summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/test
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2013-07-30 23:20:30 +0000
committerRobert Godfrey <rgodfrey@apache.org>2013-07-30 23:20:30 +0000
commitc00b603941decee250bcf5bd4abcafd9f1b18ffe (patch)
tree162ae22611038fd8191c7cdcc19fe01ee2db6282 /qpid/java/common/src/test
parent4fe28488726a1c336392aa70696026d71a5064fc (diff)
downloadqpid-python-c00b603941decee250bcf5bd4abcafd9f1b18ffe.tar.gz
QPID-4875 : The parsing logic for certificate subjects does not work properly in all cases
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1508680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common/src/test')
-rw-r--r--qpid/java/common/src/test/java/org/apache/qpid/transport/network/security/ssl/SSLUtilTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/security/ssl/SSLUtilTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/security/ssl/SSLUtilTest.java
new file mode 100644
index 0000000000..2d17f7a3c7
--- /dev/null
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/security/ssl/SSLUtilTest.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.transport.network.security.ssl;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class SSLUtilTest extends QpidTestCase
+{
+ public void testGetIdFromSubjectDN()
+ {
+ // "normal" dn
+ assertEquals("user@somewhere.example.org",SSLUtil.getIdFromSubjectDN("cn=user,dc=somewhere,dc=example,dc=org"));
+ // quoting of values, case of types, spacing all ignored
+ assertEquals("user2@somewhere.example.org",SSLUtil.getIdFromSubjectDN("DC=somewhere, dc=example,cn=\"user2\",dc=org"));
+ // only first cn is used
+ assertEquals("user@somewhere.example.org",SSLUtil.getIdFromSubjectDN("DC=somewhere, dc=example,cn=\"user\",dc=org, cn=user2"));
+ // no cn, no Id
+ assertEquals("",SSLUtil.getIdFromSubjectDN("DC=somewhere, dc=example,dc=org"));
+ // cn in value is ignored
+ assertEquals("",SSLUtil.getIdFromSubjectDN("C=CZ,O=Scholz,OU=\"JAKUB CN=USER1\""));
+ // cn with no dc gives just user
+ assertEquals("someone",SSLUtil.getIdFromSubjectDN("ou=someou, CN=\"someone\""));
+ // null results in empty string
+ assertEquals("",SSLUtil.getIdFromSubjectDN(null));
+ // invalid name results in empty string
+ assertEquals("",SSLUtil.getIdFromSubjectDN("ou=someou, ="));
+ // component containing whitespace
+ assertEquals("me@example.com",SSLUtil.getIdFromSubjectDN("CN=me,DC=example, DC=com, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB"));
+ // empty CN
+ assertEquals("",SSLUtil.getIdFromSubjectDN("CN=,DC=somewhere, dc=example,dc=org"));
+
+
+ }
+}