Began implementing support for sending type 2 artifacts.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 23 Mar 2005 21:54:39 +0000 (21:54 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 23 Mar 2005 21:54:39 +0000 (21:54 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1332 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/artifact/provider/BaseArtifactMapper.java
src/edu/internet2/middleware/shibboleth/common/RelyingParty.java
src/edu/internet2/middleware/shibboleth/common/ServiceProviderMapper.java

index 8d1b83b..0c30820 100644 (file)
@@ -25,6 +25,7 @@
 
 package edu.internet2.middleware.shibboleth.artifact.provider;
 
+import java.net.URI;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
@@ -32,6 +33,7 @@ import org.apache.log4j.Logger;
 import org.opensaml.SAMLAssertion;
 import org.opensaml.artifact.Artifact;
 import org.opensaml.artifact.SAMLArtifactType0001;
+import org.opensaml.artifact.SAMLArtifactType0002;
 import org.opensaml.artifact.Util;
 
 import edu.internet2.middleware.shibboleth.artifact.ArtifactMapper;
@@ -48,6 +50,8 @@ 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;
 
@@ -65,13 +69,29 @@ public abstract class BaseArtifactMapper implements ArtifactMapper {
 
        public Artifact generateArtifact(SAMLAssertion assertion, RelyingParty relyingParty) {
 
-               // TODO should the artifact type be configurable?
-
                // Generate the artifact
                Artifact artifact;
-               synchronized (md) {
-                       artifact = new SAMLArtifactType0001(Util.generateSourceId(md, relyingParty.getIdentityProvider()
-                                       .getProviderId()));
+
+               // If the relying party prefers type 2 and we have the proper data, use it
+               if (relyingParty.getPreferredArtifactType() == 2 && type2SourceLocation != null) {
+                       synchronized (md) {
+                               artifact = new SAMLArtifactType0002(Util.generateSourceId(md, relyingParty.getIdentityProvider()
+                                               .getProviderId()), type2SourceLocation);
+                       }
+                       // Else, use type 1
+               } else {
+                       if (relyingParty.getPreferredArtifactType() == 2) {
+                               log.warn("The relying party prefers Type 2 artifacts, but the mapper does not "
+                                               + "have a sourceLocation configured.  Using Type 1.");
+                       } else if (relyingParty.getPreferredArtifactType() != 1) {
+                               log.warn("The relying party prefers Type " + relyingParty.getPreferredArtifactType()
+                                               + " artifacts, but the mapper does not " + "support this type.  Using Type 1.");
+                       }
+
+                       synchronized (md) {
+                               artifact = new SAMLArtifactType0001(Util.generateSourceId(md, relyingParty.getIdentityProvider()
+                                               .getProviderId()));
+                       }
                }
 
                // Delegate adding to extenders
index 3b77b7e..59b51e6 100644 (file)
@@ -109,4 +109,9 @@ public interface RelyingParty extends ServiceProvider {
         * addition to profile-specific signing).
         */
        public boolean wantsAssertionsSigned();
+
+       /**
+        * Returns the type of SAML Artifact that this appropriate for use with this Relying Party.
+        */
+       public int getPreferredArtifactType();
 }
index ef59374..22e3632 100644 (file)
@@ -440,6 +440,12 @@ public class ServiceProviderMapper {
                        return wantsAssertionsSigned;
                }
 
+               public int getPreferredArtifactType() {
+
+                       // TODO make configurable
+                       return 1;
+               }
+
                /**
                 * Default identity provider implementation.
                 * 
@@ -550,6 +556,11 @@ public class ServiceProviderMapper {
 
                        return wrapped.wantsAssertionsSigned();
                }
+
+               public int getPreferredArtifactType() {
+
+                       return wrapped.getPreferredArtifactType();
+               }
        }
 
        /**
@@ -627,6 +638,11 @@ public class ServiceProviderMapper {
 
                        return wrapped.wantsAssertionsSigned();
                }
+
+               public int getPreferredArtifactType() {
+
+                       return wrapped.getPreferredArtifactType();
+               }
        }
 
        /**