private XMLObject unmarshallObject(String xmlString) throws UnmarshallingException, XMLParserException, UnsupportedEncodingException { BasicParserPool parser = new BasicParserPool(); parser.setNamespaceAware(true); /* Base64URL encoded */ byte bytes[] = xmlString.getBytes("utf-8"); if (bytes == null || bytes.length == 0) throw new InsufficientAuthenticationException("Invalid assertion encoding"); Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes)); Document doc = parser.parse(reader); Element samlElement = doc.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElement); if (unmarshaller == null) { throw new InsufficientAuthenticationException("Unsuccessful to unmarshal assertion string"); } return unmarshaller.unmarshall(samlElement); }
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); }
private Response parseResponse(String authnResponse) throws SAMLException { try { final Document doc = parsers.getBuilder() .parse(new InputSource(new StringReader(authnResponse))); final Element root = doc.getDocumentElement(); return (Response) Configuration.getUnmarshallerFactory() .getUnmarshaller(root) .unmarshall(root); } catch (org.opensaml.xml.parse.XMLParserException | org.opensaml.xml.io.UnmarshallingException | org.xml.sax.SAXException | java.io.IOException e) { throw new SAMLException(e); } }
/** * Constructing the XMLObject Object from a String * * @param authReqStr * @return Corresponding XMLObject which is a SAML2 object * @throws Exception */ public static XMLObject unmarshall(String authReqStr) throws Exception { try { doBootstrap(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = docBuilder.parse(new ByteArrayInputStream(authReqStr.trim().getBytes())); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (Exception e) { throw new Exception("Error in constructing AuthRequest from " + "the encoded String ", e); } }
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.base.IdentityException */ public static XMLObject unmarshall(String xmlString) throws IdentityException { try { DocumentBuilderFactory documentBuilderFactory = getSecuredDocumentBuilderFactory(); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes(Charsets.UTF_8))); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (ParserConfigurationException | UnmarshallingException | SAXException | IOException e) { String message = "Error in constructing XML Object from the encoded String"; throw IdentityException.error(message, e); } }
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.entitlement.EntitlementException */ public XMLObject unmarshall(String xmlString) throws EntitlementException { try { doBootstrap(); DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory(); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes())); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (Exception e) { log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e); throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e); } }
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.entitlement.EntitlementException */ public XMLObject unmarshall(String xmlString) throws EntitlementException { try { doBootstrap(); DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory(); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes())); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (Exception e) { log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e); throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e); } }
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.entitlement.EntitlementException */ public XMLObject unmarshall(String xmlString) throws EntitlementException { try { doBootstrap(); DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory(); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes())); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (Exception e) { log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e); throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e); } }
("UTF-8")))); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element);
.getBytes())); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element);
Document document = docBuilder.parse(inputStream); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element);
/** * Unmarshall specified DOM {@link Element} to an opensaml {@link XMLObject} * * @param xmlElement * DOM element * @param <X> * opensaml type * @return the opensaml object. */ @SuppressWarnings({ "unchecked" }) public static <X extends XMLObject> X unmarshall(Element xmlElement) { UnmarshallerFactory unmarshallerFactory = Configuration .getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory .getUnmarshaller(xmlElement); try { return (X) unmarshaller.unmarshall(xmlElement); } catch (UnmarshallingException e) { throw new RuntimeException("opensaml2 unmarshalling " + "error: " + e.getMessage(), e); } }
Document document = docBuilder.parse(inputStream); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element);
private Response parseResponse(String authnResponse) throws SAMLException { try { Document doc = parsers.getBuilder() .parse(new InputSource(new StringReader(authnResponse))); Element root = doc.getDocumentElement(); return (Response) Configuration.getUnmarshallerFactory() .getUnmarshaller(root) .unmarshall(root); } catch (org.opensaml.xml.parse.XMLParserException e) { throw new SAMLException(e); } catch (org.opensaml.xml.io.UnmarshallingException e) { throw new SAMLException(e); } catch (org.xml.sax.SAXException e) { throw new SAMLException(e); } catch (java.io.IOException e) { throw new SAMLException(e); } }
Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration .getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory .getUnmarshaller(element);
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element);
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.base.IdentityException */ public static XMLObject unmarshall(String xmlString) throws IdentityException { try { DocumentBuilderFactory documentBuilderFactory = getSecuredDocumentBuilderFactory(); documentBuilderFactory.setIgnoringComments(true); Document document = getDocument(documentBuilderFactory, xmlString); if (isSignedWithComments(document)) { documentBuilderFactory.setIgnoringComments(false); document = getDocument(documentBuilderFactory, xmlString); } Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (ParserConfigurationException | UnmarshallingException | SAXException | IOException e) { String message = "Error in constructing XML Object from the encoded String"; throw IdentityException.error(message, e); } }
/** * Constructing the SAML or XACML Objects from a String * * @param xmlString Decoded SAML or XACML String * @return SAML or XACML Object * @throws org.wso2.carbon.identity.base.IdentityException */ public static XMLObject unmarshall(String xmlString) throws IdentityException { try { DocumentBuilderFactory documentBuilderFactory = getSecuredDocumentBuilderFactory(); documentBuilderFactory.setIgnoringComments(true); Document document = getDocument(documentBuilderFactory, xmlString); if (isSignedWithComments(document)) { documentBuilderFactory.setIgnoringComments(false); document = getDocument(documentBuilderFactory, xmlString); } Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (ParserConfigurationException | UnmarshallingException | SAXException | IOException e) { String message = "Error in constructing XML Object from the encoded String"; throw IdentityException.error(message, e); } }
/** * Constructing the XMLObject Object from a String * * @param authReqStr * @return Corresponding XMLObject which is a SAML2 object * @throws SAML2SSOUIAuthenticatorException */ public static XMLObject unmarshall(String authReqStr) throws SAML2SSOUIAuthenticatorException { try { doBootstrap(); DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory(); Document document = getDocument(documentBuilderFactory, authReqStr); if (isSignedWithComments(document)) { documentBuilderFactory.setIgnoringComments(false); document = getDocument(documentBuilderFactory, authReqStr); } Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element); return unmarshaller.unmarshall(element); } catch (Exception e) { log.error("Error in constructing AuthRequest from the encoded String", e); throw new SAML2SSOUIAuthenticatorException("Error in constructing AuthRequest from " + "the encoded String ", e); } }
final Element root = doc.getDocumentElement(); final UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();