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


Java ConnectionConfigurator类代码示例

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


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

示例1: KerberosWebHDFSConnection2

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
public KerberosWebHDFSConnection2(String httpfsUrl, String principal, String password)  {
        this.httpfsUrl = httpfsUrl;
        this.principal = principal;
        this.password = password;

        Configuration conf = new Configuration();
        conf.addResource("conf/hdfs-site.xml");
        conf.addResource("conf/core-site.xml");
        newToken = new AuthenticatedURL.Token();

        KerberosAuthenticator ka = new KerberosAuthenticator();
        ConnectionConfigurator connectionConfigurator = new SSLFactory(SSLFactory.Mode.CLIENT,conf);
        ka.setConnectionConfigurator(connectionConfigurator);

        try{
            URL url = new URL(httpfsUrl);
            ka.authenticate(url,newToken);
        }catch(Exception e){
            e.printStackTrace();
        }


         this.authenticatedURL = new AuthenticatedURL(ka,connectionConfigurator);
//        this.authenticatedURL = new AuthenticatedURL(
//                new KerberosAuthenticator2(principal, password));
    }
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:27,代码来源:KerberosWebHDFSConnection2.java

示例2: testConnConfiguratior

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
@Test
public void testConnConfiguratior() throws IOException {
  final URL u = new URL("http://localhost");
  final List<HttpURLConnection> conns = Lists.newArrayList();
  URLConnectionFactory fc = new URLConnectionFactory(new ConnectionConfigurator() {
    @Override
    public HttpURLConnection configure(HttpURLConnection conn)
        throws IOException {
      Assert.assertEquals(u, conn.getURL());
      conns.add(conn);
      return conn;
    }
  });

  fc.openConnection(u);
  Assert.assertEquals(1, conns.size());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestURLConnectionFactory.java

示例3: initSslConnConfigurator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private ConnectionConfigurator initSslConnConfigurator(final int timeout,
    Configuration conf) throws IOException, GeneralSecurityException {
  final SSLSocketFactory sf;
  final HostnameVerifier hv;

  sslFactory = new SSLFactory(SSLFactory.Mode.CLIENT, conf);
  sslFactory.init();
  sf = sslFactory.createSSLSocketFactory();
  hv = sslFactory.getHostnameVerifier();

  return new ConnectionConfigurator() {
    @Override
    public HttpURLConnection configure(HttpURLConnection conn)
        throws IOException {
      if (conn instanceof HttpsURLConnection) {
        HttpsURLConnection c = (HttpsURLConnection) conn;
        c.setSSLSocketFactory(sf);
        c.setHostnameVerifier(hv);
      }
      setTimeouts(conn, timeout);
      return conn;
    }
  };
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:25,代码来源:TimelineClientImpl.java

示例4: getHttpURLConnection

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
@Override
public HttpURLConnection getHttpURLConnection(URL url) throws IOException {
  try {
    AuthenticatedURL authenticatedURL= ReflectionUtils.createClazzInstance(
        DELEGATION_TOKEN_AUTHENTICATED_URL_CLAZZ_NAME, new Class[] {
        delegationTokenAuthenticatorClazz,
        ConnectionConfigurator.class
    }, new Object[] {
        authenticator,
        connConfigurator
    });
    return ReflectionUtils.invokeMethod(authenticatedURL,
        delegationTokenAuthenticateURLOpenConnectionMethod, url, token, doAsUser);
  } catch (Exception e) {
    throw new IOException(e);
  }
}
 
开发者ID:apache,项目名称:tez,代码行数:18,代码来源:TimelineReaderFactory.java

示例5: obtainDelegationTokenAuthenticator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private static DelegationTokenAuthenticator
    obtainDelegationTokenAuthenticator(DelegationTokenAuthenticator dta,
          ConnectionConfigurator connConfigurator) {
  try {
    if (dta == null) {
      dta = DEFAULT_AUTHENTICATOR.newInstance();
      dta.setConnectionConfigurator(connConfigurator);
    }
    return dta;
  } catch (Exception ex) {
    throw new IllegalArgumentException(ex);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:DelegationTokenAuthenticatedURL.java

示例6: newConnConfigurator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private static ConnectionConfigurator newConnConfigurator(Configuration conf) {
  try {
    return newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
  } catch (Exception e) {
    LOG.debug("Cannot load customized ssl related configuration. " +
        "Fallback to system-generic settings.", e);
    return DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TimelineClientImpl.java

示例7: newDefaultURLConnectionFactory

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
/**
 * Construct a new URLConnectionFactory based on the configuration. It will
 * try to load SSL certificates when it is specified.
 */
public static URLConnectionFactory newDefaultURLConnectionFactory(Configuration conf) {
  ConnectionConfigurator conn = null;
  try {
    conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
  } catch (Exception e) {
    LOG.debug(
        "Cannot load customized ssl related configuration. Fallback to system-generic settings.",
        e);
    conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
  }
  return new URLConnectionFactory(conn);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:URLConnectionFactory.java

示例8: newDefaultURLConnectionFactory

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
/**
 * Construct a new URLConnectionFactory based on the configuration. It will
 * try to load SSL certificates when it is specified.
 */
public static URLConnectionFactory newDefaultURLConnectionFactory(
    Configuration conf) {
  ConnectionConfigurator conn = getSSLConnectionConfiguration(conf);

  return new URLConnectionFactory(conn);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:11,代码来源:URLConnectionFactory.java

示例9: getSSLConnectionConfiguration

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private static ConnectionConfigurator getSSLConnectionConfiguration(
    Configuration conf) {
  ConnectionConfigurator conn;
  try {
    conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
  } catch (Exception e) {
    LOG.debug(
        "Cannot load customized ssl related configuration. Fallback to" +
            " system-generic settings.",
        e);
    conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
  }

  return conn;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:16,代码来源:URLConnectionFactory.java

示例10: newOAuth2URLConnectionFactory

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
/**
 * Construct a new URLConnectionFactory that supports OAut-based connections.
 * It will also try to load the SSL configuration when they are specified.
 */
public static URLConnectionFactory newOAuth2URLConnectionFactory(
    Configuration conf) throws IOException {
  ConnectionConfigurator conn;
  try {
    ConnectionConfigurator sslConnConfigurator
        = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);

    conn = new OAuth2ConnectionConfigurator(conf, sslConnConfigurator);
  } catch (Exception e) {
    throw new IOException("Unable to load OAuth2 connection factory.", e);
  }
  return new URLConnectionFactory(conn);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:URLConnectionFactory.java

示例11: OAuth2ConnectionConfigurator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public OAuth2ConnectionConfigurator(Configuration conf,
                                    ConnectionConfigurator sslConfigurator) {
  this.sslConfigurator = sslConfigurator;

  notNull(conf, ACCESS_TOKEN_PROVIDER_KEY);

  Class accessTokenProviderClass = conf.getClass(ACCESS_TOKEN_PROVIDER_KEY,
      ConfCredentialBasedAccessTokenProvider.class,
      AccessTokenProvider.class);

  accessTokenProvider = (AccessTokenProvider) ReflectionUtils
      .newInstance(accessTokenProviderClass, conf);
  accessTokenProvider.setConf(conf);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:16,代码来源:OAuth2ConnectionConfigurator.java

示例12: addDelegationTokens

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
public Token<?>[] addDelegationTokens(String strURL, String renewer,
                                      Credentials credentials) throws IOException {
  Token<?>[] tokens = null;
  Text dtService = getDelegationTokenService(strURL);
  Token<?> token = credentials.getToken(dtService);
  if (token == null) {
    URL url = new URL(strURL);
    DelegationTokenAuthenticatedURL authUrl =
            new DelegationTokenAuthenticatedURL(new ConnectionConfigurator() {
              @Override
              public HttpURLConnection configure(HttpURLConnection conn) throws IOException {
                return conn;
              }
            });
    try {
      token = authUrl.getDelegationToken(url, authToken, renewer);
      if (token != null) {
        credentials.addToken(token.getService(), token);
        tokens = new Token<?>[]{token};
      } else {
        throw new IOException("Got NULL as delegation token");
      }
    } catch (AuthenticationException ex) {
      throw new IOException(ex);
    }
  }
  return tokens;
}
 
开发者ID:vybs,项目名称:sqoop-on-spark,代码行数:29,代码来源:ResourceRequest.java

示例13: newConnConfigurator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private static ConnectionConfigurator newConnConfigurator(Configuration conf) {
    try {
        return newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT_IN_MSECS, conf);
    } catch (Exception e) {
        LOG.debug("Cannot load customized ssl related configuration. " + "Fallback to system-generic settings.", e);
        return DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
    }
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:9,代码来源:SecureClientUtils.java

示例14: initConnConfigurator

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
private ConnectionConfigurator initConnConfigurator(Configuration conf) {
  try {
    return initSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
  } catch (Exception e) {
    LOG.debug("Cannot load customized ssl related configuration. " +
        "Fallback to system-generic settings.", e);
    return DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:10,代码来源:TimelineClientImpl.java

示例15: TokenAuthenticatedURLConnectionFactory

import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; //导入依赖的package包/类
public TokenAuthenticatedURLConnectionFactory(ConnectionConfigurator connConfigurator,
                                              Authenticator authenticator,
                                              UserGroupInformation authUgi,
                                              String doAsUser) throws TezException {
  this.connConfigurator = connConfigurator;
  this.authenticator = authenticator;
  this.authUgi = authUgi;
  this.doAsUser = doAsUser;
  this.token = ReflectionUtils.createClazzInstance(
      DELEGATION_TOKEN_AUTHENTICATED_URL_TOKEN_CLASS_NAME, null, null);
}
 
开发者ID:apache,项目名称:tez,代码行数:12,代码来源:TimelineReaderFactory.java


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