/** {@inheritDoc} */ protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { Endpoint endpoint = (Endpoint) samlObject; if (attribute.getLocalName().equals(Endpoint.BINDING_ATTRIB_NAME)) { endpoint.setBinding(attribute.getValue()); } else if (attribute.getLocalName().equals(Endpoint.LOCATION_ATTRIB_NAME)) { endpoint.setLocation(attribute.getValue()); } else if (attribute.getLocalName().equals(Endpoint.RESPONSE_LOCATION_ATTRIB_NAME)) { endpoint.setResponseLocation(attribute.getValue()); } else { QName attribQName = XMLHelper.getNodeQName(attribute); if (attribute.isId()) { endpoint.getUnknownAttributes().registerID(attribQName); } endpoint.getUnknownAttributes().put(attribQName, attribute.getValue()); } }
/** {@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; }