Token<DelegationTokenIdentifier> delegationToken() throws IOException {
    String delegation = param(DelegationParam.NAME);
    if (delegation == null) {
      return null;
    }
    final Token<DelegationTokenIdentifier> token = new
      Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(delegation);
    URI nnUri = URI.create(HDFS_URI_SCHEME + "://" + namenodeId());
    boolean isLogical = HAUtilClient.isLogicalUri(conf, nnUri);
    if (isLogical) {
      token.setService(
          HAUtilClient.buildTokenServiceForLogicalUri(nnUri, HDFS_URI_SCHEME));
    } else {
      token.setService(SecurityUtil.buildTokenService(nnUri));
    }
    return token;
  }
@Test
  public void testNullToken() throws IOException {
    Configuration conf = new Configuration();
    QueryStringDecoder decoder = new QueryStringDecoder(
            WebHdfsHandler.WEBHDFS_PREFIX + "/test");
    ParameterParser testParser = new ParameterParser(decoder, conf);
    Assert.assertNull(testParser.delegationToken());
  }