2009/12/16 Björn Krüger <krue...@tyntec.com>

> Hi,
> i have an issue getting the basic http authentification username and
> password in the service skeleton of my webservice.
>
> I try to resolve them via the MessageContext. The Code looks like this:
>
>
> MessageContext msgContext = MessageContext.getCurrentMessageContext();
>
> HttpTransportProperties.Authenticator authenticator =
> (HttpTransportProperties.Authenticator)
> msgContext.getOptions().getProperty(HTTPConstants.AUTHENTICATE);
>                if (authenticator != null){
>                        user = authenticator.getUsername();
>                        password = authenticator.getPassword();
>                }
>
> What am i doing wrong? The client is definitly sending the
> authentifaction  data.
>

try this.

HttpServletRequest httpRequest = (HttpServletRequest)
msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
        httpRequest.getUserPrincipal().getName();

you want be able to get the password. but this should work.

thanks,
Amila.

>
> Help would be welcome.
>
> Thanks.
>
> Björn Krüger
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Reply via email to