* {@inheritDoc}
*/
@Override()
public void processSASLBind(BindOperation bindOp)
{
ClientConnection clientConnection = bindOp.getClientConnection();
if (clientConnection == null)
{
Message message = ERR_SASLGSSAPI_NO_CLIENT_CONNECTION.get();
bindOp.setAuthFailureReason(message);
bindOp.setResultCode(ResultCode.INVALID_CREDENTIALS);
return;
}
ClientConnection clientConn = bindOp.getClientConnection();
SASLContext saslContext = (SASLContext) clientConn.getSASLAuthStateInfo();
if (saslContext == null) {
try {
//If the connection is secure already (i.e., TLS), then make the
//receive buffers sizes match.
if(clientConn.isSecure()) {
HashMap<String, String>secProps =
new HashMap<String,String>(saslProps);
int maxBuf = clientConn.getAppBufferSize();
secProps.put(Sasl.MAX_BUFFER, Integer.toString(maxBuf));
saslContext = SASLContext.createSASLContext(secProps, serverFQDN,
SASL_MECHANISM_GSSAPI, identityMapper);
} else {
saslContext = SASLContext.createSASLContext(saslProps, serverFQDN,
SASL_MECHANISM_GSSAPI, identityMapper);
}
} 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,
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;
}
}