AuthenticationInfo authInfo = new AuthenticationInfo();
JmxClientConnection jmxClientConnection = new JmxClientConnection(
jmxConnectionHandler, authInfo);
BindOperationBasis bindOp = new BindOperationBasis(jmxClientConnection,
jmxClientConnection.nextOperationID(),
jmxClientConnection.nextMessageID(), requestControls,
jmxConnectionHandler.getRMIConnector().getProtocolVersion(),
ByteString.valueOf(authcID), bindPW);
bindOp.run();
if (bindOp.getResultCode() == ResultCode.SUCCESS)
{
if (debugEnabled())
{
TRACER.debugVerbose("User is authenticated");
}
authInfo = bindOp.getAuthenticationInfo();
jmxClientConnection.setAuthenticationInfo(authInfo);
// Check JMX_READ privilege.
if (! jmxClientConnection.hasPrivilege(Privilege.JMX_READ, null))
{
Message message = ERR_JMX_INSUFFICIENT_PRIVILEGES.get();
jmxClientConnection.disconnect(DisconnectReason.CONNECTION_REJECTED,
false, message);
throw new SecurityException(message.toString());
}
return jmxClientConnection;
}
else
{
//
// Set the initcause.
LDAPException ldapEx = new LDAPException(
LDAPResultCode.INVALID_CREDENTIALS,
CoreMessages.INFO_RESULT_INVALID_CREDENTIALS.get());
SecurityException se = new SecurityException("return code: "
+ bindOp.getResultCode());
se.initCause(ldapEx);
throw se;
}
}