Java Code Examples for org.apache.hadoop.security.UserGroupInformation.checkTGTAndReloginFromKeytab()

The following are Jave code examples for showing how to use checkTGTAndReloginFromKeytab() of the org.apache.hadoop.security.UserGroupInformation class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: flume-release-1.7.0   File: UGIExecutor.java   View Source Code Vote up 6 votes
private void reloginUGI(UserGroupInformation ugi) {
  try {
    if (ugi.hasKerberosCredentials()) {
      long now = System.currentTimeMillis();
      if (now - lastReloginAttempt < MIN_TIME_BEFORE_RELOGIN) {
        return;
      }
      lastReloginAttempt = now;
      ugi.checkTGTAndReloginFromKeytab();
    }
  } catch (IOException e) {
    throw new SecurityException("Error trying to relogin from keytab for user "
            + ugi.getUserName(), e);
  }
}
 
Example 2
Project: hadoop   File: DFSClientCache.java   View Source Code Vote up 6 votes
/**
 * This method uses the currentUser, and real user to create a proxy
 * @param effectiveUser The user who is being proxied by the real user
 * @param realUser The actual user who does the command
 * @return Proxy UserGroupInformation
 * @throws IOException If proxying fails
 */
UserGroupInformation getUserGroupInformation(
        String effectiveUser,
        UserGroupInformation realUser)
        throws IOException {
  Preconditions.checkNotNull(effectiveUser);
  Preconditions.checkNotNull(realUser);
  realUser.checkTGTAndReloginFromKeytab();

  UserGroupInformation ugi =
          UserGroupInformation.createProxyUser(effectiveUser, realUser);
  if (LOG.isDebugEnabled()){
    LOG.debug(String.format("Created ugi:" +
            " %s for username: %s", ugi, effectiveUser));
  }
  return ugi;
}
 
Example 3
Project: hadoop   File: WebHdfsFileSystem.java   View Source Code Vote up 6 votes
T run() throws IOException {
  UserGroupInformation connectUgi = ugi.getRealUser();
  if (connectUgi == null) {
    connectUgi = ugi;
  }
  if (op.getRequireAuth()) {
    connectUgi.checkTGTAndReloginFromKeytab();
  }
  try {
    // the entire lifecycle of the connection must be run inside the
    // doAs to ensure authentication is performed correctly
    return connectUgi.doAs(
        new PrivilegedExceptionAction<T>() {
          @Override
          public T run() throws IOException {
            return runWithRetry();
          }
        });
  } catch (InterruptedException e) {
    throw new IOException(e);
  }
}
 
Example 4
Project: dremio-oss   File: HiveClient.java   View Source Code Vote up 5 votes
private void reloginExpiringKeytabUser() throws MetaException {
  if(UserGroupInformation.isSecurityEnabled()) {
    // renew the TGT if required
    try {
      UserGroupInformation ugi = UserGroupInformation.getLoginUser();
      if (ugi.isFromKeytab()) {
        ugi.checkTGTAndReloginFromKeytab();
      }
    } catch (IOException e) {
      final String msg = "Error doing relogin using keytab " + e.getMessage();
      logger.error(msg, e);
      throw new MetaException(msg);
    }
  }
}