public boolean process(final TProtocol inProt, final TProtocol outProt) throws TException {
TTransport trans = inProt.getTransport();
if (!(trans instanceof TSaslServerTransport)) {
throw new TException("Unexpected non-SASL transport " + trans.getClass());
}
TSaslServerTransport saslTrans = (TSaslServerTransport)trans;
SaslServer saslServer = saslTrans.getSaslServer();
String authId = saslServer.getAuthorizationID();
authenticationMethod.set(AuthenticationMethod.KERBEROS);
LOG.debug("AUTH ID ======>" + authId);
String endUser = authId;
if(saslServer.getMechanismName().equals("DIGEST-MD5")) {
try {
TokenIdentifier tokenId = SaslRpcServer.getIdentifier(authId,
secretManager);
endUser = tokenId.getUser().getUserName();
authenticationMethod.set(AuthenticationMethod.TOKEN);
} catch (InvalidToken e) {
throw new TException(e.getMessage());
}
}
Socket socket = ((TSocket)(saslTrans.getUnderlyingTransport())).getSocket();
remoteAddress.set(socket.getInetAddress());
try {
UserGroupInformation clientUgi = UserGroupInformation.createProxyUser(
endUser, UserGroupInformation.getLoginUser());
return clientUgi.doAs(new PrivilegedExceptionAction<Boolean>() {