Search in sources :

Example 1 with SaslRpcServer

use of org.apache.hadoop.security.SaslRpcServer 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

RpcSaslProto (org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto)1 SaslAuth (org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcSaslProto.SaslAuth)1 SaslRpcServer (org.apache.hadoop.security.SaslRpcServer)1 AuthMethod (org.apache.hadoop.security.SaslRpcServer.AuthMethod)1