Hi,
How do you access the security token/ user principal from a Spring-WS endpoint?
I downloaded spring-ws-2.0.4.RELEASE and got the tutorial project ( in samples) working. Next I added security, via a custom validation handler, and that also works.
My soap request looks as follows
Code:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://education.gov.ie/ppod/schemas"> <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>Bert</wsse:Username> <wsse:Password>Bert</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <sch:LookupSchoolRequest/> </soapenv:Body> </soapenv:Envelope>
My endpoint looks as follows
Code:@Endpoint public class MyEndpoint { private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; private MyService myService; @Autowired public MyEndpoint(MyService myService) { this.myService = myService; } @PayloadRoot(namespace = NAMESPACE_URI, localPart = "LookupSchoolRequest") public @ResponsePayload LookupSchoolResponse handleLookupSchoolRequest(@RequestPayload LookupSchoolRequest lookupSchoolRequest ) throws Exception { //TODO : Pass on username to service return myService.getLookupSchoolResponse(); } }
Now I want to pass the username into myService as it is used to determine what data is returned. So how do I do it?
Among things I tried
- I added a SoapHeader parameter to the handler method. It does not look possible to access the username token from SoapHeader. I streamed the soapHeader source into a String & saw nothing relating to the token.
Any help greatly appreciated, Thanks in advance.
Kevin


Reply With Quote
