Search in sources :

Example 1 with KerberosAuthenticator

use of org.apache.hadoop.security.authentication.client.KerberosAuthenticator in project hadoop by apache.

the class TopCLI method connect.

private URLConnection connect(URL url) throws Exception {
    AuthenticatedURL.Token token = new AuthenticatedURL.Token();
    AuthenticatedURL authUrl;
    SSLFactory clientSslFactory;
    URLConnection connection;
    // If https is chosen, configures SSL client.
    if (YarnConfiguration.useHttps(getConf())) {
        clientSslFactory = new SSLFactory(SSLFactory.Mode.CLIENT, getConf());
        clientSslFactory.init();
        SSLSocketFactory sslSocktFact = clientSslFactory.createSSLSocketFactory();
        authUrl = new AuthenticatedURL(new KerberosAuthenticator(), clientSslFactory);
        connection = authUrl.openConnection(url, token);
        HttpsURLConnection httpsConn = (HttpsURLConnection) connection;
        httpsConn.setSSLSocketFactory(sslSocktFact);
    } else {
        authUrl = new AuthenticatedURL(new KerberosAuthenticator());
        connection = authUrl.openConnection(url, token);
    }
    connection.connect();
    return connection;
}
Also used : SSLFactory(org.apache.hadoop.security.ssl.SSLFactory) KerberosAuthenticator(org.apache.hadoop.security.authentication.client.KerberosAuthenticator) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) URLConnection(java.net.URLConnection) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) AuthenticatedURL(org.apache.hadoop.security.authentication.client.AuthenticatedURL)

Aggregations

URLConnection (java.net.URLConnection)1 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 AuthenticatedURL (org.apache.hadoop.security.authentication.client.AuthenticatedURL)1 KerberosAuthenticator (org.apache.hadoop.security.authentication.client.KerberosAuthenticator)1 SSLFactory (org.apache.hadoop.security.ssl.SSLFactory)1