qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [1/2] qpid-jms git commit: QPIDJMS-360: ensure any empty challenges are passed through to the mechanism for processing
Date Wed, 24 Jan 2018 17:40:07 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 4932b00bf -> bb5abafc1


QPIDJMS-360: ensure any empty challenges are passed through to the mechanism for processing


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/ba054166
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/ba054166
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/ba054166

Branch: refs/heads/master
Commit: ba0541660c43df5616cf98f02258272a278720f4
Parents: 4932b00
Author: Robbie Gemmell <robbie@apache.org>
Authored: Wed Jan 24 17:17:46 2018 +0000
Committer: Robbie Gemmell <robbie@apache.org>
Committed: Wed Jan 24 17:17:46 2018 +0000

----------------------------------------------------------------------
 .../jms/provider/amqp/AmqpSaslAuthenticator.java    |  2 +-
 .../provider/amqp/AmqpSaslAuthenticatorTest.java    | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ba054166/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 25dc617..41dc259 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
@@ -88,7 +88,7 @@ public class AmqpSaslAuthenticator {
 
     public void handleSaslChallenge(Sasl sasl, Transport transport) {
         try {
-            if (sasl.pending() != 0) {
+            if (sasl.pending() >= 0) {
                 byte[] challenge = new byte[sasl.pending()];
                 sasl.recv(challenge, 0, challenge.length);
                 byte[] response = mechanism.getChallengeResponse(challenge);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ba054166/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticatorTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticatorTest.java
index b492a59..8fd212b 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticatorTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpSaslAuthenticatorTest.java
@@ -171,6 +171,22 @@ public class AmqpSaslAuthenticatorTest {
         assertTrue(authenticator.getFailureCause().getMessage().contains("SASL exchange not
completed"));
     }
 
+    @Test
+    public void testEmptyChallengeIsProcessedForResponse() throws Exception {
+        Mechanism mechanism = new TestSaslMechanism(INITIAL_RESPONSE,
+                                                    EMPTY_BYTES, EMPTY_BYTES);
+        AmqpSaslAuthenticator authenticator = new AmqpSaslAuthenticator(mechanismName ->
mechanism);
+
+        when(sasl.getState()).thenReturn(SaslState.PN_SASL_IDLE);
+        authenticator.handleSaslMechanisms(sasl, transport);
+        verifySaslMockReceived(sasl, INITIAL_RESPONSE);
+
+        when(sasl.getState()).thenReturn(SaslState.PN_SASL_STEP);
+        configureSaslMockToProduce(sasl, EMPTY_BYTES);
+        authenticator.handleSaslChallenge(sasl, transport);
+        verifySaslMockReceived(sasl, EMPTY_BYTES);
+    }
+
     private void verifySaslMockReceived(final Sasl sasl, final byte[] response) {
         verify(sasl).send(response, 0, response.length);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message