當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。