[java-xmltooling COMMIT] in /branches/REL_1/src/main/java/org/opensaml/xml: encryption/SimpleKeyInfoReferenceEncrypte...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Jan 17 00:27:33 EST 2013
Author: scantor
Date: Thu Jan 17 00:27:33 2013
New Revision: 774
URL: http://svn.shibboleth.net/view/java-xmltooling?rev=774&view=rev
Log:
JXT-92: New KeyInfo interfaces, validators, KeyInfo helper routines.
Added:
branches/REL_1/src/main/java/org/opensaml/xml/encryption/SimpleKeyInfoReferenceEncryptedKeyResolver.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/DEREncodedKeyValue.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/ECKeyValue.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/ECPointType.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/KeyInfoReference.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/NamedCurve.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/PublicKey.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/X509Digest.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/DEREncodedKeyValueSchemaValidator.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/ECKeyValueSchemaValidator.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/ECPointTypeSchemaValidator.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/KeyInfoReferenceSchemaValidator.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/NamedCurveSchemaValidator.java (with props)
branches/REL_1/src/main/java/org/opensaml/xml/signature/validator/X509DigestSchemaValidator.java (with props)
Modified:
branches/REL_1/src/main/java/org/opensaml/xml/security/keyinfo/KeyInfoHelper.java
Modified: branches/REL_1/src/main/java/org/opensaml/xml/security/keyinfo/KeyInfoHelper.java
URL: http://svn.shibboleth.net/view/java-xmltooling/branches/REL_1/src/main/java/org/opensaml/xml/security/keyinfo/KeyInfoHelper.java?rev=774&r1=773&r2=774&view=diff
==============================================================================
--- branches/REL_1/src/main/java/org/opensaml/xml/security/keyinfo/KeyInfoHelper.java (original)
+++ branches/REL_1/src/main/java/org/opensaml/xml/security/keyinfo/KeyInfoHelper.java Thu Jan 17 00:27:33 2013
@@ -20,6 +20,7 @@
import java.math.BigInteger;
import java.security.KeyException;
import java.security.KeyFactory;
+import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.cert.CRLException;
@@ -30,19 +31,24 @@
import java.security.cert.X509Certificate;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.DSAParameterSpec;
import java.security.spec.DSAPublicKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.X509EncodedKeySpec;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.opensaml.xml.Configuration;
+import org.opensaml.xml.XMLObject;
import org.opensaml.xml.XMLObjectBuilderFactory;
+import org.opensaml.xml.security.SecurityHelper;
import org.opensaml.xml.security.x509.X509Util;
+import org.opensaml.xml.signature.DEREncodedKeyValue;
import org.opensaml.xml.signature.DSAKeyValue;
import org.opensaml.xml.signature.Exponent;
import org.opensaml.xml.signature.G;
@@ -54,6 +60,7 @@
import org.opensaml.xml.signature.Q;
import org.opensaml.xml.signature.RSAKeyValue;
import org.opensaml.xml.signature.X509Data;
+import org.opensaml.xml.signature.X509Digest;
import org.opensaml.xml.signature.X509IssuerName;
import org.opensaml.xml.signature.X509IssuerSerial;
import org.opensaml.xml.signature.X509SKI;
@@ -421,7 +428,35 @@
return xmlSKI;
}
-
+
+ /**
+ * Build an {@link X509Digest} containing the digest of the specified certificate.
+ *
+ * @param javaCert the Java X509Certificate to digest
+ * @param algorithmURI digest algorithm URI
+ * @return a new X509Digest object
+ * @throws NoSuchAlgorithmException if the algorithm specified cannot be used
+ * @throws CertificateEncodingException if the certificate cannot be encoded
+ */
+ public static X509Digest buildX509Digest(X509Certificate javaCert, String algorithmURI)
+ throws NoSuchAlgorithmException, CertificateEncodingException {
+
+ String jceAlg = SecurityHelper.getAlgorithmIDFromURI(algorithmURI);
+ if (jceAlg == null) {
+ throw new NoSuchAlgorithmException("No JCE algorithm found for " + algorithmURI);
+ }
+ MessageDigest md = MessageDigest.getInstance(jceAlg);
+ byte[] hash = md.digest(javaCert.getEncoded());
+
+ X509Digest xmlDigest = (X509Digest) Configuration.getBuilderFactory()
[... 114 lines stripped ...]
More information about the commits
mailing list