MetadataProvider metadataProvider = samlMsgCtx.getMetadataProvider(); if (metadataProvider == null) { log.warn("Message context did not contain a metadata provider, unable to evaluate rule");
MetadataProvider metadataProvider = messageContext.getMetadataProvider(); try { if (metadataProvider != null) {
/** * Populates the peer's entity metadata if a metadata provide is present in the message context. Populates the * peer's role descriptor if the entity metadata was available and the role name is present in the message context. * * @param messageContext current message context * * @throws MessageDecodingException thrown if there is a problem populating the message context */ protected void populateRelyingPartyMetadata(SAMLMessageContext messageContext) throws MessageDecodingException { MetadataProvider metadataProvider = messageContext.getMetadataProvider(); try { if (metadataProvider != null) { EntityDescriptor relyingPartyMD = metadataProvider.getEntityDescriptor(messageContext .getInboundMessageIssuer()); messageContext.setPeerEntityMetadata(relyingPartyMD); QName relyingPartyRole = messageContext.getPeerEntityRole(); if (relyingPartyMD != null && relyingPartyRole != null) { List<RoleDescriptor> roles = relyingPartyMD.getRoleDescriptors(relyingPartyRole, SAMLConstants.SAML11P_NS); if (roles != null && roles.size() > 0) { messageContext.setPeerEntityRoleMetadata(roles.get(0)); } } } } catch (MetadataProviderException e) { log.error("Error retrieving metadata for relying party " + messageContext.getInboundMessageIssuer(), e); throw new MessageDecodingException("Error retrieving metadata for relying party " + messageContext.getInboundMessageIssuer(), e); } }
/** * Gets the source location used to for the artifacts created by this encoder. * * @param requestContext current request context * * @return source location used to for the artifacts created by this encoder */ protected Endpoint getAcsEndpoint(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) { BasicEndpointSelector selector = new BasicEndpointSelector(); selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME); selector.getSupportedIssuerBindings().add(SAMLConstants.SAML2_SOAP11_BINDING_URI); selector.setMetadataProvider(requestContext.getMetadataProvider()); selector.setEntityMetadata(requestContext.getLocalEntityMetadata()); selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata()); Endpoint acsEndpoint = selector.selectEndpoint(); if (acsEndpoint == null) { log.error("No artifact resolution service endpoint defined for the entity " + requestContext.getOutboundMessageIssuer()); return null; } return acsEndpoint; } }
/** * Gets the source location used to for the artifacts created by this encoder. * * @param requestContext current request context * * @return source location used to for the artifacts created by this encoder */ protected String getSourceLocation(SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext) { BasicEndpointSelector selector = new BasicEndpointSelector(); selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME); selector.getSupportedIssuerBindings().add(SAMLConstants.SAML1_SOAP11_BINDING_URI); selector.setMetadataProvider(requestContext.getMetadataProvider()); selector.setEntityMetadata(requestContext.getLocalEntityMetadata()); selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata()); Endpoint acsEndpoint = selector.selectEndpoint(); if (acsEndpoint == null) { log.error("Unable to select source location for artifact. No artifact resolution service defined for issuer."); return null; } return acsEndpoint.getLocation(); } }