Synch up with minor artifact map changes
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 23 Aug 2007 14:01:13 +0000 (14:01 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 23 Aug 2007 14:01:13 +0000 (14:01 +0000)
Ensure content is flushed to stream in status handler

git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2345 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

resources/WEB-INF/web.xml
resources/conf/internal.xml
src/edu/internet2/middleware/shibboleth/idp/profile/StatusProfileHandler.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml1/ArtifactResolution.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/ArtifactResolution.java

index 20bcd60..4634de5 100644 (file)
@@ -36,7 +36,7 @@
     <servlet>
         <servlet-name>ProfileRequestDispatcher</servlet-name>
         <servlet-class>
-            edu.internet2.middleware.shibboleth.idp.profile.ShibbolethProfileRequestDispatcher
+            edu.internet2.middleware.shibboleth.common.profile.ProfileRequestDispatcherServlet
         </servlet-class>
     </servlet>
 
index bd9c8a5..0e8d12a 100644 (file)
         <constructor-arg ref="shibboleth.VelocityEngine" />
     </bean>
 
-    <bean id="shibboleth.TaskTimer" class="java.util.Timer" destroy-method="cancel">
-        <constructor-arg value="true" type="boolean" />
-    </bean>
-
     <bean id="shibboleth.ParserPool" class="org.opensaml.xml.parse.BasicParserPool">
         <property name="maxPoolSize" value="50" />
         <property name="createBuildersAtPoolLimit" value="true" />
         <property name="ignoreElementContentWhitespace" value="true" />
         <property name="namespaceAware" value="true" />
     </bean>
+    
+    <bean id="shibboleth.TaskTimer" class="java.util.Timer" destroy-method="cancel">
+        <constructor-arg value="true" type="boolean" />
+    </bean>
+    
+    <bean id="shibboleth.StorageService" class="org.opensaml.util.storage.MapBasedStorageService" />
+    
+    <bean id="shibboleth.StorageServiceSweeper" class="org.opensaml.util.storage.ExpiringObjectStorageServiceSweeper">
+        <constructor-arg ref="shibboleth.TaskTimer" />
+        <constructor-arg ref="shibboleth.StorageService" />
+        <constructor-arg value="600000" />
+    </bean>
+    
+    <bean id="shibboleth.ArtifactMap" class="org.opensaml.common.binding.artifact.BasicSAMLArtifactMap">
+        <constructor-arg ref="shibboleth.StorageService" />
+        <constructor-arg type="long" value="300000" />
+    </bean>
 
     <util:map id="shibboleth.MessageDecoders">
         <entry>
             </key>
             <bean id="shibboleth.SAML2HTTPArtifactEncoder"
                 class="org.opensaml.saml2.binding.decoding.HTTPArtifactEncoder">
+                <constructor-arg ref="shibboleth.ArtifactMap" />
+                <constructor-arg ref="shibboleth.VelocityEngine" />
+                <constructor-arg value="/templates/saml2-post-artifact-binding.vm" />
             </bean>
         </entry>
         <entry>
             </key>
             <bean id="shibboleth.SAML1HttpArtifactEncoder"
                 class="org.opensaml.saml1.binding.encoding.HTTPArtifactEncoder">
+                <constructor-arg ref="shibboleth.ArtifactMap" />
             </bean>
         </entry>
         <entry>
index d39ca9a..0762892 100644 (file)
@@ -44,6 +44,7 @@ public class StatusProfileHandler extends AbstractRequestURIMappedProfileHandler
         try {
             OutputStreamWriter writer = new OutputStreamWriter(out.getOutgoingStream());
             writer.write("ok");
+            writer.flush();
         } catch (IOException e) {
             log.error("Unable to write response", e);
         }
index 4b2c8db..62ad9db 100644 (file)
@@ -220,7 +220,7 @@ public class ArtifactResolution extends AbstractSAML1ProfileHandler {
             SAMLArtifactMapEntry artifactEntry;
 
             for (AbstractSAML1Artifact artifact : artifacts) {
-                artifactEntry = artifactMap.peek(artifact.getArtifactBytes());
+                artifactEntry = artifactMap.get(artifact.getArtifactBytes());
                 if (artifactEntry == null || artifactEntry.isExpired()) {
                     log.error("Unknown artifact.");
                 }
@@ -235,7 +235,7 @@ public class ArtifactResolution extends AbstractSAML1ProfileHandler {
                             + artifactEntry.getRelyingPartyId() + " but was resolve request came from "
                             + requestContext.getPeerEntityId());
                 }
-                artifactMap.get(artifact.getArtifactBytes());
+                artifactMap.remove(artifact.getArtifactBytes());
                 assertions.add((Assertion) artifactEntry.getSamlMessage());
             }
             requestContext.setReferencedAssertions(assertions);
index 1b1c378..4c708d7 100644 (file)
@@ -18,7 +18,6 @@ package edu.internet2.middleware.shibboleth.idp.profile.saml2;
 
 import org.apache.log4j.Logger;
 import org.joda.time.DateTime;
-import org.opensaml.Configuration;
 import org.opensaml.common.SAMLObject;
 import org.opensaml.common.SAMLObjectBuilder;
 import org.opensaml.common.binding.BasicEndpointSelector;
@@ -28,7 +27,6 @@ import org.opensaml.common.binding.decoding.SAMLMessageDecoder;
 import org.opensaml.common.xml.SAMLConstants;
 import org.opensaml.saml2.binding.SAML2ArtifactMessageContext;
 import org.opensaml.saml2.binding.artifact.AbstractSAML2Artifact;
-import org.opensaml.saml2.binding.artifact.SAML2ArtifactBuilderFactory;
 import org.opensaml.saml2.core.ArtifactResolve;
 import org.opensaml.saml2.core.ArtifactResponse;
 import org.opensaml.saml2.core.NameID;
@@ -44,7 +42,6 @@ import org.opensaml.ws.message.decoder.MessageDecodingException;
 import org.opensaml.ws.security.SecurityPolicyException;
 import org.opensaml.ws.transport.http.HTTPInTransport;
 import org.opensaml.ws.transport.http.HTTPOutTransport;
-import org.opensaml.xml.util.Base64;
 
 import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
 import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
@@ -95,7 +92,7 @@ public class ArtifactResolution extends AbstractSAML2ProfileHandler {
 
             checkSamlVersion(requestContext);
 
-            SAMLArtifactMapEntry artifactEntry = artifactMap.peek(requestContext.getArtifact().getArtifactBytes());
+            SAMLArtifactMapEntry artifactEntry = artifactMap.get(requestContext.getArtifact().getArtifactBytes());
             if (artifactEntry == null || artifactEntry.isExpired()) {
                 log.error("Unknown artifact.");
                 requestContext.setFailureStatus(buildStatus(StatusCode.SUCCESS_URI, StatusCode.REQUEST_DENIED_URI,
@@ -115,7 +112,7 @@ public class ArtifactResolution extends AbstractSAML2ProfileHandler {
                 requestContext.setFailureStatus(buildStatus(StatusCode.SUCCESS_URI, StatusCode.REQUEST_DENIED_URI,
                         "Artifact requester mismatch."));
             }
-            artifactMap.get(requestContext.getArtifact().getArtifactBytes());
+            artifactMap.remove(requestContext.getArtifact().getArtifactBytes());
             SAMLObject referencedMessage = artifactEntry.getSamlMessage();
             requestContext.setReferencedMessage(referencedMessage);