Completed Type 2 artifact support.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 24 Mar 2005 03:53:37 +0000 (03:53 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 24 Mar 2005 03:53:37 +0000 (03:53 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1333 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/artifact/provider/BaseArtifactMapper.java
src/edu/internet2/middleware/shibboleth/artifact/provider/MemoryArtifactMapper.java
src/edu/internet2/middleware/shibboleth/common/ServiceProviderMapper.java
src/schemas/shibboleth-idpconfig-1.0.xsd

index 0c30820..08c7520 100644 (file)
@@ -26,6 +26,7 @@
 package edu.internet2.middleware.shibboleth.artifact.provider;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
@@ -35,6 +36,7 @@ import org.opensaml.artifact.Artifact;
 import org.opensaml.artifact.SAMLArtifactType0001;
 import org.opensaml.artifact.SAMLArtifactType0002;
 import org.opensaml.artifact.Util;
+import org.w3c.dom.Element;
 
 import edu.internet2.middleware.shibboleth.artifact.ArtifactMapper;
 import edu.internet2.middleware.shibboleth.artifact.ArtifactMapping;
@@ -50,9 +52,7 @@ import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationExcepti
 public abstract class BaseArtifactMapper implements ArtifactMapper {
 
        private static Logger log = Logger.getLogger(BaseArtifactMapper.class.getName());
-       // TODO init from config
        private URI type2SourceLocation;
-
        private MessageDigest md;
 
        public BaseArtifactMapper() throws ShibbolethConfigurationException {
@@ -64,7 +64,26 @@ public abstract class BaseArtifactMapper implements ArtifactMapper {
                        throw new ShibbolethConfigurationException(
                                        "The IdP Artifact Mapper requires JCE support for the SHA-1 digest algorithm.");
                }
+       }
+
+       public BaseArtifactMapper(Element config) throws ShibbolethConfigurationException {
+
+               this();
 
+               String attribute = config.getAttribute("sourceLocation");
+               if (attribute != null && !attribute.equals("")) {
+                       try {
+                               type2SourceLocation = new URI(attribute);
+                               log.debug("Artifact Mapper configured to issue Type 1 artifacts & Type 2 artifacts with a "
+                                               + "sourceLocation of (" + type2SourceLocation + ").");
+                       } catch (URISyntaxException e) {
+                               log.error("(sourceLocation) attribute for <ArtifactMapper/> is not a valid URI: " + e);
+                               throw new ShibbolethConfigurationException("Unable to initialize Artifact mapper");
+                       }
+               } else {
+                       log.debug("No (sourceLocaton) attribute found for element <ArtifactMapper/>.  The Artifact Mapper will "
+                                       + "only be able to send Type 1 artifacts.");
+               }
        }
 
        public Artifact generateArtifact(SAMLAssertion assertion, RelyingParty relyingParty) {
index ce96847..dbea5f3 100644 (file)
@@ -51,7 +51,7 @@ public class MemoryArtifactMapper extends BaseArtifactMapper implements Artifact
        
        public MemoryArtifactMapper(Element config) throws ShibbolethConfigurationException {
 
-               super();
+               super(config);
        }
 
        // TODO need to cleanup stale artifacts
index 22e3632..7a83c21 100644 (file)
@@ -227,6 +227,7 @@ public class ServiceProviderMapper {
                private boolean forceAttributeNoPush = false;
                private boolean defaultToPOST = true;
                private boolean wantsAssertionsSigned = false;
+               private int preferredArtifactType = 1;
 
                public RelyingPartyImpl(Element partyConfig, IdPConfig globalConfig, Credentials credentials,
                                NameMapper nameMapper) throws ServiceProviderMapperException {
@@ -314,6 +315,18 @@ public class ServiceProviderMapper {
                                log.debug("No attribute push forcing is set to (" + forceAttributeNoPush + ").");
                        }
 
+                       attribute = ((Element) partyConfig).getAttribute("preferredArtifactType");
+                       if (attribute != null && !attribute.equals("")) {
+                               log.debug("Overriding AAUrl for Relying Pary (" + name + ") with (" + attribute + ").");
+                               try {
+                                       preferredArtifactType = Integer.parseInt(attribute);
+                               } catch (NumberFormatException e) {
+                                       log.error("(preferredArtifactType) attribute to is not a valid integer.");
+                                       throw new ServiceProviderMapperException("Configuration is invalid.");
+                               }
+                               log.debug("Preferred artifact type: (" + preferredArtifactType + ").");
+                       }
+
                        // Load and verify the name format that the HS should use in
                        // assertions for this RelyingParty
                        NodeList hsNameFormats = ((Element) partyConfig).getElementsByTagNameNS(IdPConfig.configNameSpace,
@@ -442,8 +455,7 @@ public class ServiceProviderMapper {
 
                public int getPreferredArtifactType() {
 
-                       // TODO make configurable
-                       return 1;
+                       return preferredArtifactType;
                }
 
                /**
index 82e8c47..28895a0 100644 (file)
@@ -63,6 +63,7 @@
                                                        <xs:attribute name="forceAttributeNoPush" type="xs:boolean" use="optional"/>
                                                        <xs:attribute name="defaultToPOSTProfile" type="xs:boolean" use="optional"/>
                                                        <xs:attribute name="defaultAuthMethod" type="xs:string" use="optional"/>
+                                                       <xs:attribute name="preferredArtifactType" type="xs:integer" use="optional"/>
                                                </xs:complexType>
                                        </xs:element>
                                </xs:sequence>