/** {@inheritDoc} */ public Set<Namespace> getNamespaces() { return new LazySet<>(); }
protected SingleSignOnService getHoKSingleSignOnService(String entityBaseURL, String entityAlias, String filterURL, String binding) { SingleSignOnService hokSso = getSingleSignOnService(entityBaseURL, entityAlias, filterURL, org.springframework.security.saml.SAMLConstants.SAML2_HOK_WEBSSO_PROFILE_URI); QName consumerName = new QName(org.springframework.security.saml.SAMLConstants.SAML2_HOK_WEBSSO_PROFILE_URI, AuthnRequest.PROTOCOL_BINDING_ATTRIB_NAME, "hoksso"); hokSso.getUnknownAttributes().put(consumerName, binding); return hokSso; }
if (DatatypeHelper.isEmpty(encodedMessage)) { log.error("Request did not contain either a SAMLRequest or " + "SAMLResponse paramter. Invalid request for SAML 2 HTTP POST binding.");
public static String encodeSAMLRequest(XMLObject authnRequest) throws MarshallingException, IOException { Marshaller marshaller = Configuration.getMarshallerFactory() .getMarshaller(authnRequest); Element authDOM = marshaller.marshall(authnRequest); StringWriter requestWriter = new StringWriter(); XMLHelper.writeNode(authDOM, requestWriter); String requestMessage = requestWriter.toString(); Deflater deflater = new Deflater(Deflater.DEFLATED, true); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, deflater); deflaterOutputStream.write(requestMessage.getBytes(Charset.forName("UTF-8"))); deflaterOutputStream.close(); String encodedRequestMessage = Base64.encodeBytes(byteArrayOutputStream.toByteArray(), Base64.DONT_BREAK_LINES); encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, HttpUtils.UTF_8).trim(); return encodedRequestMessage; }
/** * Constructor. * * @param namespaceURI the namespace the element is in * @param elementLocalName the local name of the XML element this Object represents * @param namespacePrefix the prefix for the given namespace */ protected AttributeValueTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownAttributes = new AttributeMap(this); unknownElements = new IndexedXMLObjectChildrenList<XMLObject>(this); }
public static String generateSAMLRequestSignature(final String urlEncodedString, final PrivateKey signingKey, final String sigAlgorithmName) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, UnsupportedEncodingException { if (signingKey == null) { return urlEncodedString; } String opensamlAlgoIdSignature = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1; String javaSignatureAlgorithmName = "SHA1withRSA"; if (sigAlgorithmName.equalsIgnoreCase("SHA256")) { opensamlAlgoIdSignature = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256; javaSignatureAlgorithmName = "SHA256withRSA"; } else if (sigAlgorithmName.equalsIgnoreCase("SHA384")) { opensamlAlgoIdSignature = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA384; javaSignatureAlgorithmName = "SHA384withRSA"; } else if (sigAlgorithmName.equalsIgnoreCase("SHA512")) { opensamlAlgoIdSignature = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA512; javaSignatureAlgorithmName = "SHA512withRSA"; } String url = urlEncodedString + "&SigAlg=" + URLEncoder.encode(opensamlAlgoIdSignature, HttpUtils.UTF_8); Signature signature = Signature.getInstance(javaSignatureAlgorithmName); signature.initSign(signingKey); signature.update(url.getBytes(Charset.forName("UTF-8"))); String signatureString = Base64.encodeBytes(signature.sign(), Base64.DONT_BREAK_LINES); if (signatureString != null) { return url + "&Signature=" + URLEncoder.encode(signatureString, HttpUtils.UTF_8); } return url; }
public static Response decodeSAMLResponse(String responseMessage) throws ConfigurationException, ParserConfigurationException, SAXException, IOException, UnmarshallingException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); byte[] base64DecodedResponse = Base64.decode(responseMessage); Document document = docBuilder.parse(new ByteArrayInputStream(base64DecodedResponse)); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return (Response) unmarshaller.unmarshall(element); }
String getAssertionXml(Assertion assertion) { try { AssertionMarshaller marshaller = new AssertionMarshaller(); Element plaintextElement = marshaller.marshall(assertion); String serializedElement = XMLHelper.nodeToString(plaintextElement); return serializedElement; } catch(Exception e) { } return null; }
/** * Marshall an XMLObject to an OutputStream. * * @param xmlObject the XMLObject to marshall * @param outputStream the OutputStream to which to marshall * @throws MarshallingException if there is a problem marshalling the object */ public static void marshallToOutputStream(XMLObject xmlObject, OutputStream outputStream) throws MarshallingException { Element element = marshall(xmlObject); XMLHelper.writeNode(element, outputStream); }
returnUrlBuilder.getQueryParams().add(new Pair<String, String>(entry.getKey(), entry.getValue()));
/** * Inserts the specified element at the specified position in this list. Shifts the element currently at that * position (if any) and any subsequent elements to the right (adds one to their indices). * * @param index index of element to add * @param element element to be stored at the specified position */ public void add(int index, ElementType element) { super.add(index, element); indexElement(element); }
/** * Constructor. * * @param namespaceURI the namespace the element is in * @param elementLocalName the local name of the XML element this Object represents * @param namespacePrefix the prefix for the given namespace */ protected ResourceContentTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownAttributes = new AttributeMap(this); unknownElements = new IndexedXMLObjectChildrenList<XMLObject>(this); }
public String mockAssertionEncoded(Assertion assertion) throws Exception { AssertionMarshaller marshaller = new AssertionMarshaller(); Element plaintextElement = marshaller.marshall(assertion); String serializedElement = XMLHelper.nodeToString(plaintextElement); return Base64.encodeBase64URLSafeString(serializedElement.getBytes("utf-8")); }
/** * Constructor. * * @param namespaceURI the namespace the element is in * @param elementLocalName the local name of the XML element this Object represents * @param namespacePrefix the prefix for the given namespace */ protected AuthnContextDeclImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownXMLObjects = new IndexedXMLObjectChildrenList<XMLObject>(this); unknownAttributes = new AttributeMap(this); }
/** * Constructor. * * @param namespaceURI the namespace the element is in * @param elementLocalName the local name of the XML element this Object represents * @param namespacePrefix the prefix for the given namespace */ protected SubjectConfirmationDataImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownAttributes = new AttributeMap(this); unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this); }
/** * Constructor. * * @param namespaceURI The namespace of the element * @param elementLocalName The local name of the element * @param namespacePrefix The namespace prefix of the element */ public EntropyImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this); unknownAttributes = new AttributeMap(this); }
/** * Constructor. * * @param namespaceURI The namespace of the element * @param elementLocalName The local name of the element * @param namespacePrefix The namespace prefix of the element */ public RequestSecurityTokenImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this); unknownAttributes = new AttributeMap(this); }
/** * Constructor. * * @param namespaceURI namespace of the element * @param elementLocalName name of the element * @param namespacePrefix namespace prefix of the element */ protected EmbeddedImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownAttributes = new AttributeMap(this); unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this); }
/** * Constructor. * * @param namespaceURI The namespace of the element * @param elementLocalName The local name of the element * @param namespacePrefix The namespace prefix of the element */ public ReferenceParametersImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { super(namespaceURI, elementLocalName, namespacePrefix); unknownAttributes = new AttributeMap(this); unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this); }