Commit 1b49d730 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Consider all CN values in subjectDN. JM-1384

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10496 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9b3a084b
...@@ -174,12 +174,11 @@ public class CertificateManager { ...@@ -174,12 +174,11 @@ public class CertificateManager {
if (names.isEmpty()) { if (names.isEmpty()) {
String name = x509Certificate.getSubjectDN().getName(); String name = x509Certificate.getSubjectDN().getName();
Matcher matcher = cnPattern.matcher(name); Matcher matcher = cnPattern.matcher(name);
if (matcher.find()) { // Create an array with the detected identities
name = matcher.group(2);
}
// Create an array with the unique identity
names = new ArrayList<String>(); names = new ArrayList<String>();
names.add(name); while (matcher.find()) {
names.add(matcher.group(2));
}
} }
return names; return names;
} }
......
package org.jivesoftware.util;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Basic tests for code used by CertificateManager.
*
* @author Gaston Dombiak
*/
public class CertificateTest extends TestCase {
/**
* Verify that all CN elements are found.
*/
public void testCN() {
Pattern cnPattern = Pattern.compile("(?i)(cn=)([^,]*)");
String text = "EMAILADDRESS=XXXXX@scifi.com, CN=scifi.com, CN=jabber.scifi.com, OU=Domain validated only, O=XX, L=Skx, C=SE";
List<String> found = new ArrayList<String>();
Matcher matcher = cnPattern.matcher(text);
while (matcher.find()) {
found.add(matcher.group(2));
}
assertEquals("Incorrect number of CNs were found", 2, found.size());
assertEquals("Incorrect CN found", "scifi.com" , found.get(0));
assertEquals("Incorrect CN found", "jabber.scifi.com" , found.get(1));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment