类org.apache.hadoop.security.authentication.client.Authenticator源码实例Demo

下面列出了怎么用org.apache.hadoop.security.authentication.client.Authenticator的API类实例代码及写法,或者点击链接到github查看源代码。

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;
}
 
源代码2 项目: hadoop   文件: KerberosUgiAuthenticator.java
@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);
      }
    }
  };
}
 
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
源代码4 项目: big-c   文件: KerberosUgiAuthenticator.java
@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);
      }
    }
  };
}
 
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
源代码6 项目: tez   文件: TimelineReaderFactory.java
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);
}
 
源代码7 项目: tez   文件: TimelineReaderFactory.java
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);
}
 
源代码8 项目: hadoop   文件: DelegationTokenAuthenticator.java
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
 
源代码9 项目: big-c   文件: DelegationTokenAuthenticator.java
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
 
/**
 * 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();
}
 
 类方法
 同包方法