[java-identity-provider COMMIT] in /trunk/idp-profile-spring/src: main/java/net/shibboleth/idp/profile/spring/relying...

noreply at shibboleth.net noreply at shibboleth.net
Thu Apr 17 13:31:31 EDT 2014


Author: rdw
Date: Thu Apr 17 13:31:31 2014
New Revision: 5742

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5742&view=rev
Log:
IDP-389 Add inline public key and certificate file as other ways of providing the key to the SignatureValidationParser

Added:
    trunk/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/signingNone.xml   (with props)
    trunk/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/switch.pem
Modified:
    trunk/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParser.java
    trunk/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParserTest.java
    trunk/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/switch-metadata-file.xml
    trunk/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/switch-metadata-inline.xml

Modified: trunk/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParser.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParser.java?rev=5742&r1=5741&r2=5742&view=diff
==============================================================================
--- trunk/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParser.java (original)
+++ trunk/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/filter/SignatureValidationParser.java Thu Apr 17 13:31:31 2014
@@ -17,13 +17,29 @@
 
 package net.shibboleth.idp.profile.spring.relyingparty.metadata.filter;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.profile.spring.relyingparty.metadata.MetadataNamespaceHandler;
+import net.shibboleth.idp.profile.spring.relyingparty.security.credential.BasicInlineCredentialFactoryBean;
+import net.shibboleth.idp.profile.spring.relyingparty.security.credential.X509FilesystemCredentialFactoryBean;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import net.shibboleth.utilities.java.support.xml.ElementSupport;
 
 import org.opensaml.saml.metadata.resolver.filter.impl.SignatureValidationFilter;
+import org.opensaml.security.credential.impl.StaticCredentialResolver;
+import org.opensaml.xmlsec.keyinfo.impl.BasicProviderKeyInfoCredentialResolver;
+import org.opensaml.xmlsec.keyinfo.impl.KeyInfoProvider;
+import org.opensaml.xmlsec.keyinfo.impl.provider.DSAKeyValueProvider;
+import org.opensaml.xmlsec.keyinfo.impl.provider.InlineX509DataProvider;
+import org.opensaml.xmlsec.keyinfo.impl.provider.RSAKeyValueProvider;
+import org.opensaml.xmlsec.signature.support.impl.ExplicitKeySignatureTrustEngine;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
 import org.w3c.dom.Element;
 
@@ -35,6 +51,9 @@
     /** Schema type name. */
     public static final QName TYPE_NAME = new QName(MetadataNamespaceHandler.NAMESPACE, "SignatureValidation");
 
+    /** Element for embedded public keys. */
+    public static final QName PUBLIC_KEY = new QName(MetadataNamespaceHandler.NAMESPACE, "PublicKey");
+
     /** {@inheritDoc} */
     @Override protected Class getBeanClass(Element element) {
         return SignatureValidationFilter.class;
@@ -42,11 +61,98 @@
 
     /** {@inheritDoc} */
     @Override protected void doParse(Element element, BeanDefinitionBuilder builder) {
-        builder.addConstructorArgReference(StringSupport.trimOrNull(element.getAttributeNS(null, "trustEngineRef")));
+        final boolean hasEngineRef = element.hasAttributeNS(null, "trustEngineRef");
+        final boolean hasCertFile = element.hasAttributeNS(null, "certificateFile");
+        final List<Element> publicKeys = ElementSupport.getChildElements(element, PUBLIC_KEY);
+
+        if (hasEngineRef) {
+            if (hasCertFile) {
+                throw new BeanCreationException("trustEngineRef and certificateFile are mutually exlusive");
+            }
+            if (null != publicKeys && !publicKeys.isEmpty()) {
+                throw new BeanCreationException("trustEngineRef and embedded public keys are mutually exlusive");
+            }
+            builder.addConstructorArgReference(StringSupport.trimOrNull(element.getAttributeNS(null, 
+                    "trustEngineRef")));
+        } else if (hasCertFile) {

[... 160 lines stripped ...]


More information about the commits mailing list