|
@@ -59,6 +59,7 @@ import org.apache.hadoop.metrics2.annotation.Metric;
|
|
|
import org.apache.hadoop.metrics2.annotation.Metrics;
|
|
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
|
import org.apache.hadoop.metrics2.lib.MutableRate;
|
|
|
+import org.apache.hadoop.security.SaslRpcServer.AuthMethod;
|
|
|
import org.apache.hadoop.security.authentication.util.KerberosName;
|
|
|
import org.apache.hadoop.security.authentication.util.KerberosUtil;
|
|
|
import org.apache.hadoop.security.token.Token;
|
|
@@ -1019,13 +1020,34 @@ public class UserGroupInformation {
|
|
|
@InterfaceAudience.Public
|
|
|
@InterfaceStability.Evolving
|
|
|
public static enum AuthenticationMethod {
|
|
|
- SIMPLE,
|
|
|
- KERBEROS,
|
|
|
- TOKEN,
|
|
|
- CERTIFICATE,
|
|
|
- KERBEROS_SSL,
|
|
|
- PROXY;
|
|
|
- }
|
|
|
+ // currently we support only one auth per method, but eventually a
|
|
|
+ // subtype is needed to differentiate, ex. if digest is token or ldap
|
|
|
+ SIMPLE(AuthMethod.SIMPLE),
|
|
|
+ KERBEROS(AuthMethod.KERBEROS),
|
|
|
+ TOKEN(AuthMethod.DIGEST),
|
|
|
+ CERTIFICATE(null),
|
|
|
+ KERBEROS_SSL(null),
|
|
|
+ PROXY(null);
|
|
|
+
|
|
|
+ private final AuthMethod authMethod;
|
|
|
+ private AuthenticationMethod(AuthMethod authMethod) {
|
|
|
+ this.authMethod = authMethod;
|
|
|
+ }
|
|
|
+
|
|
|
+ public AuthMethod getAuthMethod() {
|
|
|
+ return authMethod;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static AuthenticationMethod valueOf(AuthMethod authMethod) {
|
|
|
+ for (AuthenticationMethod value : values()) {
|
|
|
+ if (value.getAuthMethod() == authMethod) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ "no authentication method for " + authMethod);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
|
* Create a proxy user using username of the effective user and the ugi of the
|
|
@@ -1290,6 +1312,15 @@ public class UserGroupInformation {
|
|
|
user.setAuthenticationMethod(authMethod);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets the authentication method in the subject
|
|
|
+ *
|
|
|
+ * @param authMethod
|
|
|
+ */
|
|
|
+ public void setAuthenticationMethod(AuthMethod authMethod) {
|
|
|
+ user.setAuthenticationMethod(AuthenticationMethod.valueOf(authMethod));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get the authentication method from the subject
|
|
|
*
|