Members | Sign In
Weblogic Wonders > Security
avatar

Read Binary security token in Soap Handler

posted Jun 08, 2015 12:43:52 by Farnaz Khan
Hi,
I have a implemented javax.xml.ws.handler.soap.SOAPHandler interface to have custom Handler being invoked whenever my web service is called. My web service is secured with X509 certificate.
My purpose is to read entire soapEnvolope.
When I override handleMessage method, I am able to read the SOAPHeader and SOAPBody, however, I am not able to get any information from the security element.

Later, I tried to use JAR:
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.5.6</version>

And update my code in the following manner:

Element elem = (Element)WSSecurityUtil.getSecurityHeader(soapMsg.getSOAPPart(),"",SOAPConstants.SOAP12_CONSTANTS);
// get a BinarySignature tag
org.w3c.dom.Node binarySignatureTag = ((org.w3c.dom.Node) elem).getFirstChild();
BinarySecurity token = null;
token = new X509Security((org.w3c.dom.Element) binarySignatureTag);
LOG.debug ("token"+token);

But I do not understand this code.

Please can you guide me, about, how do I read the security token in my handler.
Login below to reply: