public static Document createEmptyDocument() { return createEmptyDocument(null); }
@Override public DocumentBuilder create(DOMParserOptions key) { return DOMParser.createDocumentBuilder((DOMParserOptions) key); }
/** * Parses the inputsource and informs the error handler about errors. * * @throws DOMParserException * if an SAXException or IOException occurs. */ public Document parse(final InputSource inputSource, final ErrorHandler errorhandler) throws DOMParserException { return parse(inputSource, errorhandler, getDefaultEntityResolver()); }
/** * Parses the inputsource. * * @throws DOMParserException * if an SAXException or IOException occurs. */ public Document parse(final InputSource inputSource) throws DOMParserException { return parse(inputSource, null, getDefaultEntityResolver()); } }
private static Document createDocument() throws ServiceException { return DOMParser.createEmptyDocument(); }
public static Document createDocument(DOMParserOptions options) { return DOMParser.createEmptyDocument(options); }
public static Document createDocumentFromNode(Node pNode, DOMParserOptions options) { Document responseDoc = DOMParser.createEmptyDocument(options); Node importedNode = responseDoc.importNode(pNode, true); responseDoc.appendChild(importedNode); return responseDoc; }
/** * Utility method to transform a string into a w3c-Document * * @param xmlString * string containing xml * @return document representing xml string * @throws Exception * is thrown in case an transformation error occurs */ public static Document readStringToDoc(String xmlString) throws Exception { Reader reader = new StringReader(xmlString); InputSource source = new InputSource(reader); Document doc = DOMParser.createNew().parse(source); return doc; }
private Document handleXACMLRequest(final Element xacmlRequest, final XACML1DecisionService decisionService) { Element response = decisionService.evaluate(xacmlRequest); // simple check if response is root element if (response == response.getOwnerDocument().getDocumentElement()) { return response.getOwnerDocument(); } else { // is not the root, so import in new document. Document resultDoc = DOMParser.createEmptyDocument(); response = (Element) resultDoc.importNode(response, true); resultDoc.appendChild(response); return resultDoc; } }
public static XMLBuilder withNewDocument() { return new XMLBuilder(DOMParser.createEmptyDocument()); }
private Document handleReset(final XACML1DecisionService decisionService) { // call update on decison service decisionService.update(); /* Create response: <ResetResponse xmlns="http://52North.org/security/decisionservice" success="true" /> */ Document resultDoc = DOMParser.createEmptyDocument(); Element rootElement = resultDoc.createElementNS(NAMESPACE_DECISIONSERVICE, "ResetResponse"); resultDoc.appendChild(rootElement); rootElement.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, rootElement.getNamespaceURI()); rootElement.setAttribute("success", "true"); return resultDoc; }
private Document handleRequestSet(final Element requestSet, final XACML1DecisionService decisionService) { // evaluate request with multiple xacml requests /* Create response: <ResponseSet xmlns="http://52North.org/security/decisionservice"> <Response xmlns="urn:oasis:names:tc:xacml:1.0:context">..</Response> <Response xmlns="urn:oasis:names:tc:xacml:1.0:context">..</Response> .. </ResponseSet> */ Document resultDoc = DOMParser.createEmptyDocument(); Element rootElement = resultDoc.createElementNS(NAMESPACE_DECISIONSERVICE, "ResponseSet"); rootElement.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, rootElement.getNamespaceURI()); resultDoc.appendChild(rootElement); NodeList childs = requestSet.getChildNodes(); for (int i = 0, l = childs.getLength(); i < l; ++i) { Node child = childs.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && "Request".equals(child.getLocalName())) { Element response = decisionService.evaluate((Element) child); response = (Element) resultDoc.importNode(response, true); rootElement.appendChild(response); } } resultDoc.normalize(); return resultDoc; }