Updated artifact mapper interface to match new relying party interfaces.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 12 Sep 2006 15:12:09 +0000 (15:12 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 12 Sep 2006 15:12:09 +0000 (15:12 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2020 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/artifact/ArtifactMapper.java
src/edu/internet2/middleware/shibboleth/artifact/provider/BaseArtifactMapper.java
src/edu/internet2/middleware/shibboleth/artifact/provider/MemoryArtifactMapper.java

index f39ebf6..5c88182 100644 (file)
@@ -19,7 +19,7 @@ package edu.internet2.middleware.shibboleth.artifact;
 import org.opensaml.SAMLAssertion;
 import org.opensaml.artifact.Artifact;
 
-import edu.internet2.middleware.shibboleth.common.RelyingParty;
+import edu.internet2.middleware.shibboleth.common.ServiceProvider;
 
 /**
  * Translates back and forth between SAML assertions and mapping strings (artifacts) needed for the SAML artifact
@@ -34,11 +34,11 @@ public interface ArtifactMapper {
         * 
         * @param assertion
         *            the SAML assertion
-        * @param relyingParty
-        *            the relying party on behalf of which the artifact is being created
+        * @param serviceProvider
+        *            the service provider on behalf of which the artifact is being created
         * @return the artifact
         */
-       public Artifact generateArtifact(SAMLAssertion assertion, RelyingParty relyingParty);
+       public Artifact generateArtifact(SAMLAssertion assertion, ServiceProvider serviceProvider);
 
        /**
         * Recover an assertion that was previosly generated for a given artifact.
index 1d9badc..724d3b5 100644 (file)
@@ -31,7 +31,7 @@ import org.w3c.dom.Element;
 
 import edu.internet2.middleware.shibboleth.artifact.ArtifactMapper;
 import edu.internet2.middleware.shibboleth.artifact.ArtifactMapping;
-import edu.internet2.middleware.shibboleth.common.RelyingParty;
+import edu.internet2.middleware.shibboleth.common.ServiceProvider;
 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
 
 /**
@@ -77,32 +77,32 @@ public abstract class BaseArtifactMapper implements ArtifactMapper {
                }
        }
 
-       public Artifact generateArtifact(SAMLAssertion assertion, RelyingParty relyingParty) {
+       public Artifact generateArtifact(SAMLAssertion assertion, ServiceProvider serviceProvider) {
 
                // Generate the artifact
                Artifact artifact;
 
                // If the relying party prefers type 2 and we have the proper data, use it
-               if (relyingParty.getPreferredArtifactType() == 2 && type2SourceLocation != null) {
+               if (serviceProvider.getPreferredArtifactType() == 2 && type2SourceLocation != null) {
                        artifact = new SAMLArtifactType0002(new org.opensaml.artifact.URI(type2SourceLocation.toString()));
                        // Else, use type 1
                } else {
-                       if (relyingParty.getPreferredArtifactType() == 2) {
+                       if (serviceProvider.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()
+                       } else if (serviceProvider.getPreferredArtifactType() != 1) {
+                               log.warn("The relying party prefers Type " + serviceProvider.getPreferredArtifactType()
                                                + " artifacts, but the mapper does not " + "support this type.  Using Type 1.");
                        }
 
                        synchronized (md) {
-                               artifact = new SAMLArtifactType0001(Util.generateSourceId(md, relyingParty.getIdentityProvider()
+                               artifact = new SAMLArtifactType0001(Util.generateSourceId(md, serviceProvider.getIdentityProvider()
                                                .getProviderId()));
                        }
                }
 
                // Delegate adding to extenders
-               addAssertionImpl(artifact, new ArtifactMapping(artifact, assertion, relyingParty));
+               addAssertionImpl(artifact, new ArtifactMapping(artifact, assertion, serviceProvider));
 
                // Return the encoded artifact
                return artifact;
index 7fae522..141aaf1 100644 (file)
@@ -41,7 +41,8 @@ public class MemoryArtifactMapper extends BaseArtifactMapper implements Artifact
 
        private MemoryArtifactCleaner cleaner = new MemoryArtifactCleaner();
        private static Logger log = Logger.getLogger(MemoryArtifactMapper.class.getName());
-       private static Map mappings = Collections.synchronizedMap(new HashMap());
+       private static Map<Artifact, ArtifactMapping> mappings = Collections
+                       .synchronizedMap(new HashMap<Artifact, ArtifactMapping>());
 
        public MemoryArtifactMapper() throws ShibbolethConfigurationException {
 
@@ -117,14 +118,14 @@ public class MemoryArtifactMapper extends BaseArtifactMapper implements Artifact
                                                return;
                                        }
                                        log.debug("Memory-based artifact mapper cleanup thread searching for stale entries.");
-                                       Set needsDeleting = new HashSet();
+                                       Set<Artifact> needsDeleting = new HashSet<Artifact>();
                                        synchronized (mappings) {
-                                               Iterator iterator = mappings.entrySet().iterator();
+                                               Iterator<Entry<Artifact, ArtifactMapping>> iterator = mappings.entrySet().iterator();
                                                while (iterator.hasNext()) {
-                                                       Entry entry = (Entry) iterator.next();
+                                                       Entry entry = iterator.next();
                                                        ArtifactMapping mapping = (ArtifactMapping) entry.getValue();
                                                        if (mapping.isExpired()) {
-                                                               needsDeleting.add(entry.getKey());
+                                                               needsDeleting.add((Artifact) entry.getKey());
                                                        }
                                                }
                                                // release the lock to be friendly