[java-opensaml COMMIT] in /trunk/opensaml-security-api/src: main/java/org/opensaml/security/x509/X509Support.java tes...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Aug 6 19:09:06 EDT 2014
Author: putmanb
Date: Wed Aug 6 19:09:06 2014
New Revision: 3989
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3989&view=rev
Log:
Port forward missing X509Support unit tests from JXT-112.
Clean up unused imports.
Modified:
trunk/opensaml-security-api/src/main/java/org/opensaml/security/x509/X509Support.java
trunk/opensaml-security-api/src/test/java/org/opensaml/security/x509/X509SupportTest.java
Modified: trunk/opensaml-security-api/src/main/java/org/opensaml/security/x509/X509Support.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-security-api/src/main/java/org/opensaml/security/x509/X509Support.java?rev=3989&r1=3988&r2=3989&view=diff
==============================================================================
--- trunk/opensaml-security-api/src/main/java/org/opensaml/security/x509/X509Support.java (original)
+++ trunk/opensaml-security-api/src/main/java/org/opensaml/security/x509/X509Support.java Wed Aug 6 19:09:06 2014
@@ -46,11 +46,9 @@
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.bouncycastle.asn1.ASN1Primitive;
-import org.bouncycastle.asn1.DERIA5String;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
-import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
import org.bouncycastle.x509.extension.X509ExtensionUtil;
import org.cryptacular.util.CertUtil;
import org.cryptacular.util.CodecUtil;
Modified: trunk/opensaml-security-api/src/test/java/org/opensaml/security/x509/X509SupportTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-security-api/src/test/java/org/opensaml/security/x509/X509SupportTest.java?rev=3989&r1=3988&r2=3989&view=diff
==============================================================================
--- trunk/opensaml-security-api/src/test/java/org/opensaml/security/x509/X509SupportTest.java (original)
+++ trunk/opensaml-security-api/src/test/java/org/opensaml/security/x509/X509SupportTest.java Wed Aug 6 19:09:06 2014
@@ -18,7 +18,6 @@
package org.opensaml.security.x509;
import java.io.InputStream;
-import java.math.BigInteger;
import java.security.PrivateKey;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509CRL;
@@ -31,8 +30,8 @@
import javax.security.auth.x500.X500Principal;
-import net.shibboleth.utilities.java.support.codec.Base64Support;
-
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
import org.opensaml.security.SecurityException;
import org.opensaml.security.crypto.KeySupport;
import org.testng.Assert;
@@ -217,8 +216,6 @@
+ "7jPQj8U2kkWUEWXkOv5FsyiB2KdxYGbJSpGwGLRWZNDbuVUjnuzQ29EWWbNwHxTb"
+ "GMRjrI9Q4WynZ2IOcnG1hMjCU6L4uk4JfryIw4IBHGa8uUtskHqJ7TFJ/4taWyV/" + "UB0djqOPjMACQpMBhEVRSBU=";
- private String entityCertSKIBase64 = "OBGBOSNoqgroOhl9RniD0sMlRa4=";
-
private String caCertBase64 = "MIIDXTCCAkWgAwIBAgIBATANBgkqhkiG9w0BAQUFADAtMRIwEAYDVQQKEwlJbnRl"
+ "cm5ldDIxFzAVBgNVBAMTDmNhLmV4YW1wbGUub3JnMB4XDTA3MDQwOTA1NDcxMloX"
+ "DTE3MDQwNjA1NDcxMlowLTESMBAGA1UEChMJSW50ZXJuZXQyMRcwFQYDVQQDEw5j"
@@ -278,14 +275,6 @@
entityCert1AltNameURL = X509Support.decodeCertificate(entityCert1AltNameURLBase64);
entityCert1AltNameIP = X509Support.decodeCertificate(entityCert1AltNameIPBase64);
- X509Support.decodeCertificate(caCertBase64);
- X509Support.decodeCRL(caCRLBase64);
-
- new X500Principal("cn=foobar.example.org, O=Internet2");
- new X500Principal("cn=ca.example.org, O=Internet2");
- new BigInteger("49");
- Base64Support.decode(entityCertSKIBase64);
-
altNameDNS = "asimov.example.org";
altNameURN = "urn:foo:example.org:idp";
altNameURL = "http://heinlein.example.org";
@@ -294,6 +283,69 @@
altNameTypeIP = X509Support.IP_ADDRESS_ALT_NAME;
altNameTypeURI = X509Support.URI_ALT_NAME;
altNameTypeDNS = X509Support.DNS_ALT_NAME;
+ }
+
+ /**
+ * Test common name (CN) extraction from X500Principal.
+ */
+ @Test
+ public void testGetCommonNames() {
+ List<String> commonNames;
+
+ // 1 component
+ commonNames = X509Support.getCommonNames(new X500Principal("cn=foo.example.org"));
+ Assert.assertNotNull(commonNames);
+ Assert.assertEquals(commonNames.size(), 1);
+ Assert.assertTrue(commonNames.contains("foo.example.org"));
+
+ // 2 components, 1 cn
+ commonNames = X509Support.getCommonNames(new X500Principal("cn=foo.example.org, o=MyOrg"));
+ Assert.assertNotNull(commonNames);
+ Assert.assertEquals(commonNames.size(), 1);
+ Assert.assertTrue(commonNames.contains("foo.example.org"));
+
+ // 2 components each with cn
+ commonNames = X509Support.getCommonNames(new X500Principal("cn=foo.example.org, cn=MyOrg"));
+ Assert.assertNotNull(commonNames);
+ Assert.assertEquals(commonNames.size(), 2);
[... 42 lines stripped ...]
More information about the commits
mailing list