File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 106106import org .apache .hadoop .ipc .protobuf .RpcHeaderProtos .RPCTraceInfoProto ;
107107import org .apache .hadoop .net .NetUtils ;
108108import org .apache .hadoop .security .AccessControlException ;
109+ import org .apache .hadoop .security .SaslConstants ;
109110import org .apache .hadoop .security .SaslPropertiesResolver ;
110111import org .apache .hadoop .security .SaslRpcServer ;
111112import org .apache .hadoop .security .SaslRpcServer .AuthMethod ;
@@ -2605,7 +2606,8 @@ private RpcSaslProto buildSaslNegotiateResponse()
26052606 RpcSaslProto negotiateMessage = negotiateResponse ;
26062607 // accelerate token negotiation by sending initial challenge
26072608 // in the negotiation response
2608- if (enabledAuthMethods .contains (AuthMethod .TOKEN )) {
2609+ if (enabledAuthMethods .contains (AuthMethod .TOKEN )
2610+ && SaslConstants .SASL_MECHANISM_DEFAULT .equals (AuthMethod .TOKEN .getMechanismName ())) {
26092611 saslServer = createSaslServer (AuthMethod .TOKEN );
26102612 byte [] challenge = saslServer .evaluateResponse (new byte [0 ]);
26112613 RpcSaslProto .Builder negotiateBuilder =
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public class SaslConstants {
3232
3333 private static final String SASL_MECHANISM_ENV = "HADOOP_SASL_MECHANISM" ;
3434 public static final String SASL_MECHANISM ;
35- private static final String SASL_MECHANISM_DEFAULT = "DIGEST-MD5" ;
35+ public static final String SASL_MECHANISM_DEFAULT = "DIGEST-MD5" ;
3636
3737 static {
3838 final String mechanism = System .getenv (SASL_MECHANISM_ENV );
Original file line number Diff line number Diff line change 3939import javax .security .auth .callback .PasswordCallback ;
4040import javax .security .auth .callback .UnsupportedCallbackException ;
4141import javax .security .auth .kerberos .KerberosPrincipal ;
42+ import javax .security .sasl .AuthorizeCallback ;
4243import javax .security .sasl .RealmCallback ;
4344import javax .security .sasl .RealmChoiceCallback ;
4445import javax .security .sasl .Sasl ;
@@ -681,9 +682,17 @@ public void handle(Callback[] callbacks)
681682 pc = (PasswordCallback ) callback ;
682683 } else if (callback instanceof RealmCallback ) {
683684 rc = (RealmCallback ) callback ;
685+ } else if (callback instanceof AuthorizeCallback ) {
686+ final AuthorizeCallback ac = (AuthorizeCallback ) callback ;
687+ final String authId = ac .getAuthenticationID ();
688+ final String authzId = ac .getAuthorizationID ();
689+ ac .setAuthorized (authId .equals (authzId ));
690+ if (ac .isAuthorized ()) {
691+ ac .setAuthorizedID (authzId );
692+ }
684693 } else {
685694 throw new UnsupportedCallbackException (callback ,
686- "Unrecognized SASL client callback" );
695+ "Unrecognized SASL client callback " + callback . getClass () );
687696 }
688697 }
689698 if (nc != null ) {
You can’t perform that action at this time.
0 commit comments