Repository: qpid-jms Updated Branches: refs/heads/master f5f287ec0 -> 62e30c0fc
QPIDJMS-305 Remove the request object from the authenticator Remove the request object from the authenticator and let the provider just manage calls to success and failure since it drives the notification now. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/62e30c0f Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/62e30c0f Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/62e30c0f Branch: refs/heads/master Commit: 62e30c0fc254a2a832b81c3c9a8cf5332ddf9cf5 Parents: f5f287e Author: Timothy Bish <[email protected]> Authored: Fri Jul 21 11:21:33 2017 -0400 Committer: Timothy Bish <[email protected]> Committed: Fri Jul 21 11:21:33 2017 -0400 ---------------------------------------------------------------------- .../qpid/jms/provider/amqp/AmqpProvider.java | 6 +++--- .../jms/provider/amqp/AmqpSaslAuthenticator.java | 19 +++++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/62e30c0f/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java index 4a4178e..3bd7537 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java @@ -201,7 +201,7 @@ public class AmqpProvider implements Provider, TransportListener , AmqpResourceP sasl.setRemoteHostname(hostname); - authenticator = new AmqpSaslAuthenticator(connectionRequest, sasl, (remoteMechanisms) -> findSaslMechanism(remoteMechanisms)); + authenticator = new AmqpSaslAuthenticator(sasl, (remoteMechanisms) -> findSaslMechanism(remoteMechanisms)); pumpToProtonTransport(); } else { @@ -958,10 +958,10 @@ public class AmqpProvider implements Provider, TransportListener , AmqpResourceP // the state of authentication was. org.apache.qpid.proton.engine.Transport t = protonConnection.getTransport(); t.close_head(); - authenticator.signalCompletion(); + connectionRequest.onFailure(authenticator.getFailureCause()); } else { // Signal completion and release the authenticator we won't use it again. - authenticator.signalCompletion(); + connectionRequest.onSuccess(); authenticator = null; } } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/62e30c0f/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticator.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticator.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticator.java index 3b986a8..456f9ef 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticator.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticator.java @@ -20,7 +20,6 @@ import java.util.function.Function; import javax.jms.JMSSecurityException; -import org.apache.qpid.jms.provider.AsyncResult; import org.apache.qpid.jms.sasl.Mechanism; import org.apache.qpid.proton.engine.Sasl; @@ -30,7 +29,6 @@ import org.apache.qpid.proton.engine.Sasl; public class AmqpSaslAuthenticator { private final Sasl sasl; - private final AsyncResult authenticationRequest; private final Function<String[], Mechanism> mechanismFinder; private Mechanism mechanism; @@ -40,16 +38,13 @@ public class AmqpSaslAuthenticator { /** * Create the authenticator and initialize it. * - * @param request - * The initial request that is awaiting the result of the authentication process. * @param sasl * The Proton SASL entry point this class will use to manage the authentication. * @param mechanismFinder * An object that is used to locate the most correct SASL Mechanism to perform the authentication. */ - public AmqpSaslAuthenticator(AsyncResult request, Sasl sasl, Function<String[], Mechanism> mechanismFinder) { + public AmqpSaslAuthenticator(Sasl sasl, Function<String[], Mechanism> mechanismFinder) { this.sasl = sasl; - this.authenticationRequest = request; this.mechanismFinder = mechanismFinder; } @@ -86,6 +81,10 @@ public class AmqpSaslAuthenticator { return complete; } + public JMSSecurityException getFailureCause() { + return failureCause; + } + public boolean wasSuccessful() throws IllegalStateException { if (complete) { return failureCause == null; @@ -94,14 +93,6 @@ public class AmqpSaslAuthenticator { } } - public void signalCompletion() { - if (failureCause != null) { - authenticationRequest.onFailure(failureCause); - } else { - authenticationRequest.onSuccess(); - } - } - private void handleSaslInit() { try { String[] remoteMechanisms = sasl.getRemoteMechanisms(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
