Java Code Examples for org.apache.hadoop.security.authentication.client.Authenticator

The following examples show how to use org.apache.hadoop.security.authentication.client.Authenticator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Transwarp-Sample-Code   Source File: PseudoWebHDFSConnection.java    License: MIT License 6 votes vote down vote up
public static synchronized Token generateToken(String srvUrl, String princ,
                                               String passwd) {
    AuthenticatedURL.Token newToken = new AuthenticatedURL.Token();
    Authenticator authenticator = new PseudoAuthenticator(princ);
    try {
        String spec = MessageFormat.format(
                "/webhdfs/v1/?op=GETHOMEDIRECTORY&user.name={0}", princ);
        HttpURLConnection conn = new AuthenticatedURL(authenticator)
                .openConnection(new URL(new URL(srvUrl), spec), newToken);

        conn.connect();
        conn.disconnect();
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        logger.error("[" + princ + ":" + passwd + "]@" + srvUrl, ex);
    }

    return newToken;
}
 
Example 2
Source Project: hadoop   Source File: KerberosUgiAuthenticator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Authenticator getFallBackAuthenticator() {
  return new PseudoAuthenticator() {
    @Override
    protected String getUserName() {
      try {
        return UserGroupInformation.getLoginUser().getUserName();
      } catch (IOException e) {
        throw new SecurityException("Failed to obtain current username", e);
      }
    }
  };
}
 
Example 3
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
Example 4
Source Project: big-c   Source File: KerberosUgiAuthenticator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Authenticator getFallBackAuthenticator() {
  return new PseudoAuthenticator() {
    @Override
    protected String getUserName() {
      try {
        return UserGroupInformation.getLoginUser().getUserName();
      } catch (IOException e) {
        throw new SecurityException("Failed to obtain current username", e);
      }
    }
  };
}
 
Example 5
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
Example 6
Source Project: tez   Source File: TimelineReaderFactory.java    License: Apache License 2.0 5 votes vote down vote up
private static Authenticator getTokenAuthenticator() throws TezException {
  String authenticatorClazzName;

  if (UserGroupInformation.isSecurityEnabled()) {
    authenticatorClazzName = KERBEROS_DELEGATION_TOKEN_AUTHENTICATOR_CLAZZ_NAME;
  } else {
    authenticatorClazzName = PSEUDO_DELEGATION_TOKEN_AUTHENTICATOR_CLAZZ_NAME;
  }

  return ReflectionUtils.createClazzInstance(authenticatorClazzName);
}
 
Example 7
Source Project: tez   Source File: TimelineReaderFactory.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
Source Project: hadoop   Source File: DelegationTokenAuthenticator.java    License: Apache License 2.0 4 votes vote down vote up
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
 
Example 9
Source Project: big-c   Source File: DelegationTokenAuthenticator.java    License: Apache License 2.0 4 votes vote down vote up
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
 
Example 10
Source Project: Transwarp-Sample-Code   Source File: KerberosAuthenticator2.java    License: MIT License 2 votes vote down vote up
/**
 * If the specified URL does not support SPNEGO authentication, a fallback
 * {@link Authenticator} will be used.
 * <p/>
 * This implementation returns a {@link PseudoAuthenticator}.
 *
 * @return the fallback {@link Authenticator}.
 */
protected Authenticator getFallBackAuthenticator() {
    return new PseudoAuthenticator();
}