axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "keith chapman" <keithgchap...@gmail.com>
Subject Re: [Axis2] How can I get Authentication information from WebService in AXIS2
Date Tue, 27 May 2008 02:10:27 GMT
Hi Takashi,

You can get the username in this manner in your service.

MessageContext msgCtx = MessageContext.getCurrentMessageContext();

Vector results = (Vector) msgCtx
                .getProperty(WSHandlerConstants.RECV_RESULTS);

String username =
((WSSecurityEngineResult)((WSHandlerResult)results.get(0)).getResults().get(1)).getPrincipal().getName();

Thanks,
Keith.

2008/5/26 Takashi Saruhashi <TSaruhashi@valueprice.eu>:

>  Hello all,
>
> Currently, I don't know how to get Authentication information (username)
> from WebService in AXIS2.
>
> I set Authentication information to WebService Client like this,
>
> ===
> // Define client to access to the Web Service.
> ServiceClient sc = stub._getServiceClient();
>
> // Engage modules for the authentication sc.engageModule("rampart");
>
> // Set Options for authentication purpose.
> Options options = sc.getOptions();
> options.setUserName("Test");
> options.setPassword("test");
> ===
>
> Those Authentication information is sent to Password Callback Class from
> Client.
> I think this one is using JAAS.
>
> Is it possible to get Authentication information(username) from WebService
> in AXIS2??
>
> If I'm right, in case of AXIS1, I can fetch the value using "
> SimpleAuthenticationHandler " like this,
>
> ===
> org.apache.axis.handlers.SimpleAuthenticationHandler
> public class SimpleAuthenticationHandler extends BasicHandler {
>
>  public void invoke(MessageContext msgContext) throws AxisFault {
>    SecurityProvider provider =
> (SecurityProvider)msgContext.getProperty("securityProvider");
>    if (provider != null) {
>      String  userID = msgContext.getUsername();
>      if ( userID == null || userID.equals(""))
> throw new AxisFault( "Server.Unauthenticated",........);
>      String passwd = msgContext.getPassword();
>      AuthenticatedUser authUser = provider.authenticate(msgContext);
>      if ( authUser == null)
>                    throw new AxisFault( "Server.Unauthenticated",........);
>      msgContext.setProperty(MessageContext.AUTHUSER, authUser);
>    }
> }
> };
> ===
>
>
> However, in case of AXIS2, I can't find any Class like this for fetching
> Authentication Information.
> Does someone know the way to fetch Authentication information in AXIS2??
> Any suggestions are quite appreciated.
>
>
> May Tnanks
>
> Takashi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

Mime
View raw message