* the login context performed by the GSSAPI mechanism handler. See comments
* for processing overview.
* @return {@code true} if the authentication processing was successful.
*/
public Boolean run() {
ClientConnection clientConn = bindOp.getClientConnection();
//If the SASL server is null then this is the first handshake and the
//server needs to be initialized before any processing can be performed.
//If the SASL server cannot be created then all processing is abandoned
//and INVALID_CREDENTIALS is returned to the client.
if(saslServer == null) {
try {
initSASLServer();
} catch (SaslException ex) {
if (debugEnabled())
TRACER.debugCaught(DebugLogLevel.ERROR, ex);
Message msg;
GSSException gex = (GSSException) ex.getCause();
if(gex != null)
msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
GSSAPISASLMechanismHandler.getGSSExceptionMessage(gex));
else
msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
getExceptionMessage(ex));
clientConn.setSASLAuthStateInfo(null);
bindOp.setAuthFailureReason(msg);
bindOp.setResultCode(ResultCode.INVALID_CREDENTIALS);
return false;
}
}
ByteString clientCredentials = bindOp.getSASLCredentials();
clientConn.setSASLAuthStateInfo(null);
try {
ByteString responseAuthStr = evaluateResponse(clientCredentials);
//If the bind has not been completed,then
//more handshake is needed and SASL_BIND_IN_PROGRESS is returned back
//to the client.
if (isBindComplete()) {
bindOp.setResultCode(ResultCode.SUCCESS);
bindOp.setSASLAuthUserEntry(authEntry);
AuthenticationInfo authInfo =
new AuthenticationInfo(authEntry, authzEntry,
mechanism, clientCredentials,
DirectoryServer.isRootDN(authEntry.getDN()));
bindOp.setAuthenticationInfo(authInfo);
//If confidentiality/integrity has been negotiated then
//create a SASL security provider and save it in the client
//connection. If confidentiality/integrity has not been
//negotiated, dispose of the SASL server.
if(isConfidentialIntegrity()) {
SASLByteChannel saslByteChannel =
SASLByteChannel.getSASLByteChannel(clientConn,
mechanism, this);
LDAPClientConnection ldapConn =
(LDAPClientConnection) clientConn;
ldapConn.setSASLPendingProvider(saslByteChannel);
} else {
dispose();
clientConn.setSASLAuthStateInfo(null);
}
} else {
bindOp.setServerSASLCredentials(responseAuthStr);
clientConn.setSASLAuthStateInfo(this);
bindOp.setResultCode(ResultCode.SASL_BIND_IN_PROGRESS);
}
} catch (SaslException e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);