Author: anil.saldhana(a)jboss.com
Date: 2011-04-06 12:27:06 -0400 (Wed, 06 Apr 2011)
New Revision: 867
Modified:
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/STSWSClientTestCase.java
Log:
add comments
Modified:
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/STSWSClientTestCase.java
===================================================================
---
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/STSWSClientTestCase.java 2011-04-06
16:25:13 UTC (rev 866)
+++
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/STSWSClientTestCase.java 2011-04-06
16:27:06 UTC (rev 867)
@@ -49,34 +49,38 @@
{
private static String username = "UserA";
private static String password = "PassA";
-
+
@SuppressWarnings("rawtypes")
@Test
- public void testWSInteraction() throws Exception {
+ public void testWSInteraction() throws Exception
+ {
+ // Step 1: Get a SAML2 Assertion Token from the STS
WSTrustClient client = new WSTrustClient("PicketLinkSTS",
"PicketLinkSTSPort",
"http://localhost:8080/picketlink-sts/PicketLinkSTS",
new SecurityInfo(username, password));
- Element assertion = null;
- try {
- System.out.println("Invoking token service to get SAML assertion for "
+ username);
- assertion = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);
- System.out.println("SAML assertion for " + username + "
successfully obtained!");
- } catch (WSTrustException wse) {
- System.out.println("Unable to issue assertion: " + wse.getMessage());
- wse.printStackTrace();
- System.exit(1);
- }
+ Element assertion = null;
+ try {
+ System.out.println("Invoking token service to get SAML assertion for "
+ username);
+ assertion = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);
+ System.out.println("SAML assertion for " + username + "
successfully obtained!");
+ } catch (WSTrustException wse) {
+ System.out.println("Unable to issue assertion: " + wse.getMessage());
+ wse.printStackTrace();
+ System.exit(1);
+ }
- URL wsdl = new
URL("http://localhost:8080/picketlink-wstest-tests/WSTestBean?wsdl");
- QName serviceName = new
QName("http://ws.trust.test.picketlink.org/",
"WSTestBeanService");
- Service service = Service.create(wsdl, serviceName);
- WSTest port = service.getPort(new
QName("http://ws.trust.test.picketlink.org/", "WSTestBeanPort"),
WSTest.class);
- BindingProvider bp = (BindingProvider)port;
- bp.getRequestContext().put(SAML2Constants.SAML2_ASSERTION_PROPERTY, assertion);
- List<Handler> handlers = bp.getBinding().getHandlerChain();
- handlers.add(new SAML2Handler());
- bp.getBinding().setHandlerChain(handlers);
-
- port.echo("Test");
+ // Step 2: Stuff the Assertion on the SOAP message context and add the SAML2Handler
to client side handlers
+ URL wsdl = new
URL("http://localhost:8080/picketlink-wstest-tests/WSTestBean?wsdl");
+ QName serviceName = new
QName("http://ws.trust.test.picketlink.org/",
"WSTestBeanService");
+ Service service = Service.create(wsdl, serviceName);
+ WSTest port = service.getPort(new
QName("http://ws.trust.test.picketlink.org/", "WSTestBeanPort"),
WSTest.class);
+ BindingProvider bp = (BindingProvider)port;
+ bp.getRequestContext().put(SAML2Constants.SAML2_ASSERTION_PROPERTY, assertion);
+ List<Handler> handlers = bp.getBinding().getHandlerChain();
+ handlers.add(new SAML2Handler());
+ bp.getBinding().setHandlerChain(handlers);
+
+ //Step 3: Access the WS. Exceptions will be thrown anyway.
+ port.echo("Test");
}
}
\ No newline at end of file