Okay, I discovered how to do this. Part of the problem was that my BASIC authentication
via DatabaseServerLoginModule was not working properly.
Ignoring the authentication problem, once you have authentication working then the
following code should work:
| import javax.xml.ws.WebServiceContext;
| import javax.xml.ws.handler.MessageContext;
| import javax.servlet.http.HttpServletRequest;
| import java.security.Principal;
| ...
|
| @Stateless
| @Remote(SubscriberServices.class)
| @WebService(
| name = "SubscriberWS",
| endpointInterface =
"com.cei.crunch.server.ws.SubscriberServices.SubscriberServicesEndpoint"
| )
| @SOAPBinding(style = SOAPBinding.Style.RPC)
|
| public class SubscriberServices implements SubscriberServicesEndpoint {
|
| @Resource
| WebServiceContext wsContext;
|
| private Subscriber getUserInfo() throws CrunchWSException {
|
| MessageContext msgContext = wsContext.getMessageContext();
| HttpServletRequest servletRequest = (HttpServletRequest)
msgContext.get(MessageContext.SERVLET_REQUEST);
| Principal p = servletRequest.getUserPrincipal();
| String username = p.getName();
| ....
|
Alternatively:
| ...
| MessageContext msgContext = wsContext.getMessageContext();
| HttpServletRequest servletRequest = (HttpServletRequest)
msgContext.get(MessageContext.SERVLET_REQUEST);
| String username = servletRequest.getRemoteUser();
| ...
Either method appears to work.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123148#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...