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;
String assertingPartyId = requestContext.getRelyingPartyConfiguration().getProviderId();
requestContext.setLocalEntityId(assertingPartyId);
- requestContext.setLocalEntityMetadata(metadataProvider.getEntityDescriptor(assertingPartyId));
+ EntityDescriptor assertingPartyMetadata = metadataProvider.getEntityDescriptor(assertingPartyId);
+ if (assertingPartyMetadata == null) {
+ throw new MetadataProviderException("Unable to locate metadata for asserting party "
+ + assertingPartyId);
+ }
+ requestContext.setLocalEntityMetadata(assertingPartyMetadata);
requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
- requestContext.setLocalEntityRoleMetadata(requestContext.getLocalEntityMetadata()
+ requestContext.setLocalEntityRoleMetadata(assertingPartyMetadata
.getAttributeAuthorityDescriptor(SAMLConstants.SAML11P_NS));
ArtifactResolutionConfiguration profileConfig = (ArtifactResolutionConfiguration) rpConfig
.getProfileConfiguration(ArtifactResolutionConfiguration.PROFILE_ID);
- if(profileConfig != null){
+ if (profileConfig != null) {
requestContext.setProfileConfiguration(profileConfig);
if (profileConfig.getSigningCredential() != null) {
requestContext.setOutboundSAMLMessageSigningCredential(profileConfig.getSigningCredential());
}
} catch (MetadataProviderException e) {
- log.error("Unable to locate metadata for asserting or relying party");
+ log.error(e.getMessage());
requestContext
.setFailureStatus(buildStatus(StatusCode.RESPONDER, null, "Error locating party metadata"));
throw new ProfileException("Error locating party metadata");
artifactMap.remove(assertionArtifact.getAssertionArtifact());
assertions.add((Assertion) artifactEntry.getSamlMessage());
}
-
+
requestContext.setReferencedAssertions(assertions);
}
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;
// Set as much information as can be retrieved from the decoded message
try {
Request request = requestContext.getInboundSAMLMessage();
+ if (request == null) {
+ throw new ProfileException("No inbound SAML message found.");
+ }
AttributeQuery query = request.getAttributeQuery();
requestContext.setSubjectNameIdentifier(query.getSubject().getNameIdentifier());
String assertingPartyId = requestContext.getRelyingPartyConfiguration().getProviderId();
requestContext.setLocalEntityId(assertingPartyId);
- requestContext.setLocalEntityMetadata(metadataProvider.getEntityDescriptor(assertingPartyId));
+ EntityDescriptor assertingPartyMetadata = metadataProvider.getEntityDescriptor(assertingPartyId);
+ if (assertingPartyMetadata == null) {
+ throw new MetadataProviderException("Unable to locate metadata for asserting party "
+ + assertingPartyId);
+ }
+ requestContext.setLocalEntityMetadata(assertingPartyMetadata);
requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
- requestContext.setLocalEntityRoleMetadata(requestContext.getLocalEntityMetadata()
+ requestContext.setLocalEntityRoleMetadata(assertingPartyMetadata
.getAttributeAuthorityDescriptor(SAMLConstants.SAML11P_NS));
AttributeQueryConfiguration profileConfig = (AttributeQueryConfiguration) rpConfig
}
} catch (MetadataProviderException e) {
- log.error("Unable to locate metadata for asserting or relying party");
+ log.error(e.getMessage());
requestContext
.setFailureStatus(buildStatus(StatusCode.RESPONDER, null, "Error locating party metadata"));
throw new ProfileException("Error locating party metadata");
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;
/** Artifact response object builder. */
private SAMLObjectBuilder<ArtifactResponse> responseBuilder;
-
+
/** Builder of assertion consumer service endpoints. */
private SAMLObjectBuilder<AssertionConsumerService> acsEndpointBuilder;
*/
public ArtifactResolution(SAMLArtifactMap map) {
super();
-
+
artifactMap = map;
-
+
responseBuilder = (SAMLObjectBuilder<ArtifactResponse>) getBuilderFactory().getBuilder(
ArtifactResponse.DEFAULT_ELEMENT_NAME);
acsEndpointBuilder = (SAMLObjectBuilder<AssertionConsumerService>) getBuilderFactory().getBuilder(
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);
// Set as much information as can be retrieved from the decoded message
try {
requestContext.setArtifact(requestContext.getInboundSAMLMessage().getArtifact().getArtifact());
-
+
String relyingPartyId = requestContext.getInboundMessageIssuer();
RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
requestContext.setRelyingPartyConfiguration(rpConfig);
String assertingPartyId = requestContext.getRelyingPartyConfiguration().getProviderId();
requestContext.setLocalEntityId(assertingPartyId);
- requestContext.setLocalEntityMetadata(metadataProvider.getEntityDescriptor(assertingPartyId));
+ EntityDescriptor assertingPartyMetadata = metadataProvider.getEntityDescriptor(assertingPartyId);
+ if (assertingPartyMetadata == null) {
+ throw new MetadataProviderException("Unable to locate metadata for asserting party "
+ + assertingPartyId);
+ }
+ requestContext.setLocalEntityMetadata(assertingPartyMetadata);
requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
- requestContext.setLocalEntityRoleMetadata(requestContext.getLocalEntityMetadata()
+ requestContext.setLocalEntityRoleMetadata(assertingPartyMetadata
.getAttributeAuthorityDescriptor(SAMLConstants.SAML20P_NS));
ArtifactResolutionConfiguration profileConfig = (ArtifactResolutionConfiguration) rpConfig
.getProfileConfiguration(ArtifactResolutionConfiguration.PROFILE_ID);
- if(profileConfig != null){
+ if (profileConfig != null) {
requestContext.setProfileConfiguration(profileConfig);
if (profileConfig.getSigningCredential() != null) {
requestContext.setOutboundSAMLMessageSigningCredential(profileConfig.getSigningCredential());
}
} catch (MetadataProviderException e) {
- log.error("Unable to locate metadata for asserting or relying party");
+ log.error(e.getMessage());
requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, null,
"Error locating party metadata"));
throw new ProfileException("Error locating party metadata");
endpointSelector.getSupportedIssuerBindings().addAll(getSupportedOutboundBindings());
endpoint = endpointSelector.selectEndpoint();
}
-
+
return endpoint;
}
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;
/** Class logger. */
private static Logger log = Logger.getLogger(AttributeQueryProfileHandler.class);
-
+
/** Builder of assertion consumer service endpoints. */
private SAMLObjectBuilder<AssertionConsumerService> acsEndpointBuilder;
"SAML 2 Attribute Query profile is not configured for relying party "
+ requestContext.getInboundMessageIssuer()));
throw new ProfileException("SAML 2 Attribute Query profile is not configured for relying party "
- + requestContext.getInboundMessageIssuer());
+ + requestContext.getInboundMessageIssuer());
}
checkSamlVersion(requestContext);
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);
// Set as much information as can be retrieved from the decoded message
try {
AttributeQuery query = requestContext.getInboundSAMLMessage();
+ if (query == null) {
+ throw new ProfileException("No inbound SAML message found.");
+ }
requestContext.setSubjectNameIdentifier(query.getSubject().getNameID());
-
+
String relyingPartyId = requestContext.getInboundMessageIssuer();
RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
requestContext.setRelyingPartyConfiguration(rpConfig);
String assertingPartyId = requestContext.getRelyingPartyConfiguration().getProviderId();
requestContext.setLocalEntityId(assertingPartyId);
- requestContext.setLocalEntityMetadata(metadataProvider.getEntityDescriptor(assertingPartyId));
+ EntityDescriptor assertingPartyMetadata = metadataProvider.getEntityDescriptor(assertingPartyId);
+ if (assertingPartyMetadata == null) {
+ throw new MetadataProviderException("Unable to locate metadata for asserting party "
+ + assertingPartyId);
+ }
+ requestContext.setLocalEntityMetadata(assertingPartyMetadata);
requestContext.setLocalEntityRole(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
- requestContext.setLocalEntityRoleMetadata(requestContext.getLocalEntityMetadata()
+ requestContext.setLocalEntityRoleMetadata(assertingPartyMetadata
.getAttributeAuthorityDescriptor(SAMLConstants.SAML20P_NS));
AttributeQueryConfiguration profileConfig = (AttributeQueryConfiguration) rpConfig
.getProfileConfiguration(AttributeQueryConfiguration.PROFILE_ID);
- if(profileConfig != null){
+ if (profileConfig != null) {
requestContext.setProfileConfiguration(profileConfig);
requestContext.setOutboundMessageArtifactType(profileConfig.getOutboundArtifactType());
if (profileConfig.getSigningCredential() != null) {
}
}
} catch (MetadataProviderException e) {
- log.error("Unable to locate metadata for asserting or relying party");
+ log.error(e.getMessage());
requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, null,
"Error locating party metadata"));
throw new ProfileException("Error locating party metadata");
}
}
}
-
+
/**
* Selects the appropriate endpoint for the relying party and stores it in the request context.
*
if (loginContext.getPrincipalName() == null) {
log.error("User's login context did not contain a principal, user considered unauthenticiated.");
if (loginContext.getPassiveAuth()) {
- requestContext
- .setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.NO_PASSIVE_URI, null));
+ requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.NO_PASSIVE_URI,
+ null));
} else {
- requestContext
- .setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.AUTHN_FAILED_URI, null));
+ requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.AUTHN_FAILED_URI,
+ null));
}
throw new ProfileException("User failed authentication");
}