You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/01/10 17:38:18 UTC
[2/5] qpid-broker-j git commit: QPID-8038: [Broker-J] [AMQP 0-x] Add
connection protocol tests related to SASL.
QPID-8038: [Broker-J] [AMQP 0-x] Add connection protocol tests related to SASL.
(cherry picked from commit cd13129adff47932b2e26e4a33a9bcba27c661ce)
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/8f680024
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/8f680024
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/8f680024
Branch: refs/heads/7.0.x
Commit: 8f6800248d8949bf353ac4787492f4404db519ca
Parents: c39cf07
Author: Keith Wall <kw...@apache.org>
Authored: Sat Jan 6 22:34:15 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Wed Jan 10 17:30:11 2018 +0000
----------------------------------------------------------------------
.../v1_0/transport/security/sasl/SaslTest.java | 19 +--------
.../apache/qpid/tests/protocol/SaslUtils.java | 41 ++++++++++++++++++++
2 files changed, 43 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/8f680024/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
index ee657f3..0eac112 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
@@ -20,6 +20,7 @@
package org.apache.qpid.tests.protocol.v1_0.transport.security.sasl;
+import static org.apache.qpid.tests.protocol.SaslUtils.generateCramMD5ClientResponse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -32,10 +33,6 @@ import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.bind.DatatypeConverter;
-
import org.junit.Before;
import org.junit.Test;
@@ -169,7 +166,7 @@ public class SaslTest extends BrokerAdminUsingTestBase
assertThat(saslChallenge.getChallenge(), is(notNullValue()));
byte[] response = generateCramMD5ClientResponse(_username, _password,
- saslChallenge.getChallenge().getArray());
+ saslChallenge.getChallenge().getArray());
final SaslOutcome saslOutcome = interaction.saslResponseResponse(new Binary(response))
.saslResponse()
@@ -324,16 +321,4 @@ public class SaslTest extends BrokerAdminUsingTestBase
transport.assertNoMoreResponsesAndChannelClosed();
}
}
-
- private static byte[] generateCramMD5ClientResponse(String userName, String userPassword, byte[] challengeBytes)
- throws Exception
- {
- String macAlgorithm = "HmacMD5";
- Mac mac = Mac.getInstance(macAlgorithm);
- mac.init(new SecretKeySpec(userPassword.getBytes(StandardCharsets.UTF_8), macAlgorithm));
- final byte[] messageAuthenticationCode = mac.doFinal(challengeBytes);
- String responseAsString = userName + " " + DatatypeConverter.printHexBinary(messageAuthenticationCode)
- .toLowerCase();
- return responseAsString.getBytes();
- }
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/8f680024/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
new file mode 100644
index 0000000..5833599
--- /dev/null
+++ b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.qpid.tests.protocol;
+
+import java.nio.charset.StandardCharsets;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.DatatypeConverter;
+
+public class SaslUtils
+{
+ public static byte[] generateCramMD5ClientResponse(String userName, String userPassword, byte[] challengeBytes)
+ throws Exception
+ {
+ String macAlgorithm = "HmacMD5";
+ Mac mac = Mac.getInstance(macAlgorithm);
+ mac.init(new SecretKeySpec(userPassword.getBytes(StandardCharsets.UTF_8), macAlgorithm));
+ final byte[] messageAuthenticationCode = mac.doFinal(challengeBytes);
+ String responseAsString = userName + " " + DatatypeConverter.printHexBinary(messageAuthenticationCode)
+ .toLowerCase();
+ return responseAsString.getBytes();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org