public Document getOwnerDocument() { return delegateHeader.getOwnerDocument(); }
public Document getOwnerDocument() { return delegateElement.getOwnerDocument(); }
public Document getOwnerDocument() { return delegateElement.getOwnerDocument(); }
public Document getOwnerDocument() { return delegateElement.getOwnerDocument(); }
public SecurityHeader(SOAPElement delegateHeader) { this.delegateHeader = delegateHeader; this.ownerDoc = delegateHeader.getOwnerDocument(); topMostSoapElement = getFirstChildElement(); currentSoapElement = null; }
public void setValue(QName qName, ElementBinding element, Object owner, Object value) { SOAPElement e = (SOAPElement)owner; Text textNode = e.getOwnerDocument().createTextNode((String)value); e.appendChild(textNode); } }
private void appendCommentNode(SOAPElement soapElement, Node child) { String nodeValue = child.getNodeValue(); Document ownerDoc = soapElement.getOwnerDocument(); Comment comment = ownerDoc.createComment(nodeValue); soapElement.appendChild(comment); }
/** * Constructs a SAML <code>Assertion</code> header block from an existing * <code>SOAPElement</code>. * * @param element an existing SAML assertion element. * @throws XWSSecurityException when the element is not a valid template * for a SAML <code>Assertion</code>. */ public SamlAssertionHeaderBlock(SOAPElement element) throws XWSSecurityException { contextDocument_ = element.getOwnerDocument(); delegateAssertion_ = element; setSOAPElement(element); }
public SOAPElement makeUsable(SOAPElement elem)throws XWSSecurityException { SOAPElement elementToInsert = elem; try { if (elem.getOwnerDocument() != ownerDoc) { elementToInsert = (SOAPElement) ownerDoc.importNode( elem, true); } return elementToInsert; } catch (DOMException e) { log.log(Level.SEVERE, "WSS0376.error.inserting.header", e.getMessage()); throw new XWSSecurityException(e); } } public Node cloneNode(boolean arg0) {
private SOAPElement convertToSoapElement(Element element) throws SOAPException { if (element instanceof SOAPElement) { return (SOAPElement) element; } SOAPElement copy = createElement( element.getLocalName(), element.getPrefix(), element.getNamespaceURI()); Document ownerDoc = copy.getOwnerDocument(); NamedNodeMap attrMap = element.getAttributes(); for (int i=0; i < attrMap.getLength(); i++) { Attr nextAttr = (Attr)attrMap.item(i); Attr importedAttr = (Attr)ownerDoc.importNode(nextAttr, true); copy.setAttributeNodeNS(importedAttr); } NodeList nl = element.getChildNodes(); for (int i=0; i < nl.getLength(); i++) { org.w3c.dom.Node next = nl.item(i); org.w3c.dom.Node imported = ownerDoc.importNode(next, true); copy.appendChild(imported); } return copy; }
@Override protected void runTest() throws Throwable { Document doc = newSOAPFactory().createElement(new QName("test")).getOwnerDocument(); assertThat(doc).isNotInstanceOf(SOAPPart.class); assertThat(doc).isNotInstanceOf(javax.xml.soap.Node.class); assertThat(doc.createElementNS(null, "test")).isInstanceOf(SOAPElement.class); } }
/** * parse and create the KeyInfo element * @param element the KeyInfo element * NOTE : this constructor assumes a fully initialized XML KeyInfo * No additions are allowed on the keyinfo, only we can get existing * values. For example addkeyName() will have no impact on the KeyInfo * will not append a KeyName child to the KeyInfo. */ public KeyInfoHeaderBlock(SOAPElement element) throws XWSSecurityException { super(element); try { // The BaseURI in Apache KeyInfo is seems optional // However the purpose of it is not clear this.document = element.getOwnerDocument(); delegateKeyInfo = new KeyInfo(element,baseURI); } catch (XMLSecurityException e) { log.log( Level.SEVERE, "WSS0318.exception.while.creating.keyinfoblock", e); throw new XWSSecurityException(e); } }
@Override protected void runTest() throws Throwable { SOAPElement parent = newSOAPFactory().createElement(new QName("parent")); SOAPElement child1 = parent.addChildElement(new QName("child1")); SOAPElement child2 = (SOAPElement)parent.getOwnerDocument().createElementNS(null, "child2"); child2.setParentElement(parent); NodeList children = parent.getChildNodes(); assertEquals(2, children.getLength()); assertSame(child1, children.item(0)); assertSame(child2, children.item(1)); } }
/** * parse and create the Signature element * @param elem the element representing an XML Signature * NOTE : this constructor assumes a fully initialized XML Signature * No modifications are allowed on the signature, We can only get existing * values. For example appendObject() would throw an Exception. If * a KeyInfo was not present in the signature, then calling getKeyInfo() * will not append a KeyInfo child to the signature. */ public SignatureHeaderBlock(SOAPElement elem) throws XWSSecurityException { super(elem); try { this.document = elem.getOwnerDocument(); delegateSignature = new XMLSignature(elem, null); } catch (Exception e) { // add log here log.log( Level.SEVERE, "WSS0322.exception.creating.signatureblock", e); throw new XWSSecurityException(e); } }
public void insertBefore(SecurityHeaderBlock block,Node elem) throws XWSSecurityException { SOAPElement elementToInsert = block.getAsSoapElement(); try { if (elementToInsert.getOwnerDocument() != ownerDoc) { elementToInsert = (SOAPElement) ownerDoc.importNode( elementToInsert, true); } } catch (DOMException e) { log.log(Level.SEVERE, "WSS0376.error.inserting.header", e.getMessage()); throw new XWSSecurityException(e); } insertBefore(elementToInsert,elem); }
public void insertHeaderBlockElement(SOAPElement blockElement) throws XWSSecurityException { try { if (blockElement.getOwnerDocument() != ownerDoc) { blockElement = (SOAPElement) ownerDoc.importNode(blockElement, true); } updateTopMostSoapElement(); insertBefore(blockElement, topMostSoapElement); } catch (DOMException e) { log.log(Level.SEVERE, "WSS0376.error.inserting.header", e.getMessage()); throw new XWSSecurityException(e); } topMostSoapElement = blockElement; }
public void appendChild(SecurityHeaderBlock block) throws XWSSecurityException { SOAPElement elementToInsert = block.getAsSoapElement(); try { if (elementToInsert.getOwnerDocument() != ownerDoc) { elementToInsert = (SOAPElement) ownerDoc.importNode( elementToInsert, true); } appendChild(elementToInsert); } catch (DOMException e) { log.log(Level.SEVERE, "WSS0376.error.inserting.header", e.getMessage()); throw new XWSSecurityException(e); } }
/** * @throws XWSSecurityException * If the given element does not have an appropriate name. */ public ReferenceListHeaderBlock(SOAPElement element) throws XWSSecurityException { super(element); if (!(element.getLocalName().equals("ReferenceList") && XMLUtil.inEncryptionNS(element))) { log.log(Level.SEVERE, "WSS0362.error.creating.rlhb", element.getTagName()); throw new XWSSecurityException("Invalid ReferenceList passed"); } ownerDoc = element.getOwnerDocument(); size = element.getElementsByTagNameNS(MessageConstants.XENC_NS, "DataReference").getLength(); }
/** * Inserts the header block at the top of the security header, i.e, * the block becomes the first child element of the security header. * This method will be used on the sender side. */ public void insertHeaderBlock(SecurityHeaderBlock block) throws XWSSecurityException { SOAPElement elementToInsert = block.getAsSoapElement(); try { if (elementToInsert.getOwnerDocument() != ownerDoc) { elementToInsert = (SOAPElement) ownerDoc.importNode( elementToInsert, true); } updateTopMostSoapElement(); insertBefore(elementToInsert, topMostSoapElement); } catch (DOMException e) { log.log(Level.SEVERE, "WSS0376.error.inserting.header", e.getMessage()); throw new XWSSecurityException(e); } topMostSoapElement = elementToInsert; }
/** * Creates an empty ReferenceList element. * * @throws XWSSecurityException * If there is problem creating a ReferenceList element. */ public ReferenceListHeaderBlock() throws XWSSecurityException { try { setSOAPElement( getSoapFactory().createElement( "ReferenceList", MessageConstants.XENC_PREFIX, MessageConstants.XENC_NS)); addNamespaceDeclaration( MessageConstants.XENC_PREFIX, MessageConstants.XENC_NS); } catch (SOAPException e) { log.log(Level.SEVERE, "WSS0360.error.creating.rlhb", e.getMessage()); throw new XWSSecurityException(e); } ownerDoc = getAsSoapElement().getOwnerDocument(); }