/** * 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; } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") public Endpoint selectEndpoint() { if(getEntityRoleMetadata() == null){ return null; } List<? extends Endpoint> endpoints = getEntityRoleMetadata().getEndpoints(getEndpointType()); if (endpoints == null || endpoints.size() == 0) { return null; } Endpoint selectedEndpoint; endpoints = filterEndpointsByProtocolBinding(endpoints); if (endpoints == null || endpoints.size() == 0) { return null; } if (endpoints.get(0) instanceof IndexedEndpoint) { selectedEndpoint = selectIndexedEndpoint((List<IndexedEndpoint>) endpoints); } else { selectedEndpoint = selectNonIndexedEndpoint((List<Endpoint>) endpoints); } log.debug("Selected endpoint {} for request", selectedEndpoint.getLocation()); return selectedEndpoint; }
/** * Filters the list of possible endpoints by supported outbound bindings. * * @param endpoints raw list of endpoints * * @return filtered endpoints */ protected List<? extends Endpoint> filterEndpointsByProtocolBinding(List<? extends Endpoint> endpoints) { List<Endpoint> filteredEndpoints = new ArrayList<Endpoint>(endpoints); Iterator<Endpoint> endpointItr = filteredEndpoints.iterator(); Endpoint endpoint; while (endpointItr.hasNext()) { endpoint = endpointItr.next(); if (!getSupportedIssuerBindings().contains(endpoint.getBinding())) { endpointItr.remove(); continue; } } return filteredEndpoints; }
/** * 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(); } }