axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Takashi Saruhashi" <>
Subject RE: [Axis2] How can I get Authentication information from WebService in AXIS2
Date Tue, 27 May 2008 09:21:27 GMT
Hello Keith,

Thanks for your reply!!  I tried your way in your previous email.
However, it seems it doesn't work....

Is this really suitable for AXIS2 also?? I think the way you showed me is for AXIS1.
Could you tell me the web site describing how to fetch Authentication information if possible??

Instead of getting username, I got NPE....

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(
	at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(
	at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(
	at org.apache.axis2.receivers.AbstractMessageReceiver.receive(
	at org.apache.axis2.engine.AxisEngine.receive(
	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(
	at org.apache.axis2.transport.http.AxisServlet.doPost(
	at javax.servlet.http.HttpServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Caused by: java.lang.NullPointerException
	at services.PriceService.getPrice(
	... 31 more

From: keith chapman [] 
Sent: Tuesday, May 27, 2008 4:10 AM
Subject: Re: [Axis2] How can I get Authentication information from WebService in AXIS2

Hi Takashi,

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

MessageContext msgCtx = MessageContext.getCurrentMessageContext();

Vector results = (Vector) msgCtx

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

2008/5/26 Takashi Saruhashi <>:
 Hello all,

Currently, I don't know how to get Authentication information (username) from WebService in

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();

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,

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


To unsubscribe, e-mail:
For additional commands, e-mail:

Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.

View raw message