axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Takashi Saruhashi" <TSaruha...@valueprice.eu>
Subject RE: [Axis2] How can I get Authentication information from WebService in AXIS2
Date Tue, 27 May 2008 10:55:17 GMT
Hi Keith,

Thanks for replying again. Actually, I debugged and found out this part is null.

---
((WSSecurityEngineResult)((WSHandlerResult)results.get(0)).getResults().get(1))
---

As I already said in my first email, I set authentication information using ServiceClient
from 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");
===

I need to change the way to set Authentication Information from Client side??


Many Thanks.
Takashi




________________________________________
From: keith chapman [mailto:keithgchapman@gmail.com] 
Sent: Tuesday, May 27, 2008 11:34 AM
To: axis-dev@ws.apache.org
Subject: Re: [Axis2] How can I get Authentication information from WebService in AXIS2

Hi Takashi,

The code I gave you is for Axis2 and not Axis1. This code will work for a service thats secured
using username Token scenario. The code snippet I gave you was taken from [1] which is an
admin service in the WSO2 Mashup Server which is secured using username token scenario.

Can you try debugging your service to check what exactly is null and also check weather your
service is really secured using username token scenario (These results that we retrive in
the service is set into the Message Context by Rampart when it processors the security header).
Also this code applies for Axis2 1.4.

Thanks,
Keith.

[1] https://svn.wso2.org/repos/wso2/trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceUT.java
On Tue, May 27, 2008 at 2:51 PM, Takashi Saruhashi <TSaruhashi@valueprice.eu> wrote:
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....

java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
       at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
       at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
       at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
       at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
       at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NullPointerException
       at services.PriceService.getPrice(PriceService.java:103)
       ... 31 more


________________________________________
From: keith chapman [mailto:keithgchapman@gmail.com]
Sent: Tuesday, May 27, 2008 4:10 AM
To: axis-dev@ws.apache.org
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
                .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



-- 
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