/** * Parse a document from the string * * @param docString * @return * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public static Document getDocument(String docString) throws ConfigurationException, ParsingException, ProcessingException { return getDocument(new StringReader(docString)); }
/** * Signs a SAML assertion using the given security {@link KeyPair}. * @param assertion * @param keypair */ public static String signSAMLAssertion(String assertion, KeyPair keypair) { try { Document samlDocument = DocumentUtil.getDocument(assertion); SAML2Signature sig = new SAML2Signature(); sig.signSAMLDocument(samlDocument, keypair); return DocumentUtil.getDocumentAsString(samlDocument); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Parse a document from the string * @param docString * @return * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public static Document getDocument(String docString) throws ConfigurationException, ParsingException, ProcessingException { return getDocument(new StringReader(docString)); }
/** * Parse a document from the string * @param docString * @return * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public static Document getDocument(String docString) throws ConfigurationException, ParsingException, ProcessingException { return getDocument(new StringReader(docString)); }
public static Element assertionToElement(final String assertion) throws ProcessingException { try { Document document = DocumentUtil.getDocument(assertion); return (Element) document.getFirstChild(); } catch (final ConfigurationException e) { throw logger.processingError(e); } catch (final ParsingException e) { throw logger.processingError(e); } }
public static Element assertionToElement(final String assertion) throws ProcessingException { try { Document document = DocumentUtil.getDocument(assertion); return (Element) document.getFirstChild(); } catch (final ConfigurationException e) { throw new ProcessingException(e); } catch (final ParsingException e) { throw new ProcessingException(e); } }
/** * Convert a SAML2 Response into a Document * * @param responseType * @return * @throws ParserConfigurationException */ public Document convert(ResponseType responseType) throws ProcessingException, ParsingException, ConfigurationException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); SAMLResponseWriter writer = new SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos)); writer.write(responseType); ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray()); return DocumentUtil.getDocument(bis); }
public static Element assertionToElement(final String assertion) throws ProcessingException { try { Document document = DocumentUtil.getDocument(assertion); return (Element) document.getFirstChild(); } catch (final ConfigurationException e) { throw new ProcessingException(e); } catch (final ParsingException e) { throw new ProcessingException(e); } }
/** * Convert a SAML2 Response into a Document * @param responseType * @return * @throws ParserConfigurationException */ public Document convert(ResponseType responseType) throws ProcessingException, ParsingException, ConfigurationException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); SAMLResponseWriter writer = new SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos)); writer.write(responseType); ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray()); return DocumentUtil.getDocument(bis); }
/** * <p> * Utility method that marshals the specified {@code AssertionType} object into an {@code Element} instance. * </p> * * @param assertion an {@code AssertionType} object representing the SAML assertion to be marshaled. * @return a reference to the {@code Element} that contains the marshaled SAML assertion. * @throws Exception if an error occurs while marshaling the assertion. */ public static Element toElement(SAML11AssertionType assertion) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); SAML11AssertionWriter writer = new SAML11AssertionWriter(StaxUtil.getXMLStreamWriter(baos)); writer.write(assertion); ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray()); Document document = DocumentUtil.getDocument(bis); return document.getDocumentElement(); }
public static Document getXACMLResponse(ResponseType responseType) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JAXBElement<?> jaxb = (new ObjectFactory()).createResponse(responseType); StreamResult result = new StreamResult(baos); try { TransformerUtil.transform(SAMLXACMLUtil.getJAXBContext(), jaxb, result); return DocumentUtil.getDocument(new String(baos.toByteArray())); } catch (Exception e) { throw logger.processingError(e); } }
public static Document getXACMLRequest(RequestType requestType) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); // Marshaller marshaller = getMarshaller(); JAXBElement<?> jaxb = (new ObjectFactory()).createRequest(requestType); StreamResult result = new StreamResult(baos); try { TransformerUtil.transform(getJAXBContext(), jaxb, result); return DocumentUtil.getDocument(new String(baos.toByteArray())); } catch (Exception e) { throw logger.processingError(e); } } }
public static Document getXACMLRequest( RequestType requestType ) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); //Marshaller marshaller = getMarshaller(); JAXBElement<?> jaxb = (new ObjectFactory()).createRequest( requestType ); StreamResult result = new StreamResult( baos ); try { TransformerUtil.transform( getJAXBContext(), jaxb, result); return DocumentUtil.getDocument( new String( baos.toByteArray() )); } catch ( Exception e ) { throw new ProcessingException( e ); } } }
public static Document getXACMLResponse( ResponseType responseType ) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JAXBElement<?> jaxb = (new ObjectFactory()).createResponse( responseType ); StreamResult result = new StreamResult( baos ); try { TransformerUtil.transform( SAMLXACMLUtil.getJAXBContext(), jaxb, result); return DocumentUtil.getDocument( new String( baos.toByteArray() )); } catch ( Exception e ) { throw new ProcessingException( e ); } }
public static Document getXACMLResponse( ResponseType responseType ) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JAXBElement<?> jaxb = (new ObjectFactory()).createResponse( responseType ); StreamResult result = new StreamResult( baos ); try { TransformerUtil.transform( SAMLXACMLUtil.getJAXBContext(), jaxb, result); return DocumentUtil.getDocument( new String( baos.toByteArray() )); } catch ( Exception e ) { throw new ProcessingException( e ); } }
/** * Given {@code AssertionType}, convert it into a DOM Document. * * @param assertion * @return * @throws ProcessingException */ public static Document asDocument(AssertionType assertion) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos)); writer.write(assertion); try { return DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray())); } catch (Exception e) { throw logger.processingError(e); } }
public static Document getXACMLRequest( RequestType requestType ) throws ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); //Marshaller marshaller = getMarshaller(); JAXBElement<?> jaxb = (new ObjectFactory()).createRequest( requestType ); StreamResult result = new StreamResult( baos ); try { TransformerUtil.transform( getJAXBContext(), jaxb, result); return DocumentUtil.getDocument( new String( baos.toByteArray() )); } catch ( Exception e ) { throw new ProcessingException( e ); } } }
/** * Get an encrypted assertion from the stream * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public EncryptedAssertionType getEncryptedAssertion(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "inputstream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (EncryptedAssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Read an assertion from an input stream * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "inputstream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Read an assertion from an input stream * * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw logger.nullArgumentError("InputStream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }