Have decoders extract basic SAML message information (message ID, claimed issuer...
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 6 Sep 2007 23:42:29 +0000 (23:42 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 6 Sep 2007 23:42:29 +0000 (23:42 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2372 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/profile/saml1/ArtifactResolution.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml1/AttributeQueryProfileHandler.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml1/ShibbolethSSODecoder.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml1/ShibbolethSSOProfileHandler.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/ArtifactResolution.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/AttributeQueryProfileHandler.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/SSOProfileHandler.java

index 62ad9db..277c464 100644 (file)
@@ -127,11 +127,14 @@ public class ArtifactResolution extends AbstractSAML1ProfileHandler {
         MetadataProvider metadataProvider = getMetadataProvider();
 
         ArtifactResolutionRequestContext requestContext = new ArtifactResolutionRequestContext();
+        requestContext.setMetadataProvider(metadataProvider);
+        
         requestContext.setInboundMessageTransport(inTransport);
-        requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
+        requestContext.setInboundSAMLProtocol(SAMLConstants.SAML11P_NS);
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+        
         requestContext.setOutboundMessageTransport(outTransport);
-        requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
-        requestContext.setMetadataProvider(metadataProvider);
+        requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML11P_NS);
 
         try {
             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
@@ -153,15 +156,8 @@ public class ArtifactResolution extends AbstractSAML1ProfileHandler {
         } finally {
             // Set as much information as can be retrieved from the decoded message
             try {
-                Request samlRequest = requestContext.getInboundSAMLMessage();
-                requestContext.setInboundSAMLMessageId(samlRequest.getID());
-                requestContext.setInboundSAMLMessageIssueInstant(samlRequest.getIssueInstant());
-
-                String relyingPartyId = requestContext.getPeerEntityId();
-                requestContext.setPeerEntityMetadata(metadataProvider.getEntityDescriptor(relyingPartyId));
-                requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
-                requestContext.setPeerEntityRoleMetadata(requestContext.getPeerEntityMetadata().getSPSSODescriptor(
-                        SAMLConstants.SAML11P_NS));
+                String relyingPartyId = requestContext.getInboundMessageIssuer();
+                
                 RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
                 requestContext.setRelyingPartyConfiguration(rpConfig);
 
index f0e9d2d..1a10f7a 100644 (file)
@@ -108,11 +108,14 @@ public class AttributeQueryProfileHandler extends AbstractSAML1ProfileHandler {
         MetadataProvider metadataProvider = getMetadataProvider();
 
         AttributeQueryContext requestContext = new AttributeQueryContext();
+        requestContext.setMetadataProvider(metadataProvider);
+        
         requestContext.setInboundMessageTransport(inTransport);
         requestContext.setInboundSAMLProtocol(SAMLConstants.SAML11P_NS);
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+        
         requestContext.setOutboundMessageTransport(outTransport);
         requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML11P_NS);
-        requestContext.setMetadataProvider(metadataProvider);
 
         try {
             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
@@ -138,14 +141,8 @@ public class AttributeQueryProfileHandler extends AbstractSAML1ProfileHandler {
             // Set as much information as can be retrieved from the decoded message
             try {
                 Request attributeRequest = requestContext.getInboundSAMLMessage();
-                requestContext.setInboundSAMLMessageId(attributeRequest.getID());
-                requestContext.setInboundSAMLMessageIssueInstant(attributeRequest.getIssueInstant());
-
-                String relyingPartyId = requestContext.getPeerEntityId();
-                requestContext.setPeerEntityMetadata(metadataProvider.getEntityDescriptor(relyingPartyId));
-                requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
-                requestContext.setPeerEntityRoleMetadata(requestContext.getPeerEntityMetadata().getSPSSODescriptor(
-                        SAMLConstants.SAML10P_NS));
+
+                String relyingPartyId = requestContext.getInboundMessageIssuer();
                 RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
                 requestContext.setRelyingPartyConfiguration(rpConfig);
                 requestContext.setPeerEntityEndpoint(selectEndpoint(requestContext));
index 11e928c..16144c2 100644 (file)
@@ -18,8 +18,8 @@ package edu.internet2.middleware.shibboleth.idp.profile.saml1;
 
 import org.apache.log4j.Logger;
 import org.opensaml.common.binding.decoding.SAMLMessageDecoder;
+import org.opensaml.saml1.binding.decoding.BaseSAML1MessageDecoder;
 import org.opensaml.ws.message.MessageContext;
-import org.opensaml.ws.message.decoder.BaseMessageDecoder;
 import org.opensaml.ws.message.decoder.MessageDecodingException;
 import org.opensaml.ws.transport.http.HTTPInTransport;
 import org.opensaml.xml.util.DatatypeHelper;
@@ -29,7 +29,7 @@ import edu.internet2.middleware.shibboleth.idp.profile.saml1.ShibbolethSSOProfil
 /**
  * Shibboleth 1.0 SSO authentication request message decoder.
  */
-public class ShibbolethSSODecoder extends BaseMessageDecoder implements SAMLMessageDecoder {
+public class ShibbolethSSODecoder extends BaseSAML1MessageDecoder implements SAMLMessageDecoder {
 
     /** Class logger. */
     private final Logger log = Logger.getLogger(ShibbolethSSODecoder.class);
@@ -83,5 +83,7 @@ public class ShibbolethSSODecoder extends BaseMessageDecoder implements SAMLMess
             long time = Long.parseLong(timeStr);
             requestContext.setTime(time);
         }
+        
+        populateMessageContext(requestContext);
     }
 }
\ No newline at end of file
index bb0f5aa..8c9160f 100644 (file)
@@ -179,8 +179,14 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
         HttpServletRequest httpRequest = ((HttpServletRequestAdapter) inTransport).getWrappedRequest();
 
         ShibbolethSSORequestContext requestContext = new ShibbolethSSORequestContext();
+        requestContext.setMetadataProvider(getMetadataProvider());
+        
         requestContext.setInboundMessageTransport(inTransport);
+        requestContext.setInboundSAMLProtocol(ShibbolethConstants.SHIB_SSO_PROFILE_URI);        
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+        
         requestContext.setOutboundMessageTransport(outTransport);
+        requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML11P_NS);
 
         SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
         requestContext.setMessageDecoder(decoder);
index 4c708d7..4cfc5f5 100644 (file)
@@ -149,11 +149,15 @@ public class ArtifactResolution extends AbstractSAML2ProfileHandler {
         MetadataProvider metadataProvider = getMetadataProvider();
 
         ArtifactResolutionRequestContext requestContext = new ArtifactResolutionRequestContext();
+        requestContext.setMetadataProvider(metadataProvider);
+        
         requestContext.setInboundMessageTransport(inTransport);
         requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+
+        
         requestContext.setOutboundMessageTransport(outTransport);
         requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
-        requestContext.setMetadataProvider(metadataProvider);
 
         try {
             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
@@ -175,15 +179,7 @@ public class ArtifactResolution extends AbstractSAML2ProfileHandler {
         } finally {
             // Set as much information as can be retrieved from the decoded message
             try {
-                ArtifactResolve artResolve = requestContext.getInboundSAMLMessage();
-                requestContext.setInboundSAMLMessageId(artResolve.getID());
-                requestContext.setInboundSAMLMessageIssueInstant(artResolve.getIssueInstant());
-
                 String relyingPartyId = requestContext.getPeerEntityId();
-                requestContext.setPeerEntityMetadata(metadataProvider.getEntityDescriptor(relyingPartyId));
-                requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
-                requestContext.setPeerEntityRoleMetadata(requestContext.getPeerEntityMetadata().getSPSSODescriptor(
-                        SAMLConstants.SAML20P_NS));
                 RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
                 requestContext.setRelyingPartyConfiguration(rpConfig);
 
index 325a1c2..e53c0b0 100644 (file)
@@ -109,11 +109,15 @@ public class AttributeQueryProfileHandler extends AbstractSAML2ProfileHandler {
         MetadataProvider metadataProvider = getMetadataProvider();
 
         AttributeQueryContext requestContext = new AttributeQueryContext();
+        requestContext.setMetadataProvider(metadataProvider);
+        
         requestContext.setInboundMessageTransport(inTransport);
         requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+
+        
         requestContext.setOutboundMessageTransport(outTransport);
         requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
-        requestContext.setMetadataProvider(metadataProvider);
 
         try {
             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
@@ -135,15 +139,7 @@ public class AttributeQueryProfileHandler extends AbstractSAML2ProfileHandler {
         } finally {
             // Set as much information as can be retrieved from the decoded message
             try {
-                AttributeQuery attributeQuery = requestContext.getInboundSAMLMessage();
-                requestContext.setInboundSAMLMessageId(attributeQuery.getID());
-                requestContext.setInboundSAMLMessageIssueInstant(attributeQuery.getIssueInstant());
-
                 String relyingPartyId = requestContext.getPeerEntityId();
-                requestContext.setPeerEntityMetadata(metadataProvider.getEntityDescriptor(relyingPartyId));
-                requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
-                requestContext.setPeerEntityRoleMetadata(requestContext.getPeerEntityMetadata().getSPSSODescriptor(
-                        SAMLConstants.SAML20P_NS));
                 RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
                 requestContext.setRelyingPartyConfiguration(rpConfig);
 
index ccc5479..2651ceb 100644 (file)
@@ -245,9 +245,14 @@ public class SSOProfileHandler extends AbstractSAML2ProfileHandler {
         }
 
         SSORequestContext requestContext = new SSORequestContext();
+        requestContext.setMetadataProvider(getMetadataProvider());
+        
         requestContext.setInboundMessageTransport(inTransport);
+        requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
+        requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+        
         requestContext.setOutboundMessageTransport(outTransport);
-        requestContext.setMetadataProvider(getMetadataProvider());
+        requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
 
         try {
             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());