From 2c0691101081a89c7dd740d763be786206d957d5 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 18 May 2015 11:13:48 +0000
Subject: [PATCH] Get rid of calls to Throwable.initCause() + code cleanup
---
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiAuthenticator.java | 54 ++++++++++++++----------------------------------------
1 files changed, 14 insertions(+), 40 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiAuthenticator.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiAuthenticator.java
index 97c5ece..d915f42 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiAuthenticator.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiAuthenticator.java
@@ -67,10 +67,7 @@
*/
private boolean finalizedPhase;
- /**
- * The JMX Client connection to be used to perform the bind (auth)
- * call.
- */
+ /** The JMX Client connection to be used to perform the bind (auth) call. */
private JmxConnectionHandler jmxConnectionHandler;
/**
@@ -131,16 +128,11 @@
throw new SecurityException();
}
- if (logger.isTraceEnabled())
- {
- logger.trace("UserName = %s", authcID);
- }
-
- // Declare the client connection
- JmxClientConnection jmxClientConnection;
+ logger.trace("UserName = %s", authcID);
// Try to see if we have an Ldap Authentication
// Which should be the case in the current implementation
+ JmxClientConnection jmxClientConnection;
try
{
jmxClientConnection = bind(authcID, password);
@@ -152,13 +144,10 @@
throw se;
}
- // If we've gotten here, then the authentication was
- // successful. We'll take the connection so
- // invoke the post-connect plugins.
- PluginConfigManager pluginManager = DirectoryServer
- .getPluginConfigManager();
- PluginResult.PostConnect pluginResult = pluginManager
- .invokePostConnectPlugins(jmxClientConnection);
+ // If we've gotten here, then the authentication was successful.
+ // We'll take the connection so invoke the post-connect plugins.
+ PluginConfigManager pluginManager = DirectoryServer.getPluginConfigManager();
+ PluginResult.PostConnect pluginResult = pluginManager.invokePostConnectPlugins(jmxClientConnection);
if (!pluginResult.continueProcessing())
{
jmxClientConnection.disconnect(pluginResult.getDisconnectReason(),
@@ -182,8 +171,7 @@
s.getPrincipals().add(new OpendsJmxPrincipal(authcID));
// add the connection client object
- // this connection client is used at forwarder level to identify the
- // calling client
+ // this connection client is used at forwarder level to identify the calling client
s.getPrivateCredentials().add(new Credential(jmxClientConnection));
return s;
@@ -199,8 +187,6 @@
*/
private JmxClientConnection bind(String authcID, String password)
{
- ArrayList<Control> requestControls = new ArrayList<Control>();
-
try
{
DN.valueOf(authcID);
@@ -210,19 +196,11 @@
LDAPException ldapEx = new LDAPException(
LDAPResultCode.INVALID_CREDENTIALS,
CoreMessages.INFO_RESULT_INVALID_CREDENTIALS.get());
- SecurityException se = new SecurityException();
- se.initCause(ldapEx);
- throw se;
+ throw new SecurityException(ldapEx);
}
- ByteString bindPW;
- if (password == null)
- {
- bindPW = null;
- }
- else
- {
- bindPW = ByteString.valueOf(password);
- }
+
+ ArrayList<Control> requestControls = new ArrayList<>();
+ ByteString bindPW = password != null ? ByteString.valueOf(password) : null;
AuthenticationInfo authInfo = new AuthenticationInfo();
JmxClientConnection jmxClientConnection = new JmxClientConnection(
@@ -237,10 +215,7 @@
bindOp.run();
if (bindOp.getResultCode() == ResultCode.SUCCESS)
{
- if (logger.isTraceEnabled())
- {
- logger.trace("User is authenticated");
- }
+ logger.trace("User is authenticated");
authInfo = bindOp.getAuthenticationInfo();
jmxClientConnection.setAuthenticationInfo(authInfo);
@@ -263,8 +238,7 @@
LDAPException ldapEx = new LDAPException(
LDAPResultCode.INVALID_CREDENTIALS,
CoreMessages.INFO_RESULT_INVALID_CREDENTIALS.get());
- SecurityException se = new SecurityException("return code: "
- + bindOp.getResultCode());
+ SecurityException se = new SecurityException("return code: " + bindOp.getResultCode());
se.initCause(ldapEx);
throw se;
}
--
Gitblit v1.10.0