Wednesday, May 14, 2008

How To - 10.1.3 OWSM: Pass SAML token to the service after verification

The "Verify SAML token" policy step when executed removes the SAML token xml from the request message. This is inline with ws-security processing.

But, sometimes you may require the SAML token to be passed to the web service after it's verified by OWSM. This can be achieved by
Writing a custom policy step, and placing it immediately after the "Verify SAML token" step in the policy request pipeline. The custom step needs to extract the SAML token xml from message context and put it back into the request payload.

public IResult execute(IMessageContext ctx) throws Fault {
MessageContext context = (MessageContext) ctx;
ArrayList samlTokensList = context.getProperty("SAML_ASSERTIONS");
String samlToken = samlTokensList.get(0);
// now you can add this xml to either the SOAP body or a header element.