public static Document createEmptyDocument() { return createEmptyDocument(null); }
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; }
public static XMLBuilder withNewDocument() { return new XMLBuilder(DOMParser.createEmptyDocument()); }
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; } }
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; }
private Document buildIsoDocument() throws WebServiceDescriptionException { DOMResult result = null; try { String template = templateFactory.getTemplateFor(response); transformerService.setRulesetSystemID(template); result = new DOMResult(DOMParser.createEmptyDocument()); transformerService.transform(new DOMSource(response), result); } catch (Exception e) { LOG.error("Error reading capabilities document: {}", e.getMessage()); throw new WebServiceDescriptionException("Error reading capabilities document", e); } return (Document) result.getNode(); }