Set communication profile before decoding
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / idp / profile / saml1 / ShibbolethSSOProfileHandler.java
index 6de3f77..da1ab1f 100644 (file)
@@ -98,7 +98,8 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
         subjectLocalityBuilder = (SAMLObjectBuilder<SubjectLocality>) getBuilderFactory().getBuilder(
                 SubjectLocality.DEFAULT_ELEMENT_NAME);
 
-        endpointBuilder = (SAMLObjectBuilder<Endpoint>) getBuilderFactory().getBuilder(Endpoint.DEFAULT_ELEMENT_NAME);
+        endpointBuilder = (SAMLObjectBuilder<Endpoint>) getBuilderFactory().getBuilder(
+                AssertionConsumerService.DEFAULT_ELEMENT_NAME);
     }
 
     /** {@inheritDoc} */
@@ -182,6 +183,8 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
         HttpServletRequest httpRequest = ((HttpServletRequestAdapter) inTransport).getWrappedRequest();
 
         ShibbolethSSORequestContext requestContext = new ShibbolethSSORequestContext();
+        requestContext.setCommunicationProfileId(getProfileId());
+        
         requestContext.setMetadataProvider(getMetadataProvider());
         requestContext.setSecurityPolicyResolver(getSecurityPolicyResolver());
 
@@ -204,7 +207,7 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
             log.error("Shibboleth SSO request does not meet security requirements", e);
             throw new ProfileException("Shibboleth SSO request does not meet security requirements", e);
         }
-        
+
         ShibbolethSSOLoginContext loginContext = new ShibbolethSSOLoginContext();
         loginContext.setRelyingParty(requestContext.getInboundMessageIssuer());
         loginContext.setSpAssertionConsumerService(requestContext.getSpAssertionConsumerService());
@@ -281,6 +284,7 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
     protected ShibbolethSSORequestContext buildRequestContext(ShibbolethSSOLoginContext loginContext,
             HTTPInTransport in, HTTPOutTransport out) throws ProfileException {
         ShibbolethSSORequestContext requestContext = new ShibbolethSSORequestContext();
+        requestContext.setCommunicationProfileId(getProfileId());
 
         requestContext.setMessageDecoder(getMessageDecoders().get(getInboundBinding()));
 
@@ -357,7 +361,7 @@ public class ShibbolethSSOProfileHandler extends AbstractSAML1ProfileHandler {
         if (endpoint == null && loginContext.getSpAssertionConsumerService() != null) {
             endpoint = endpointBuilder.buildObject();
             endpoint.setLocation(loginContext.getSpAssertionConsumerService());
-            endpoint.setBinding(getInboundBinding());
+            endpoint.setBinding(getSupportedOutboundBindings().get(0));
             log.warn("No endpoint available for relying party {}. Generating endpoint with ACS url {} and binding {}",
                     new Object[] { requestContext.getPeerEntityId(), endpoint.getLocation(), endpoint.getBinding() });
         }