當前位置: 首頁>>代碼示例>>Java>>正文


Java SecurityUtil.getTokenServiceAddr方法代碼示例

本文整理匯總了Java中org.apache.hadoop.security.SecurityUtil.getTokenServiceAddr方法的典型用法代碼示例。如果您正苦於以下問題:Java SecurityUtil.getTokenServiceAddr方法的具體用法?Java SecurityUtil.getTokenServiceAddr怎麽用?Java SecurityUtil.getTokenServiceAddr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.security.SecurityUtil的用法示例。


在下文中一共展示了SecurityUtil.getTokenServiceAddr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cancelDelegationToken

import org.apache.hadoop.security.SecurityUtil; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void cancelDelegationToken(
    final Token<TimelineDelegationTokenIdentifier> timelineDT)
        throws IOException, YarnException {
  final boolean isTokenServiceAddrEmpty =
      timelineDT.getService().toString().isEmpty();
  final String scheme = isTokenServiceAddrEmpty ? null
      : (YarnConfiguration.useHttps(this.getConfig()) ? "https" : "http");
  final InetSocketAddress address = isTokenServiceAddrEmpty ? null
      : SecurityUtil.getTokenServiceAddr(timelineDT);
  PrivilegedExceptionAction<Void> cancelDTAction =
      new PrivilegedExceptionAction<Void>() {

        @Override
        public Void run() throws Exception {
          // If the timeline DT to cancel is different than cached, replace it.
          // Token to set every time for retry, because when exception happens,
          // DelegationTokenAuthenticatedURL will reset it to null;
          if (!timelineDT.equals(token.getDelegationToken())) {
            token.setDelegationToken((Token) timelineDT);
          }
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          // If the token service address is not available, fall back to use
          // the configured service address.
          final URI serviceURI = isTokenServiceAddrEmpty ? resURI
              : new URI(scheme, null, address.getHostName(),
              address.getPort(), RESOURCE_URI_STR, null, null);
          authUrl.cancelDelegationToken(serviceURI.toURL(), token, doAsUser);
          return null;
        }
      };
  operateDelegationToken(cancelDTAction);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:37,代碼來源:TimelineClientImpl.java

示例2: renewDelegationToken

import org.apache.hadoop.security.SecurityUtil; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public long renewDelegationToken(
    final Token<TimelineDelegationTokenIdentifier> timelineDT)
        throws IOException, YarnException {
  final boolean isTokenServiceAddrEmpty =
      timelineDT.getService().toString().isEmpty();
  final String scheme = isTokenServiceAddrEmpty ? null
      : (YarnConfiguration.useHttps(this.getConfig()) ? "https" : "http");
  final InetSocketAddress address = isTokenServiceAddrEmpty ? null
      : SecurityUtil.getTokenServiceAddr(timelineDT);
  PrivilegedExceptionAction<Long> renewDTAction =
      new PrivilegedExceptionAction<Long>() {

        @Override
        public Long run() throws Exception {
          // If the timeline DT to renew is different than cached, replace it.
          // Token to set every time for retry, because when exception happens,
          // DelegationTokenAuthenticatedURL will reset it to null;
          if (!timelineDT.equals(token.getDelegationToken())) {
            token.setDelegationToken((Token) timelineDT);
          }
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          // If the token service address is not available, fall back to use
          // the configured service address.
          final URI serviceURI = isTokenServiceAddrEmpty ? resURI
              : new URI(scheme, null, address.getHostName(),
              address.getPort(), RESOURCE_URI_STR, null, null);
          return authUrl
              .renewDelegationToken(serviceURI.toURL(), token, doAsUser);
        }
      };
  return (Long) operateDelegationToken(renewDTAction);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:37,代碼來源:TimelineClientImpl.java

示例3: getInstance

import org.apache.hadoop.security.SecurityUtil; //導入方法依賴的package包/類
private TokenManagementDelegator getInstance(Token<?> token,
                                             Configuration conf)
        throws IOException {
  final URI uri;
  final String scheme = getSchemeByKind(token.getKind());
  if (HAUtil.isTokenForLogicalUri(token)) {
    uri = HAUtil.getServiceUriFromToken(scheme, token);
  } else {
    final InetSocketAddress address = SecurityUtil.getTokenServiceAddr
            (token);
    uri = URI.create(scheme + "://" + NetUtils.getHostPortString(address));
  }
  return (TokenManagementDelegator) FileSystem.get(uri, conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:15,代碼來源:TokenAspect.java


注:本文中的org.apache.hadoop.security.SecurityUtil.getTokenServiceAddr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。