1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.security.wss4j;
18
19 import org.w3c.dom.Document;
20
21 import org.springframework.ws.context.MessageContext;
22 import org.springframework.ws.soap.SoapMessage;
23
24 public abstract class Wss4jMessageInterceptorUsernameTokenSignatureTestCase extends Wss4jTestCase {
25
26 public void testAddUsernameTokenSignature() throws Exception {
27 Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
28 interceptor.setSecurementActions("UsernameTokenSignature");
29 interceptor.setSecurementUsername("Bert");
30 interceptor.setSecurementPassword("Ernie");
31 interceptor.afterPropertiesSet();
32 SoapMessage message = loadSoap11Message("empty-soap.xml");
33 MessageContext context = getSoap11MessageContext(message);
34 interceptor.secureMessage(message, context);
35
36 Document doc = getDocument(message);
37 assertXpathEvaluatesTo("Invalid Username", "Bert",
38 "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Username/text()", doc);
39 assertXpathExists("Invalid Password",
40 "/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:UsernameToken/wsse:Password[@Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest']/text()",
41 doc);
42 }
43 }