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


Java Token.setKind方法代码示例

本文整理汇总了Java中org.apache.hadoop.security.token.Token.setKind方法的典型用法代码示例。如果您正苦于以下问题:Java Token.setKind方法的具体用法?Java Token.setKind怎么用?Java Token.setKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.security.token.Token的用法示例。


在下文中一共展示了Token.setKind方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWebHdfsFileSystem

import org.apache.hadoop.security.token.Token; //导入方法依赖的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: testNodeHeartBeatResponse

import org.apache.hadoop.security.token.Token; //导入方法依赖的package包/类
@Test
public void testNodeHeartBeatResponse() throws IOException {
  NodeHeartbeatResponse record =
      Records.newRecord(NodeHeartbeatResponse.class);
  Map<ApplicationId, ByteBuffer> appCredentials =
      new HashMap<ApplicationId, ByteBuffer>();
  Credentials app1Cred = new Credentials();

  Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>();
  token1.setKind(new Text("kind1"));
  app1Cred.addToken(new Text("token1"), token1);
  Token<DelegationTokenIdentifier> token2 =
      new Token<DelegationTokenIdentifier>();
  token2.setKind(new Text("kind2"));
  app1Cred.addToken(new Text("token2"), token2);

  DataOutputBuffer dob = new DataOutputBuffer();
  app1Cred.writeTokenStorageToStream(dob);
  ByteBuffer byteBuffer1 = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
  appCredentials.put(ApplicationId.newInstance(1234, 1), byteBuffer1);
  record.setSystemCredentialsForApps(appCredentials);

  NodeHeartbeatResponse proto =
      new NodeHeartbeatResponsePBImpl(
        ((NodeHeartbeatResponsePBImpl) record).getProto());
  Assert.assertEquals(appCredentials, proto.getSystemCredentialsForApps());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestProtocolRecords.java

示例3: generateDelegationToken

import org.apache.hadoop.security.token.Token; //导入方法依赖的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

示例4: injectToken

import org.apache.hadoop.security.token.Token; //导入方法依赖的package包/类
private void injectToken() throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    Token<DelegationTokenIdentifier> token = params.delegationToken();
    token.setKind(HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:WebHdfsHandler.java

示例5: getTokenUGI

import org.apache.hadoop.security.token.Token; //导入方法依赖的package包/类
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:JspHelper.java

示例6: getTokenOwner

import org.apache.hadoop.security.token.Token; //导入方法依赖的package包/类
private String getTokenOwner(Token<?> token) throws IOException {
  // webhdfs doesn't register properly with the class loader
  @SuppressWarnings({ "rawtypes", "unchecked" })
  Token<?> clone = new Token(token);
  clone.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  return clone.decodeIdentifier().getUser().getUserName();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestWebHdfsTokens.java


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