当前位置: 首页>>代码示例>>Java>>正文


Java DelegationTokenSecretManager类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager的典型用法代码示例。如果您正苦于以下问题:Java DelegationTokenSecretManager类的具体用法?Java DelegationTokenSecretManager怎么用?Java DelegationTokenSecretManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DelegationTokenSecretManager类属于org.apache.hadoop.hdfs.security.token.delegation包,在下文中一共展示了DelegationTokenSecretManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWebHdfsFileSystem

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private WebHdfsFileSystem getWebHdfsFileSystem(UserGroupInformation ugi,
    Configuration conf) throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(new Text(
        ugi.getUserName()), null, null);
    FSNamesystem namesystem = mock(FSNamesystem.class);
    DelegationTokenSecretManager dtSecretManager = new DelegationTokenSecretManager(
        86400000, 86400000, 86400000, 86400000, namesystem);
    dtSecretManager.startThreads();
    Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
        dtId, dtSecretManager);
    SecurityUtil.setTokenService(
        token, NetUtils.createSocketAddr(uri.getAuthority()));
    token.setKind(WebHdfsFileSystem.TOKEN_KIND);
    ugi.addToken(token);
  }
  return (WebHdfsFileSystem) FileSystem.get(uri, conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestWebHdfsUrl.java

示例2: getWebHdfsFileSystem

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private WebHdfsFileSystem getWebHdfsFileSystem(UserGroupInformation ugi,
    Configuration conf) throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(new Text(
        ugi.getUserName()), null, null);
    FSNamesystem namesystem = mock(FSNamesystem.class);
    DelegationTokenSecretManager dtSecretManager = new DelegationTokenSecretManager(
        86400000, 86400000, 86400000, 86400000, namesystem);
    dtSecretManager.startThreads();
    Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
        dtId, dtSecretManager);
    SecurityUtil.setTokenService(
        token, NetUtils.createSocketAddr(uri.getAuthority()));
    token.setKind(WebHdfsConstants.WEBHDFS_TOKEN_KIND);
    ugi.addToken(token);
  }
  return (WebHdfsFileSystem) FileSystem.get(uri, conf);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:TestWebHdfsUrl.java

示例3: getWebHdfsFileSystem

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private WebHdfsFileSystem getWebHdfsFileSystem(UserGroupInformation ugi,
    Configuration conf) throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    DelegationTokenIdentifier dtId =
        new DelegationTokenIdentifier(new Text(ugi.getUserName()), null,
            null);
    FSNamesystem namesystem = mock(FSNamesystem.class);
    DelegationTokenSecretManager dtSecretManager =
        new DelegationTokenSecretManager(86400000, 86400000, 86400000,
            86400000, namesystem);
    dtSecretManager.startThreads();
    Token<DelegationTokenIdentifier> token =
        new Token<>(dtId, dtSecretManager);
    SecurityUtil.setTokenService(token,
        NetUtils.createSocketAddr(uri.getAuthority()));
    token.setKind(WebHdfsFileSystem.TOKEN_KIND);
    ugi.addToken(token);
  }
  return (WebHdfsFileSystem) FileSystem.get(uri, conf);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:TestWebHdfsUrl.java

示例4: testCancelDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
@Test 
public void testCancelDelegationToken() throws Exception {
  DelegationTokenSecretManager dtSecretManager = cluster.getNameNode()
      .getNamesystem().getDelegationTokenSecretManager();
  Token<DelegationTokenIdentifier> token = generateDelegationToken(
      "SomeUser", "JobTracker");
  //Fake renewer should not be able to renew
  try {
    dtSecretManager.cancelToken(token, "FakeCanceller");
    Assert.fail("should have failed");
  } catch (AccessControlException ace) {
    // PASS
  }
  dtSecretManager.cancelToken(token, "JobTracker");
  try {
    dtSecretManager.renewToken(token, "JobTracker");
    Assert.fail("should have failed");
  } catch (InvalidToken it) {
    // PASS
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:22,代码来源:TestDelegationToken.java

示例5: testDelegationTokenDFSApi

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
@Test
public void testDelegationTokenDFSApi() throws Exception {
  DelegationTokenSecretManager dtSecretManager = cluster.getNameNode()
      .getNamesystem().getDelegationTokenSecretManager();
  DistributedFileSystem dfs = (DistributedFileSystem) cluster.getFileSystem();
  final Token<DelegationTokenIdentifier> token = dfs.getDelegationToken(new Text("JobTracker"));
  DelegationTokenIdentifier identifier = new DelegationTokenIdentifier();
  byte[] tokenId = token.getIdentifier();
  identifier.readFields(new DataInputStream(
           new ByteArrayInputStream(tokenId)));
  LOG.info("A valid token should have non-null password, and should be renewed successfully");
  Assert.assertTrue(null != dtSecretManager.retrievePassword(identifier));
  dtSecretManager.renewToken(token, "JobTracker");
  UserGroupInformation.createRemoteUser("JobTracker").doAs(
      new PrivilegedExceptionAction<Object>() {
        @Override
        public Object run() throws Exception {
          token.renew(config);
          token.cancel(config);
          return null;
        }
      });
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:24,代码来源:TestDelegationToken.java

示例6: testCancelDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
@Test 
public void testCancelDelegationToken() throws Exception {
  DelegationTokenSecretManager dtSecretManager = cluster.getNamesystem()
      .getDelegationTokenSecretManager();
  Token<DelegationTokenIdentifier> token = generateDelegationToken(
      "SomeUser", "JobTracker");
  //Fake renewer should not be able to renew
  try {
    dtSecretManager.cancelToken(token, "FakeCanceller");
    Assert.fail("should have failed");
  } catch (AccessControlException ace) {
    // PASS
  }
  dtSecretManager.cancelToken(token, "JobTracker");
  try {
    dtSecretManager.renewToken(token, "JobTracker");
    Assert.fail("should have failed");
  } catch (InvalidToken it) {
    // PASS
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:22,代码来源:TestDelegationToken.java

示例7: generateDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager.createCredentials(
      namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
  if (c == null) {
    return null;
  }
  final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
  Text kind = request.getScheme().equals("http") ? WebHdfsFileSystem.TOKEN_KIND
      : SWebHdfsFileSystem.TOKEN_KIND;
  t.setKind(kind);
  return t;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:NamenodeWebHdfsMethods.java

示例8: saveSecretManagerSection

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private void saveSecretManagerSection(FileSummary.Builder summary)
    throws IOException {
  final FSNamesystem fsn = context.getSourceNamesystem();
  DelegationTokenSecretManager.SecretManagerState state = fsn
      .saveSecretManagerState();
  state.section.writeDelimitedTo(sectionOutputStream);
  for (SecretManagerSection.DelegationKey k : state.keys)
    k.writeDelimitedTo(sectionOutputStream);

  for (SecretManagerSection.PersistToken t : state.tokens)
    t.writeDelimitedTo(sectionOutputStream);

  commitSection(summary, SectionName.SECRET_MANAGER);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:FSImageFormatProtobuf.java

示例9: createDelegationTokenSecretManager

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
/**
 * Create delegation token secret manager
 */
private DelegationTokenSecretManager createDelegationTokenSecretManager(
    Configuration conf) {
  return new DelegationTokenSecretManager(conf.getLong(
      DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_KEY,
      DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT),
      conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY,
          DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT),
      conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,
          DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT),
      DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL,
      conf.getBoolean(DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_KEY,
          DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_DEFAULT),
      this);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:FSNamesystem.java

示例10: generateDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager.createCredentials(
      namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
  if (c == null) {
    return null;
  }
  final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
  Text kind = request.getScheme().equals("http") ? WebHdfsConstants.WEBHDFS_TOKEN_KIND
      : WebHdfsConstants.SWEBHDFS_TOKEN_KIND;
  t.setKind(kind);
  return t;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:15,代码来源:NamenodeWebHdfsMethods.java

示例11: printTokens

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private static void printTokens(final Configuration conf,
                                final Path tokenFile)
        throws IOException {
  DelegationTokenIdentifier id = new DelegationTokenSecretManager(0, 0, 0,
          0, null).createIdentifier();
  for (Token<?> token : readTokens(tokenFile, conf)) {
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(token
            .getIdentifier()));
    id.readFields(in);
    System.out.println("Token (" + id + ") for " + token.getService());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:13,代码来源:DelegationTokenFetcher.java

示例12: getWebHdfsFileSystem

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private WebHdfsFileSystem getWebHdfsFileSystem(UserGroupInformation ugi,
    Configuration conf, List<Token<DelegationTokenIdentifier>> tokens)
    throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(new Text(
        ugi.getUserName()), null, null);
    FSNamesystem namesystem = mock(FSNamesystem.class);
    DelegationTokenSecretManager dtSecretManager = new DelegationTokenSecretManager(
        86400000, 86400000, 86400000, 86400000, namesystem);
    dtSecretManager.startThreads();
    Token<DelegationTokenIdentifier> token1 = new Token<DelegationTokenIdentifier>(
        dtId, dtSecretManager);
    Token<DelegationTokenIdentifier> token2 = new Token<DelegationTokenIdentifier>(
        dtId, dtSecretManager);
    SecurityUtil.setTokenService(token1,
        NetUtils.createSocketAddr(uri.getAuthority()));
    SecurityUtil.setTokenService(token2,
        NetUtils.createSocketAddr(uri.getAuthority()));
    token1.setKind(WebHdfsConstants.WEBHDFS_TOKEN_KIND);
    token2.setKind(WebHdfsConstants.WEBHDFS_TOKEN_KIND);

    tokens.add(token1);
    tokens.add(token2);

    ugi.addToken(token1);
    ugi.addToken(token2);
  }
  return (WebHdfsFileSystem) FileSystem.get(uri, conf);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:30,代码来源:TestDataNodeUGIProvider.java

示例13: generateDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager.createCredentials(
      namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
  final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
  t.setKind(WebHdfsFileSystem.TOKEN_KIND);
  return t;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:10,代码来源:NamenodeWebHdfsMethods.java

示例14: createDelegationTokenSecretManager

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
/**
 * Create delegation token secret manager
 */
private DelegationTokenSecretManager createDelegationTokenSecretManager(
    Configuration conf) {
  return new DelegationTokenSecretManager(conf.getLong(
      DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_KEY,
      DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT),
      conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY,
          DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT),
      conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,
          DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT),
      DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL, this);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:15,代码来源:FSNamesystem.java

示例15: generateDelegationToken

import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager; //导入依赖的package包/类
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager
      .createCredentials(namenode, ugi,
          renewer != null ? renewer : ugi.getShortUserName());
  final Token<? extends TokenIdentifier> t =
      c.getAllTokens().iterator().next();
  t.setKind(WebHdfsFileSystem.TOKEN_KIND);
  SecurityUtil.setTokenService(t, namenode.getHttpAddress());
  return t;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:13,代码来源:NamenodeWebHdfsMethods.java


注:本文中的org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。