List of usage examples for javax.xml.soap SOAPEnvelope getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:it.cnr.icar.eric.common.security.wss4j.WSS4JSecurityUtilBase.java
protected static void verifySOAPEnvelopeBST(SOAPEnvelope se, CredentialInfo credentialInfo, Crypto crypto) throws WSSecurityException { WSSecurityEngine secEngine = new WSSecurityEngine(); WSSConfig.init();//w ww. j av a2 s .c om Document doc = se.getOwnerDocument(); List<WSSecurityEngineResult> results = secEngine.processSecurityHeader(doc, null, null, crypto); if (results != null) { WSSecurityEngineResult actionResult = WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN); X509Certificate cert = (X509Certificate) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); // inject certificate for further processing credentialInfo.cert = cert; } }
From source file:it.cnr.icar.eric.common.security.wss4j.WSS4JSecurityUtilBase.java
protected static void signSOAPEnvelopeBST(SOAPEnvelope se, CredentialInfo credentialInfo, Crypto userCrypto) throws WSSecurityException { WSSConfig.init();//from w ww. ja v a 2 s .c o m // inject empty SecHeader into Document Document doc = se.getOwnerDocument(); WSSecHeader secHeader = new WSSecHeader(); secHeader.insertSecurityHeader(doc); WSSecTimestamp timestamp = createTimestamp(); timestamp.build(doc, secHeader); // overridden WSS4J path for explicit setPrivateKey() // <ds:Signature> WSS4JSignatureBST sign = new WSS4JSignatureBST(); // <wsse:BinarySecurityToken ...> sign.setX509Certificate(credentialInfo.cert); sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE); sign.setPrivateKey(credentialInfo.privateKey); // <ds:KeyInfo> sign.setCertUri(CanonicalConstants.CANONICAL_URI_SENDER_CERT); String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement()); // signature references // <ds:Reference> List<WSEncryptionPart> parts = createReferences(soapNamespace); sign.setParts(parts); sign.build(doc, userCrypto, secHeader); }
From source file:edu.duke.cabig.c3pr.webservice.integration.StudyImportExportWebServiceTest.java
private SOAPMessage prepareRequestEnvelope(String xmlFile, String wrapperElement) throws SOAPException, DOMException, IOException, SAXException, ParserConfigurationException { MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage reqMsg = mf.createMessage(); SOAPPart part = reqMsg.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); SOAPBody body = env.getBody(); SOAPElement operation = body.addChildElement(wrapperElement, "stud", SERVICE_NS); operation.appendChild(env.getOwnerDocument().importNode(getSOAPBodyFromXML(xmlFile), true)); reqMsg.saveChanges();/* www. jav a 2 s .c o m*/ return reqMsg; }
From source file:org.jasig.portal.security.provider.saml.SAMLDelegatedAuthenticationService.java
private Document createSOAPFaultDocument(String faultString) throws SOAPException { MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart sp = message.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); se.setPrefix(SOAP_PREFIX);/*from www . jav a 2 s .c o m*/ se.getHeader().detachNode(); se.addHeader(); se.getBody().detachNode(); SOAPBody body = se.addBody(); SOAPFault fault = body.addFault(); Name faultCode = se.createName("Client", null, SOAPConstants.URI_NS_SOAP_ENVELOPE); fault.setFaultCode(faultCode); fault.setFaultString(faultString); return se.getOwnerDocument(); }
From source file:org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.java
private String toString(SOAPEnvelope saajEnvelope) throws TransformerException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Transformer tf;/*from w ww.j a v a2 s . co m*/ tf = TransformerFactory.newInstance().newTransformer(); tf.transform(new DOMSource(saajEnvelope.getOwnerDocument()), new StreamResult(baos)); return new String(baos.toByteArray()); }