Search in sources :

Example 1 with WSSecEncrypt

use of org.apache.ws.security.message.WSSecEncrypt in project webservices-axiom by apache.

the class WSS4JTest method testEncryptHeader.

@Test
public void testEncryptHeader() throws Exception {
    Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>();
    parts.add(new WSEncryptionPart("header", "urn:ns1", "Header"));
    WSSecEncrypt encrypt = new WSSecEncrypt();
    encrypt.setUserInfo("key2", "password");
    encrypt.setEncryptSymmKey(false);
    encrypt.setParts(parts);
    SOAPMessage message = load("envelope1.xml");
    Document doc = (Document) message;
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);
    encrypt.build(doc, crypto, secHeader);
}
Also used : WSEncryptionPart(org.apache.ws.security.WSEncryptionPart) WSSecHeader(org.apache.ws.security.message.WSSecHeader) WSSecEncrypt(org.apache.ws.security.message.WSSecEncrypt) Document(org.w3c.dom.Document) Vector(java.util.Vector) SOAPMessage(org.apache.axiom.soap.SOAPMessage) Test(org.junit.Test)

Aggregations

Vector (java.util.Vector)1 SOAPMessage (org.apache.axiom.soap.SOAPMessage)1 WSEncryptionPart (org.apache.ws.security.WSEncryptionPart)1 WSSecEncrypt (org.apache.ws.security.message.WSSecEncrypt)1 WSSecHeader (org.apache.ws.security.message.WSSecHeader)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1