private void buildCommonAttributes(String localEntityId, Response response, Endpoint service, AuthnRequest authnRequest) { response.setID(generateID()); response.setIssuer(getIssuer(localEntityId)); response.setInResponseTo(authnRequest.getID()); response.setVersion(SAMLVersion.VERSION_20); response.setIssueInstant(new DateTime()); if (service != null) { response.setDestination(service.getLocation()); } }
/** * Checks that Location is present. * * @param endpoint * @throws ValidationException */ protected void validateLocation(Endpoint endpoint) throws ValidationException { if (DatatypeHelper.isEmpty(endpoint.getLocation())) { throw new ValidationException("Location required"); } } }
endpoint = endpointItr.next(); if (!getSupportedIssuerBindings().contains(endpoint.getBinding())) { log.debug("Removing endpoint {} because its binding {} is not supported", endpoint.getLocation(), endpoint.getBinding()); endpointItr.remove(); endpoint.getLocation(), endpoint.getBinding()); endpointItr.remove();
/** {@inheritDoc} */ public void marshallAttributes(XMLObject samlElement, Element domElement) { Endpoint endpoint = (Endpoint) samlElement; if (endpoint.getBinding() != null) { domElement.setAttributeNS(null, Endpoint.BINDING_ATTRIB_NAME, endpoint.getBinding().toString()); } if (endpoint.getLocation() != null) { domElement.setAttributeNS(null, Endpoint.LOCATION_ATTRIB_NAME, endpoint.getLocation().toString()); } if (endpoint.getResponseLocation() != null) { domElement.setAttributeNS(null, Endpoint.RESPONSE_LOCATION_ATTRIB_NAME, endpoint.getResponseLocation() .toString()); } Attr attribute; for (Entry<QName, String> entry : endpoint.getUnknownAttributes().entrySet()) { attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey()); attribute.setValue(entry.getValue()); domElement.setAttributeNodeNS(attribute); if (Configuration.isIDAttribute(entry.getKey()) || endpoint.getUnknownAttributes().isIDAttribute(entry.getKey())) { attribute.getOwnerElement().setIdAttributeNode(attribute, true); } } } }
/** * Verifies that the destination URL intended in the message matches with the endpoint address. The URL message * was ultimately received doesn't need to necessarily match the one defined in the metadata (in case of e.g. reverse-proxying * of messages). * * @param endpoint endpoint the message was received at * @param destination URL of the endpoint the message was intended to be sent to by the peer or null when not included * @throws SAMLException in case endpoint doesn't match */ protected void verifyEndpoint(Endpoint endpoint, String destination) throws SAMLException { // Verify that destination in the response matches one of the available endpoints if (destination != null) { if (uriComparator.compare(destination, endpoint.getLocation())) { // Expected } else if (uriComparator.compare(destination, endpoint.getResponseLocation())) { // Expected } else { throw new SAMLException("Intended destination " + destination + " doesn't match any of the endpoint URLs on endpoint " + endpoint.getLocation() + " for profile " + getProfileIdentifier()); } } }
if (endpoint.getLocation() != null && uriComparator.compare(endpoint.getLocation(), requestURL)) { log.debug("Found endpoint {} for request URL {} based on location attribute in metadata", endpoint, requestURL); return endpoint;
/** {@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; }
/** * Fills the request with version, issue instants and destination data. * * @param localEntityId entityId of the local party acting as message issuer * @param request request to be filled * @param service service to use as destination for the request */ protected void buildCommonAttributes(String localEntityId, RequestAbstractType request, Endpoint service) { request.setID(generateID()); request.setIssuer(getIssuer(localEntityId)); request.setVersion(SAMLVersion.VERSION_20); request.setIssueInstant(new DateTime()); if (service != null) { // Service is now known when we do not know which IDP will be used request.setDestination(service.getLocation()); } }
/** * 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(); } }
urlBuilder = new URLBuilder(endpoint.getResponseLocation()); } else { if (DatatypeHelper.isEmpty(endpoint.getLocation())) { throw new MessageEncodingException("Relying party endpoint location was null or empty."); urlBuilder = new URLBuilder(endpoint.getLocation());
urlBuilder = new URLBuilder(endpoint.getResponseLocation()); } else { if (DatatypeHelper.isEmpty(endpoint.getLocation())) { throw new MessageEncodingException("Relying party endpoint location was null or empty."); urlBuilder = new URLBuilder(endpoint.getLocation());
URI uri = new URI(context.getPeerEntityEndpoint().getLocation(), true, "UTF-8"); postMethod = new PostMethod(); postMethod.setPath(uri.getPath());