Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8284669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:11:28+00:00 2026-06-08T11:11:28+00:00

I have Axis2 web services running in an Application Server (like JBoss, WebSphere and

  • 0

I have Axis2 web services running in an Application Server (like JBoss, WebSphere and Weblogic) and till now I am passing the user details within a request and authenticating the user before processing it.

The next step is that I want to delegate the authentication bit to the Java EE Application Server and once authenticated the application server should pass the UserPrinciple which I will be using as context to execute the request.

I am not sure if I have asked the question correctly? I think I am mixing the WebContainer authentication with WS-Security stuff.

Can anyone please point me to the right direction with some documentation which I can refer as start-up guide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:11:31+00:00Added an answer on June 8, 2026 at 11:11 am

    OK, I have tried a solution and it worked to some extent. Here are details;

    Created TestService with following services.xml

    <serviceGroup>
        <service name="TestWebService" scope="application" targetNamespace="http://TestServiceWs"> 
            <schema schemaNamespace="http://TestServiceWs"/>
            <description>Test POJO Axis2 AAR deployment</description>
            <parameter name="ServiceClass">test.TestServiceWS</parameter>
            <messageReceivers>
                <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
                <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
            </messageReceivers>
        </service>
    
        <module ref="rampart" />
    
        <parameter name="InflowSecurity">
          <action>
            <items>UsernameToken Timestamp</items>
            <passwordCallbackClass>test.PWHandlerServer</passwordCallbackClass>
          </action>
        </parameter>
    </serviceGroup>
    

    Implemented PWHandlerServer.java

    package test;
    
    import java.io.IOException;
    
    import javax.security.auth.callback.Callback;
    import javax.security.auth.callback.CallbackHandler;
    import javax.security.auth.callback.UnsupportedCallbackException;
    
    import org.apache.ws.security.WSPasswordCallback;
    
    public class PWHandlerServer implements CallbackHandler {
    
        // the username and password we expect incoming WS calls to use
        private String user = "wsuser";
        private String pwd = "wspwd";
    
        public void handle (Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
                if (callbacks[i] instanceof WSPasswordCallback) {
                    WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
                    System.out.println("identifier: "+pc.getIdentifer()+", usage: "+pc.getUsage());
    
                    if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
                        // for passwords sent in digest mode we need to provide the password,
                        // because the original one can't be un-digested from the message
    
                        // we can throw either of the two Exception types if authentication fails
                        if (! user.equals(pc.getIdentifer()))
                            throw new IOException("unknown user: "+pc.getIdentifer());
    
                        // this will throw an exception if the passwords don't match
                        pc.setPassword(pwd);
    
                    } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
                        // for passwords sent in cleartext mode we can compare passwords directly
    
                        if (! user.equals(pc.getIdentifer()))
                            throw new IOException("unknown user: "+pc.getIdentifer());
    
                        // we can throw either of the two Exception types if authentication fails
                        if (! pwd.equals(pc.getPassword()))
                            throw new IOException("password incorrect for user: "+pc.getIdentifer());
                    }
                    // If everything is OK then set the context and move on
                    TestRequestContext ctx = new TestRequestContext(pc.getIdentifer());
                    TestRequestContext.setRequestContext(ctx);
    
                } else {
                    throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
                }
            }
        }
    }
    

    Implemented TestRequestContext

    package test;
    
    
    class TestRequestContext {
        private final static ThreadLocal<TestRequestContext> currentContext = new ThreadLocal<TestRequestContext>();
    
        public static void setRequestContext(TestRequestContext context) {
            currentContext.set(context);
        }
    
        public static TestRequestContext getRequestContext() {
            return currentContext.get();
        }
    
        public static void clearRequestContext() {
            currentContext.remove();
        }
    
        private String userPrincipal;
    
        public TestRequestContext(String principal) {
            this.userPrincipal = principal;
        }
    
        public String getUserPrincipal(){
            return this.userPrincipal;
        }
    }
    

    Now I should be able to access my TestRequestContext.getUserPricipal() in my web service class and pass it on DB for transaction and switching a security context. The only problem is when I am trying to access the service via SoapUI its giving me following exception;

        15:07:34,924 INFO  [STDOUT] identifier: wsuser, usage: 5
    15:08:48,081 INFO  [STDOUT] [ERROR] WSDoAllReceiver: security processing failed (actions mismatch)
    org.apache.axis2.AxisFault: WSDoAllReceiver: security processing failed (actions mismatch)
            at org.apache.rampart.handler.WSDoAllReceiver.processBasic(WSDoAllReceiver.java:344)
            at org.apache.rampart.handler.WSDoAllReceiver.processMessage(WSDoAllReceiver.java:86)
            at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
            at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
            at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
            at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160)
            at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
            at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
            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:182)
            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:619)
    

    Within SoapUI, I am simply using ‘Auth’ tab to set username and password and invoke? do I need to setup anything else before invocation.

    Also, the approach to use ThreadLocal is correct or I can access the principle some otherway as well?

    Thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an echo web service running on lets say http://localhost:8080/axis2/services/Service1 . This service
I have two servlets that access two corresponding Axis2 web services on the same
Could someone help me on this, I have created simple web services using axis2
Is it possible to achive each of axis2 web services have own log file
I have created an Axis web service as a Java 6 application running on
I have a web application running on port :80, and I have an Axis
I have an application that is using Apache CXF to communicate with Axis2 web
I have web services running on GlassFish, but when I try to call WS
I'm going to develope an application based on web services (axis2) and android (clients).
I have a problem deploying an Axis 2 web application. I'm using Jboss 4.2.0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.