Search in sources :

Example 6 with AuthMethod

use of org.apache.hadoop.security.SaslRpcServer.AuthMethod in project hadoop by apache.

the class Server method buildNegotiateResponse.

private RpcSaslProto buildNegotiateResponse(List<AuthMethod> authMethods) throws IOException {
    RpcSaslProto.Builder negotiateBuilder = RpcSaslProto.newBuilder();
    if (authMethods.contains(AuthMethod.SIMPLE) && authMethods.size() == 1) {
        // SIMPLE-only servers return success in response to negotiate
        negotiateBuilder.setState(SaslState.SUCCESS);
    } else {
        negotiateBuilder.setState(SaslState.NEGOTIATE);
        for (AuthMethod authMethod : authMethods) {
            SaslRpcServer saslRpcServer = new SaslRpcServer(authMethod);
            SaslAuth.Builder builder = negotiateBuilder.addAuthsBuilder().setMethod(authMethod.toString()).setMechanism(saslRpcServer.mechanism);
            if (saslRpcServer.protocol != null) {
                builder.setProtocol(saslRpcServer.protocol);
            }
            if (saslRpcServer.serverId != null) {
                builder.setServerId(saslRpcServer.serverId);
            }
        }
    }
    return negotiateBuilder.build();
}
Also used : SaslRpcServer(org.apache.hadoop.security.SaslRpcServer) SaslAuth(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto.SaslAuth) RpcSaslProto(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto) AuthMethod(org.apache.hadoop.security.SaslRpcServer.AuthMethod)

Aggregations

AuthMethod (org.apache.hadoop.security.SaslRpcServer.AuthMethod)6 ByteString (com.google.protobuf.ByteString)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Text (org.apache.hadoop.io.Text)2 SaslAuth (org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto.SaslAuth)2 ServiceException (com.google.protobuf.ServiceException)1 InetSocketAddress (java.net.InetSocketAddress)1 CallbackHandler (javax.security.auth.callback.CallbackHandler)1 SaslServer (javax.security.sasl.SaslServer)1 Configuration (org.apache.hadoop.conf.Configuration)1 Connection (org.apache.hadoop.ipc.Server.Connection)1 RpcSaslProto (org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto)1 SaslRpcServer (org.apache.hadoop.security.SaslRpcServer)1 AuthenticationMethod (org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod)1 InvalidToken (org.apache.hadoop.security.token.SecretManager.InvalidToken)1 Token (org.apache.hadoop.security.token.Token)1