1
2
3
4
5
6
7
8
9
10
11 package org.mule.extras.wssecurity.testcases;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.umo.UMOMessage;
16
17 import java.util.Properties;
18
19 import org.apache.ws.security.WSConstants;
20 import org.apache.ws.security.handler.WSHandlerConstants;
21
22 public class XfireSamlTestCase extends FunctionalTestCase
23 {
24
25
26
27 public void testBogus () throws Exception
28 {
29
30 }
31
32 public void _testGoodUnsignedSamlTokenAuthentication () throws Exception
33 {
34 MuleClient client = new MuleClient();
35 Properties props = new Properties();
36
37
38 props.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SAML_TOKEN_UNSIGNED);
39
40 props.setProperty(WSHandlerConstants.SAML_PROP_FILE, "saml.properties");
41
42 props.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
43
44 props.setProperty(WSHandlerConstants.USER, "mulealias");
45
46 props.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
47 "org.mule.extras.wssecurity.callbackhandlers.MuleWsSecurityCallbackHandler");
48
49 UMOMessage m = client.send("xfire:http://localhost:8282/MySecuredUMO?method=echo", "Test",
50 props);
51 assertNotNull(m);
52 assertTrue(m.getPayload() instanceof String);
53 assertTrue(m.getPayload().equals("Test"));
54 }
55
56 public void _testBadUnsignedSamlTokenAuthentication () throws Exception
57 {
58 MuleClient client = new MuleClient();
59 Properties props = new Properties();
60
61
62 props.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
63
64 props.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
65
66 props.setProperty(WSHandlerConstants.USER, "baduser");
67
68 props.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
69 "org.mule.extras.wssecurity.callbackhandlers.MuleWsSecurityCallbackHandler");
70
71 UMOMessage m = null;
72 try
73 {
74 m = client.send("xfire:http://localhost:8282/MySecuredUMO?method=echo", "Test", props);
75 }
76 catch (Exception e)
77 {
78 assertNotNull(e);
79 }
80 assertNull(m);
81 }
82
83 public void _testGoodSignedSamlTokenAuthentication () throws Exception
84 {
85 MuleClient client = new MuleClient();
86 Properties props = new Properties();
87
88
89 props.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SAML_TOKEN_SIGNED);
90
91 props.setProperty(WSHandlerConstants.SAML_PROP_FILE, "saml.properties");
92
93 props.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
94
95 props.setProperty(WSHandlerConstants.USER, "mulealias");
96
97 props.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
98 "org.mule.extras.wssecurity.callbackhandlers.MuleWsSecurityCallbackHandler");
99
100 props.setProperty(WSHandlerConstants.SIG_PROP_FILE, "out-signed-security.properties");
101
102 props.setProperty(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
103
104 UMOMessage m = client.send("xfire:http://localhost:8282/MySecuredUMO?method=echo", "Test",
105 props);
106 assertNotNull(m);
107 assertTrue(m.getPayload() instanceof String);
108 assertTrue(m.getPayload().equals("Test"));
109 }
110
111 protected String getConfigResources ()
112 {
113 return "wssecurity-mule-config-for-inbound.xml";
114 }
115 }