Example usage for org.apache.hadoop.security.authentication.client AuthenticatedURL AuthenticatedURL

List of usage examples for org.apache.hadoop.security.authentication.client AuthenticatedURL AuthenticatedURL

Introduction

In this page you can find the example usage for org.apache.hadoop.security.authentication.client AuthenticatedURL AuthenticatedURL.

Prototype

public AuthenticatedURL() 

Source Link

Document

Creates an AuthenticatedURL .

Usage

From source file:azkaban.utils.AuthenticationUtils.java

License:Apache License

public static HttpURLConnection loginAuthenticatedURL(final URL url, final String keytabPrincipal,
        final String keytabPath) throws Exception {

    logger.info("Logging in URL: " + url.toString() + " using Principal: " + keytabPrincipal + ", Keytab: "
            + keytabPath);//from  www . j av  a 2 s .co  m

    UserGroupInformation loginUser = UserGroupInformation.getLoginUser();

    if (loginUser == null) {
        UserGroupInformation.loginUserFromKeytab(keytabPrincipal, keytabPath);
        loginUser = UserGroupInformation.getLoginUser();
        logger.info("Logged in with user " + loginUser);
    } else {
        logger.info("Login user (" + loginUser + ") already created, refreshing tgt.");
        loginUser.checkTGTAndReloginFromKeytab();
    }

    final HttpURLConnection connection = loginUser.doAs((PrivilegedExceptionAction<HttpURLConnection>) () -> {
        final Token token = new Token();
        return new AuthenticatedURL().openConnection(url, token);
    });

    return connection;
}

From source file:com.linkedin.drelephant.analysis.AnalyticJobGeneratorHadoop2.java

License:Apache License

/**
 * Authenticate and update the token//from ww  w  .  ja v a2  s  .  co m
 */
private void updateAuthToken() {
    if (_currentTime - _tokenUpdatedTime > TOKEN_UPDATE_INTERVAL) {
        logger.info("AnalysisProvider updating its Authenticate Token...");
        _token = new AuthenticatedURL.Token();
        _authenticatedURL = new AuthenticatedURL();
        _tokenUpdatedTime = _currentTime;
    }
}

From source file:com.linkedin.drelephant.exceptions.MRClient.java

License:Apache License

public MRClient() {
    _token = new AuthenticatedURL.Token();
    _authenticatedURL = new AuthenticatedURL();
}

From source file:com.linkedin.drelephant.mapreduce.fetchers.MapReduceFetcherHadoop2.java

License:Apache License

public static void updateAuthToken() {
    long curTime = System.currentTimeMillis();
    if (curTime - _LOCAL_LAST_UPDATED.get() > _LOCAL_UPDATE_INTERVAL.get()) {
        logger.info("Executor " + _LOCAL_THREAD_ID.get() + " updates its AuthenticatedToken.");
        _LOCAL_AUTH_TOKEN.set(new AuthenticatedURL.Token());
        _LOCAL_AUTH_URL.set(new AuthenticatedURL());
        _LOCAL_LAST_UPDATED.set(curTime);
    }/*w  w w .  j  a v  a 2 s . c  o m*/
}

From source file:com.linkedin.drelephant.tuning.APIFitnessComputeUtil.java

License:Apache License

/**
 * Authenticate and update the token//from  w ww .  j  av a 2 s. co m
 */
private void updateAuthToken() {
    _currentTime = System.currentTimeMillis() - FETCH_DELAY;
    if (_currentTime - _tokenUpdatedTime > TOKEN_UPDATE_INTERVAL) {
        logger.info("AnalysisProvider updating its Authenticate Token...");
        _token = new AuthenticatedURL.Token();
        _authenticatedURL = new AuthenticatedURL();
        _tokenUpdatedTime = _currentTime;
    }
}

From source file:com.trendmicro.hdfs.webdav.tool.Get.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Process command line 

    Options options = new Options();
    options.addOption("d", "debug", false, "Enable debug logging");

    CommandLine cmd = null;// w w  w.  j  a  v  a2  s  .c  o m
    try {
        cmd = new PosixParser().parse(options, args);
    } catch (ParseException e) {
        printUsageAndExit(options, -1);
    }
    boolean debug = cmd.hasOption('d');
    args = cmd.getArgs();
    if (args.length < 1) {
        printUsageAndExit(options, -1);
    }

    // Do the fetch

    AuthenticatedURL.Token token = new AuthenticatedURL.Token();
    AuthenticatedURL url = new AuthenticatedURL();
    HttpURLConnection conn = url.openConnection(new URL(args[0]), token);
    if (debug) {
        System.out.println("Token value: " + token);
        System.out.println("Status code: " + conn.getResponseCode() + " " + conn.getResponseMessage());
    }
    if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line = reader.readLine();
        while (line != null) {
            System.out.println(line);
            line = reader.readLine();
        }
        reader.close();
    }
    System.out.println();
}