import org.opensaml.saml2.metadata.AssertionConsumerService;
import org.opensaml.saml2.metadata.AttributeAuthorityDescriptor;
import org.opensaml.saml2.metadata.Endpoint;
+import org.opensaml.saml2.metadata.EntityDescriptor;
import org.opensaml.saml2.metadata.SPSSODescriptor;
import org.opensaml.saml2.metadata.provider.MetadataProvider;
-import org.opensaml.saml2.metadata.provider.MetadataProviderException;
import org.opensaml.ws.message.decoder.MessageDecodingException;
import org.opensaml.ws.transport.http.HTTPInTransport;
import org.opensaml.ws.transport.http.HTTPOutTransport;
import org.slf4j.LoggerFactory;
import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
-import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
+import edu.internet2.middleware.shibboleth.common.profile.provider.BaseSAMLProfileRequestContext;
import edu.internet2.middleware.shibboleth.common.relyingparty.provider.saml1.ArtifactResolutionConfiguration;
/**
/** {@inheritDoc} */
public String getProfileId() {
- return "urn:mace:shibboleth:2.0:idp:profiles:saml1:request:artifact";
+ return ArtifactResolutionConfiguration.PROFILE_ID;
}
/** {@inheritDoc} */
*/
protected ArtifactResolutionRequestContext decodeRequest(HTTPInTransport inTransport, HTTPOutTransport outTransport)
throws ProfileException {
- log.debug("Decoding incomming request");
-
- MetadataProvider metadataProvider = getMetadataProvider();
+ log.debug("Decoding message with decoder binding {}", getInboundBinding());
ArtifactResolutionRequestContext requestContext = new ArtifactResolutionRequestContext();
+
+ MetadataProvider metadataProvider = getMetadataProvider();
requestContext.setMetadataProvider(metadataProvider);
- requestContext.setSecurityPolicyResolver(getSecurityPolicyResolver());
- requestContext.setCommunicationProfileId(ArtifactResolutionConfiguration.PROFILE_ID);
requestContext.setInboundMessageTransport(inTransport);
requestContext.setInboundSAMLProtocol(SAMLConstants.SAML11P_NS);
+ requestContext.setSecurityPolicyResolver(getSecurityPolicyResolver());
requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
requestContext.setOutboundMessageTransport(outTransport);
throw new ProfileException("Message did not meet security requirements", e);
} finally {
// Set as much information as can be retrieved from the decoded message
- try {
- String relyingPartyId = requestContext.getInboundMessageIssuer();
- RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
- requestContext.setRelyingPartyConfiguration(rpConfig);
- requestContext.setPeerEntityEndpoint(selectEndpoint(requestContext));
-
- String assertingPartyId = requestContext.getRelyingPartyConfiguration().getProviderId();
- requestContext.setLocalEntityId(assertingPartyId);
- requestContext.setLocalEntityMetadata(metadataProvider.getEntityDescriptor(assertingPartyId));
- requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
- requestContext.setLocalEntityRoleMetadata(requestContext.getLocalEntityMetadata()
- .getAttributeAuthorityDescriptor(SAMLConstants.SAML11P_NS));
-
- ArtifactResolutionConfiguration profileConfig = (ArtifactResolutionConfiguration) rpConfig
- .getProfileConfiguration(ArtifactResolutionConfiguration.PROFILE_ID);
- if(profileConfig != null){
- requestContext.setProfileConfiguration(profileConfig);
- if (profileConfig.getSigningCredential() != null) {
- requestContext.setOutboundSAMLMessageSigningCredential(profileConfig.getSigningCredential());
- } else if (rpConfig.getDefaultSigningCredential() != null) {
- requestContext.setOutboundSAMLMessageSigningCredential(rpConfig.getDefaultSigningCredential());
- }
- }
-
- } catch (MetadataProviderException e) {
- log.error("Unable to locate metadata for asserting or relying party");
- requestContext
- .setFailureStatus(buildStatus(StatusCode.RESPONDER, null, "Error locating party metadata"));
- throw new ProfileException("Error locating party metadata");
- }
+ populateRequestContext(requestContext);
+ populateProfileInformation(requestContext);
}
}
+ /** {@inheritDoc} */
+ protected void populateRelyingPartyInformation(BaseSAMLProfileRequestContext requestContext)
+ throws ProfileException {
+ super.populateRelyingPartyInformation(requestContext);
+
+ EntityDescriptor relyingPartyMetadata = requestContext.getPeerEntityMetadata();
+ if (relyingPartyMetadata != null) {
+ requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
+ requestContext.setPeerEntityRoleMetadata(relyingPartyMetadata.getSPSSODescriptor(SAMLConstants.SAML11P_NS));
+ }
+ }
+
+ /** {@inheritDoc} */
+ protected void populateAssertingPartyInformation(BaseSAMLProfileRequestContext requestContext)
+ throws ProfileException {
+ super.populateAssertingPartyInformation(requestContext);
+
+ EntityDescriptor localEntityDescriptor = requestContext.getLocalEntityMetadata();
+ if (localEntityDescriptor != null) {
+ requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
+ requestContext.setLocalEntityRoleMetadata(localEntityDescriptor
+ .getAttributeAuthorityDescriptor(SAMLConstants.SAML11P_NS));
+ }
+ }
+
+ /** {@inheritDoc} */
+ protected void populateSAMLMessageInformation(BaseSAMLProfileRequestContext requestContext) throws ProfileException {
+ // nothing to do here
+ }
+
/**
* Selects the appropriate endpoint for the relying party and stores it in the request context.
*
*
* @return Endpoint selected from the information provided in the request context
*/
- protected Endpoint selectEndpoint(ArtifactResolutionRequestContext requestContext) {
+ protected Endpoint selectEndpoint(BaseSAMLProfileRequestContext requestContext) {
Endpoint endpoint;
if (getInboundBinding().equals(SAMLConstants.SAML1_SOAP11_BINDING_URI)) {
}
/**
- * Derferences the artifacts within the incomming request and stores them in the request context.
+ * Derferences the artifacts within the incoming request and stores them in the request context.
*
* @param requestContext current request context
*
- * @throws ProfileException thrown if the incomming request does not contain any {@link AssertionArtifact}s.
+ * @throws ProfileException thrown if the incoming request does not contain any {@link AssertionArtifact}s.
*/
protected void derferenceArtifacts(ArtifactResolutionRequestContext requestContext) throws ProfileException {
Request request = requestContext.getInboundSAMLMessage();
artifactMap.remove(assertionArtifact.getAssertionArtifact());
assertions.add((Assertion) artifactEntry.getSamlMessage());
}
-
- requestContext.setReferencedAssertions(assertions);
+
+ requestContext.setDereferencedAssertions(assertions);
}
/**
samlResponse.setIssueInstant(issueInstant);
populateStatusResponse(requestContext, samlResponse);
- if (requestContext.getReferencedAssertions() != null) {
- samlResponse.getAssertions().addAll(requestContext.getReferencedAssertions());
+ if (requestContext.getDereferencedAssertions() != null) {
+ samlResponse.getAssertions().addAll(requestContext.getDereferencedAssertions());
}
Status status = buildStatus(StatusCode.SUCCESS, null, null);
return samlResponse;
}
- /** Represents the internal state of a SAML 1 Artiface resolver request while it's being processed by the IdP. */
+ /** Represents the internal state of a SAML 1 Artifact resolver request while it's being processed by the IdP. */
public class ArtifactResolutionRequestContext extends
BaseSAML1ProfileRequestContext<Request, Response, ArtifactResolutionConfiguration> implements
SAML1ArtifactMessageContext<Request, Response, NameIdentifier> {
*
* @return SAML assertions referenced by the artifact(s)
*/
- public Collection<Assertion> getReferencedAssertions() {
+ public Collection<Assertion> getDereferencedAssertions() {
return referencedAssertions;
}
*
* @param assertions SAML assertions referenced by the artifact(s)
*/
- public void setReferencedAssertions(Collection<Assertion> assertions) {
+ public void setDereferencedAssertions(Collection<Assertion> assertions) {
referencedAssertions = assertions;
}
}