Example usage for org.apache.hadoop.hdfs.web KerberosUgiAuthenticator KerberosUgiAuthenticator

List of usage examples for org.apache.hadoop.hdfs.web KerberosUgiAuthenticator KerberosUgiAuthenticator

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.web KerberosUgiAuthenticator KerberosUgiAuthenticator.

Prototype

KerberosUgiAuthenticator

Source Link

Usage

From source file:org.apache.slider.core.restclient.SliderURLConnectionFactory.java

License:Apache License

/**
 * Opens a url with read and connect timeouts
 *
 * @param url/*from  w w  w.j  a v a  2s .c om*/
 *          URL to open
 * @param isSpnego
 *          whether the url should be authenticated via SPNEGO
 * @return URLConnection
 * @throws IOException
 * @throws AuthenticationException
 */
public URLConnection openConnection(URL url, boolean isSpnego) throws IOException, AuthenticationException {
    if (isSpnego) {
        log.debug("open AuthenticatedURL connection {}", url);
        UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
        final AuthenticatedURL.Token authToken = new AuthenticatedURL.Token();
        return new AuthenticatedURL(new KerberosUgiAuthenticator(), connConfigurator).openConnection(url,
                authToken);
    } else {
        log.debug("open URL connection {}", url);
        URLConnection connection = url.openConnection();
        if (connection instanceof HttpURLConnection) {
            connConfigurator.configure((HttpURLConnection) connection);
        }
        return connection;
    }
}