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


Java TestDelegationTokenIdentifier类代码示例

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


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

示例1: testDecodeIdentifier

import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
public void testDecodeIdentifier() throws IOException {
  TestDelegationTokenSecretManager secretManager =
    new TestDelegationTokenSecretManager(0, 0, 0, 0);
  secretManager.startThreads();
  TestDelegationTokenIdentifier id = new TestDelegationTokenIdentifier(
      new Text("owner"), new Text("renewer"), new Text("realUser"));
  
  Token<TestDelegationTokenIdentifier> token =
    new Token<TestDelegationTokenIdentifier>(id, secretManager);
  TokenIdentifier idCopy = token.decodeIdentifier();
  
  assertNotSame(id, idCopy);
  assertEquals(id, idCopy);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestToken.java

示例2: getDelegationToken

import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
@Override // MiniProtocol
public Token<TestDelegationTokenIdentifier> getDelegationToken(Text renewer) 
throws IOException {
  String owner = UserGroupInformation.getCurrentUser().getUserName();
  String realUser = 
    UserGroupInformation.getCurrentUser().getRealUser() == null ? "":
    UserGroupInformation.getCurrentUser().getRealUser().getUserName();
  TestDelegationTokenIdentifier tokenId = 
    new TestDelegationTokenIdentifier(
        new Text(owner), renewer, new Text(realUser));
  return new Token<TestDelegationTokenIdentifier>(tokenId, secretManager);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:MiniRPCBenchmark.java

示例3: connectToServerAndGetDelegationToken

import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
void connectToServerAndGetDelegationToken(
    final Configuration conf, final InetSocketAddress addr) throws IOException {
  MiniProtocol client = null;
  try {
    UserGroupInformation current = UserGroupInformation.getCurrentUser();
    UserGroupInformation proxyUserUgi = 
      UserGroupInformation.createProxyUserForTesting(
          MINI_USER, current, GROUP_NAMES);
    
    try {
      client =  proxyUserUgi.doAs(new PrivilegedExceptionAction<MiniProtocol>() {
        @Override
        public MiniProtocol run() throws IOException {
          MiniProtocol p = RPC.getProxy(MiniProtocol.class,
              MiniProtocol.versionID, addr, conf);
          Token<TestDelegationTokenIdentifier> token;
          token = p.getDelegationToken(new Text(RENEWER));
          currentUgi = UserGroupInformation.createUserForTesting(MINI_USER, 
              GROUP_NAMES);
          SecurityUtil.setTokenService(token, addr);
          currentUgi.addToken(token);
          return p;
        }
      });
    } catch (InterruptedException e) {
      Assert.fail(Arrays.toString(e.getStackTrace()));
    }
  } finally {
    RPC.stopProxy(client);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:MiniRPCBenchmark.java

示例4: connectToServerAndGetDelegationToken

import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
void connectToServerAndGetDelegationToken(
    final Configuration conf, final InetSocketAddress addr) throws IOException {
  MiniProtocol client = null;
  try {
    UserGroupInformation current = UserGroupInformation.getCurrentUser();
    UserGroupInformation proxyUserUgi = 
      UserGroupInformation.createProxyUserForTesting(
          MINI_USER, current, GROUP_NAMES);
    
    try {
      client =  proxyUserUgi.doAs(new PrivilegedExceptionAction<MiniProtocol>() {
        public MiniProtocol run() throws IOException {
          MiniProtocol p = (MiniProtocol) RPC.getProxy(MiniProtocol.class,
              MiniProtocol.versionID, addr, conf);
          Token<TestDelegationTokenIdentifier> token;
          token = p.getDelegationToken(new Text(RENEWER));
          currentUgi = UserGroupInformation.createUserForTesting(MINI_USER, 
              GROUP_NAMES);
          SecurityUtil.setTokenService(token, addr);
          currentUgi.addToken(token);
          return p;
        }
      });
    } catch (InterruptedException e) {
      Assert.fail(Arrays.toString(e.getStackTrace()));
    }
  } finally {
    RPC.stopProxy(client);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:31,代码来源:MiniRPCBenchmark.java


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