Search in sources :

Example 1 with WSEncryptionPart

use of org.apache.ws.security.WSEncryptionPart 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)

Example 2 with WSEncryptionPart

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

the class WSS4JTest method testSignHeaderAndBody.

@Test
public void testSignHeaderAndBody() throws Exception {
    Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>();
    parts.add(new WSEncryptionPart("header", "urn:ns1", ""));
    parts.add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", ""));
    testSignature("envelope1.xml", parts);
}
Also used : WSEncryptionPart(org.apache.ws.security.WSEncryptionPart) Vector(java.util.Vector) Test(org.junit.Test)

Example 3 with WSEncryptionPart

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

the class WSS4JTest method testSignPartById.

@Test
public void testSignPartById() throws Exception {
    Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>();
    parts.add(new WSEncryptionPart("my-id"));
    testSignature("envelope2.xml", parts);
}
Also used : WSEncryptionPart(org.apache.ws.security.WSEncryptionPart) Vector(java.util.Vector) Test(org.junit.Test)

Aggregations

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