public static Document getDocumentFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); transformer.transform(source, result); return (Document) result.getNode(); } catch (TransformerException te) { throw new ProcessingException(te); } }
public static Node getNodeFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); TransformerUtil.transform(transformer,source,result); return result.getNode(); } catch (ParsingException pe){ throw logger.processingError(pe); } }
/** * Marshall the signed document to an output stream * * @param signedDocument * @param os * @throws TransformerException */ public static void marshall(Document signedDocument, OutputStream os) throws TransformerException { TransformerFactory tf = TransformerUtil.getTransformerFactory(); Transformer trans = tf.newTransformer(); trans.transform(DocumentUtil.getXMLSource(signedDocument), new StreamResult(os)); }
/** * Given that the {@code XMLEventReader} is in {@code XMLStreamConstants.START_ELEMENT} mode, we parse into a DOM Element * * @param xmlEventReader * @return * @throws ParsingException */ public static Element getDOMElement(XMLEventReader xmlEventReader) throws ParsingException { Transformer transformer = null; final String JDK_TRANSFORMER_PROPERTY = "picketlink.jdk.transformer"; boolean useJDKTransformer = Boolean.parseBoolean(SecurityActions.getSystemProperty(JDK_TRANSFORMER_PROPERTY, "false")); try { if (useJDKTransformer) { transformer = TransformerUtil.getTransformer(); } else { transformer = TransformerUtil.getStaxSourceToDomResultTransformer(); } Document resultDocument = DocumentUtil.createDocument(); DOMResult domResult = new DOMResult(resultDocument); Source source = new StAXSource(xmlEventReader); TransformerUtil.transform(transformer, source, domResult); Document doc = (Document) domResult.getNode(); return doc.getDocumentElement(); } catch (ConfigurationException e) { throw logger.parserException(e); } catch (XMLStreamException e) { throw logger.parserException(e); } }
/** * Use the transformer to transform * * @param transformer * @param stax * @param result * @throws ParsingException */ public static void transform(Transformer transformer, StAXSource stax, DOMResult result) throws ParsingException { transform(transformer, (Source)stax, result); }
transformer = TransformerUtil.getTransformer(); transformer = TransformerUtil.getStaxSourceToDomResultTransformer(); TransformerUtil.transform(transformer, source, domResult);
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); } }
transformer = TransformerUtil.getTransformer(); transformer = TransformerUtil.getStaxSourceToDomResultTransformer(); TransformerUtil.transform(transformer, source, domResult);
public static Node getNodeFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); transformer.transform(source, result); return result.getNode(); } catch (TransformerException te) { throw new ProcessingException(te); } }
public static Document getDocumentFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); TransformerUtil.transform(transformer,source,result); return (Document) result.getNode(); } catch (ParsingException te) { throw logger.processingError(te); } }
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); } } }
/** * Get the Default Transformer * * @return * @throws ConfigurationException */ public static Transformer getTransformer() throws ConfigurationException { Transformer transformer; try { transformer = getTransformerFactory().newTransformer(); } catch (TransformerConfigurationException e) { throw logger.configurationError(e); } catch (TransformerFactoryConfigurationError e) { throw logger.configurationError(e); } transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.INDENT, "no"); return transformer; }
public static Node getNodeFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); transformer.transform(source, result); return result.getNode(); } catch (TransformerException te) { throw new ProcessingException(te); } }
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 getDocumentFromSource(Source source) throws ProcessingException, ConfigurationException { try { Transformer transformer = TransformerUtil.getTransformer(); DOMResult result = new DOMResult(); transformer.transform(source, result); return (Document) result.getNode(); } catch (TransformerException te) { throw new ProcessingException(te); } }
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 ); } }
/** * Marshall a document into a String * * @param signedDoc * @return * @throws TransformerFactoryConfigurationError * @throws TransformerException */ public static String getDocumentAsString(Document signedDoc) throws ProcessingException, ConfigurationException { Source source = new DOMSource(signedDoc); StringWriter sw = new StringWriter(); Result streamResult = new StreamResult(sw); // Write the DOM document to the stream Transformer xformer = TransformerUtil.getTransformer(); try { xformer.transform(source, streamResult); } catch (TransformerException e) { throw logger.processingError(e); } return sw.toString(); }
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 the {@link Source} as an {@link InputStream} * * @param source * @return * @throws ConfigurationException * @throws ProcessingException */ public static InputStream getSourceAsStream(Source source) throws ConfigurationException, ProcessingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Result streamResult = new StreamResult(baos); // Write the DOM document to the stream Transformer transformer = TransformerUtil.getTransformer(); try { transformer.transform(source, streamResult); } catch (TransformerException e) { throw logger.processingError(e); } return new ByteArrayInputStream(baos.toByteArray()); }
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 ); } } }