|
@@ -103,7 +103,11 @@ public abstract class Server {
|
|
|
static int INITIAL_RESP_BUF_SIZE = 10240;
|
|
|
|
|
|
public static final Log LOG = LogFactory.getLog(Server.class);
|
|
|
-
|
|
|
+ public static final Log auditLOG =
|
|
|
+ LogFactory.getLog("SecurityLogger."+Server.class.getName());
|
|
|
+ private static final String AUTH_FAILED_FOR = "Auth failed for ";
|
|
|
+ private static final String AUTH_SUCCESSFULL_FOR = "Auth successfull for ";
|
|
|
+
|
|
|
private static final ThreadLocal<Server> SERVER = new ThreadLocal<Server>();
|
|
|
|
|
|
private static final Map<String, Class<?>> PROTOCOL_CACHE =
|
|
@@ -718,7 +722,7 @@ public abstract class Server {
|
|
|
}
|
|
|
|
|
|
/** Reads calls from a connection and queues them for handling. */
|
|
|
- private class Connection {
|
|
|
+ public class Connection {
|
|
|
private boolean rpcHeaderRead = false; // if initial rpc header is read
|
|
|
private boolean headerRead = false; //if the connection header that
|
|
|
//follows version is read.
|
|
@@ -748,6 +752,7 @@ public abstract class Server {
|
|
|
private ByteBuffer unwrappedDataLengthBuffer;
|
|
|
|
|
|
UserGroupInformation user = null;
|
|
|
+ public UserGroupInformation attemptingUser = null; // user name before auth
|
|
|
|
|
|
// Fake 'call' for failed authorization response
|
|
|
private static final int AUTHROIZATION_FAILED_CALLID = -1;
|
|
@@ -844,7 +849,7 @@ public abstract class Server {
|
|
|
saslServer = Sasl.createSaslServer(AuthMethod.DIGEST
|
|
|
.getMechanismName(), null, SaslRpcServer.SASL_DEFAULT_REALM,
|
|
|
SaslRpcServer.SASL_PROPS, new SaslDigestCallbackHandler(
|
|
|
- secretManager));
|
|
|
+ secretManager, this));
|
|
|
break;
|
|
|
default:
|
|
|
UserGroupInformation current = UserGroupInformation
|
|
@@ -884,6 +889,9 @@ public abstract class Server {
|
|
|
replyToken = saslServer.evaluateResponse(saslToken);
|
|
|
} catch (SaslException se) {
|
|
|
rpcMetrics.authenticationFailures.inc();
|
|
|
+ String clientIP = this.toString();
|
|
|
+ // attempting user could be null
|
|
|
+ auditLOG.warn(AUTH_FAILED_FOR + clientIP + ":" + attemptingUser, se);
|
|
|
throw se;
|
|
|
}
|
|
|
if (replyToken != null) {
|
|
@@ -905,6 +913,8 @@ public abstract class Server {
|
|
|
}
|
|
|
user = getAuthorizedUgi(saslServer.getAuthorizationID());
|
|
|
LOG.info("SASL server successfully authenticated client: " + user);
|
|
|
+ rpcMetrics.authenticationSuccesses.inc();
|
|
|
+ auditLOG.info(AUTH_SUCCESSFULL_FOR + user);
|
|
|
saslContextEstablished = true;
|
|
|
}
|
|
|
} else {
|
|
@@ -1103,7 +1113,6 @@ public abstract class Server {
|
|
|
|
|
|
private void processOneRpc(byte[] buf) throws IOException,
|
|
|
InterruptedException {
|
|
|
- rpcMetrics.authenticationSuccesses.inc();
|
|
|
if (headerRead) {
|
|
|
processData(buf);
|
|
|
} else {
|