/** * 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; }
/** * Checks that Binding is present. * * @param endpoint * @throws ValidationException */ protected void validateBinding(Endpoint endpoint) throws ValidationException { if (DatatypeHelper.isEmpty(endpoint.getBinding())) { throw new ValidationException("Binding required"); } }
while (endpointItr.hasNext()) { endpoint = endpointItr.next(); if (!getSupportedIssuerBindings().contains(endpoint.getBinding())) { log.debug("Removing endpoint {} because its binding {} is not supported", endpoint.getLocation(), endpoint.getBinding()); endpointItr.remove(); continue; if (filterByRequestBinding && !endpoint.getBinding().equals(acsBinding)) { log.debug("Removing endpoint {} because its binding {} does not match request's requested binding", 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); } } } }
/** * Method determines binding supported by the given endpoint. Usually the biding is encoded in the binding attribute * of the endpoint, but in some cases more processing is needed (e.g. for HoK profile). * * @param endpoint endpoint * @return binding supported by the endpoint */ public static String getBindingForEndpoint(Endpoint endpoint) { String bindingName = endpoint.getBinding(); // For HoK profile the used binding is determined in a different way if (org.springframework.security.saml.SAMLConstants.SAML2_HOK_WEBSSO_PROFILE_URI.equals(bindingName)) { QName attributeName = org.springframework.security.saml.SAMLConstants.WEBSSO_HOK_METADATA_ATT_NAME; String endpointLocation = endpoint.getUnknownAttributes().get(attributeName); if (endpointLocation != null) { bindingName = endpointLocation; } else { throw new SAMLRuntimeException("Holder of Key profile endpoint doesn't contain attribute hoksso:ProtocolBinding"); } } return bindingName; }