You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by peng peng <pe...@gmail.com> on 2010/04/03 13:23:17 UTC

Failed to implement UsernameToken in Rampart.

Hi,

I am integrating axis2 , rampart and tomcat these days. I followed the
tutorial of http://wso2.org/library/240 , and i tried to implement the
client in eclipse3.4.

--service
public class SimpleService {

    public String echo(String arg) {
        return "Hello "+arg;
    }
}

--service.xml
<service name="SimpleService ">
 <operation name="echo">
  <messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
 </operation>
 <parameter name="ServiceClass"
locked="false">org.apache.rampart.samples.sample02.SimpleService</parameter>

 <module ref="rampart" />

 <parameter name="InflowSecurity">
      <action>
        <items>UsernameToken</items>

<passwordCallbackClass>org.apache.rampart.samples.sample02.PWCBHandler</passwordCallbackClass>
      </action>
    </parameter>
</service>


and i tried to get the message from a client using ADB.

--client

public static void main(String[] args) throws Exception {

 System.setProperty("javax.net.ssl.trustStore", "C:/Program Files/Apache
Software Foundation/Tomcat 6.0/mykey/tomcat.keystore");
 System.setProperty("javax.net.ssl.trustStorePassword", "tomcat");

// I used ant client.02 to generate the repository which include
/conf/axis2.xml and /modules/rampart-SNAPSHOT.mar
 String repository="C:/Documents and Settings/wenjund/My
Documents/erp/rampart-ut-samples/build/client_repositories/sample02";

 ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository,
repository + "/conf/axis2.xml");

  SimpleServiceStub stub = new SimpleServiceStub(ctx,"
https://localhost:8443/axis2/services/SimpleService");
  try {
   ServiceClient client = stub._getServiceClient();
   Options options = client.getOptions();
   options.setUserName("admin");
   options.setPassword("axis2");
   client.engageModule("rampart");
  } catch (Exception e1) {
   e1.printStackTrace();
  }

  String in="peng";
  String out=stub.echo(in);
  System.out.println("in="+in);
  System.out.println("out="+out);
}

When i ran the client in eclipse , an  error occur at

ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository,
repository + "/conf/axis2.xml");.

--error
 org.apache.axis2.deployment.DeploymentException: The "Dispatch" phase is
not found on the global "InFlow" phase of the axis2.xml file. Make sure the
phase is within the axis2.xml file.


I checked both the client and the server axis2.xml file and BOTH have the
<phaseOrder type="InFlow"> node which include a <phase name="Dispatch">
node.

Why i can use ant to get the service message but i can not get the message
from a client using eclipse? Any ideas, thanks.

I am new in the feild of axis2 and rampart , and if i sent a wrong email
address, please tell me. I attached the client axis2.xml here.

--client axis2.xml
<axisconfig name="AxisJava2.0">
 <module ref="rampart" />

 <parameter name="OutflowSecurity">
     <action>
         <items>UsernameToken</items>
         <user>bob</user>

 <passwordCallbackClass>org.apache.rampart.samples.sample02.PWCBHandler</passwordCallbackClass>
       </action>
    </parameter>

    <parameter name="hotdeployment" locked="false">true</parameter>
    <parameter name="hotupdate" locked="false">true</parameter>
    <messageReceiver mep="INOUT"
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    <transportSender name="http"
class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
        <parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
    </transportSender>
   <phaseOrder type="inflow">
        <!--  System pre defined phases       -->
         <phase name="Transport">
            <handler name="RequestURIBasedDispatcher"

class="org.apache.axis2.engine.RequestURIBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPActionBasedDispatcher"

class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
        </phase>
        <phase name="Security"/>
        <phase name="PreDispatch"/>
        <phase name="Dispatch"
class="org.apache.axis2.engine.DispatchPhase">
            <handler name="AddressingBasedDispatcher"

class="org.apache.axis2.engine.AddressingBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPMessageBodyBasedDispatcher"

class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="InstanceDispatcher"
                     class="org.apache.axis2.engine.InstanceDispatcher">
                <order phase="PostDispatch"/>
            </handler>
        </phase>
        <!--  System pre defined phases       -->
        <!--   After Postdispatch phase module author or or service author
can add any phase he want      -->
        <phase name="OperationInPhase"/>
    </phaseOrder>
    <phaseOrder type="outflow">
        <!--      user can add his own phases to this area  -->
        <phase name="OperationOutPhase"/>
        <!--system predefined phase-->
        <!--these phase will run irrespective of the service-->
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut"/>
    </phaseOrder>
    <phaseOrder type="INfaultflow">
        <phase name="PreDispatch"/>
        <phase name="Dispatch"
class="org.apache.axis2.engine.DispatchPhase">
            <handler name="RequestURIBasedDispatcher"

class="org.apache.axis2.engine.RequestURIBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPActionBasedDispatcher"

class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="AddressingBasedDispatcher"

class="org.apache.axis2.engine.AddressingBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPMessageBodyBasedDispatcher"

class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="InstanceDispatcher"
                     class="org.apache.axis2.engine.InstanceDispatcher">
                <order phase="PostDispatch"/>
            </handler>
        </phase>
        <!--      user can add his own phases to this area  -->
        <phase name="OperationInFaultPhase"/>
    </phaseOrder>
    <phaseOrder type="Outfaultflow">
        <!--      user can add his own phases to this area  -->
        <phase name="OperationOutFaultPhase"/>
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut"/>
    </phaseOrder>
</axisconfig>

Re: Failed to implement UsernameToken in Rampart.

Posted by Thilina Mahesh Buddhika <th...@gmail.com>.
Hi Jorge,

Yes. If you look at the published date of this tutorial, it is somewhere in
2006. So the required features and functionalities might be changed/removed
from Axis2/Rampart in the releases after the 2006. Also now it is not
recommended to configure security using inflow and outflow. Also we haven't
tested it in later Rampart releases.

The article I pointed in my previous reply[1] is based on the new security
configurations. So it should work out of the box.

As a resolution for the 'NoClassDefFoundError' you are getting, try adding
the 'com.springsource.edu.emory.mathcs.backport-3.1.0.jar' to your client's
classpath. You can download it from here [2].

Also please switch to latest Rampart release (Rampart 1.5) [3].

Thanks.
/thilina

[1] - http://wso2.org/library/3190
[2] -
http://ondex.rothamsted.bbsrc.ac.uk/nexus/content/groups/public/edu/emory/mathcs/backport/com.springsource.edu.emory.mathcs.backport/3.1.0/com.springsource.edu.emory.mathcs.backport-3.1.0.jar
[3] - http://ws.apache.org/rampart/download/1.5/download.cgi

Thilina Mahesh Buddhika
http://blog.thilinamb.com


On Mon, Apr 5, 2010 at 1:00 AM, Jorge Infante Osorio <jo...@uci.cu> wrote:

> I think the problem in this tutorial are not the tutorial, but the version
> of axis2 and rampart and the additional jars to use....as I say I used
> axis2
> 1.5.1 with rampart 1.4, and have some errors yet.
>
> The jars I use:
>
> axis2-mex-1.2.jar
> jaxen-1.1.1.jar
> opensaml-1.1.jar
> rampart-core-1.4.jar
> rampart-policy-1.4.jar
> rampart-trust-1.4.jar
> saxpath.jar
> wss4j-1.5.4.jar
> xmlsec-1.4.1.jar
> httpcore-4.0-alpha6.jar
> backport-util-concurrent.jar
>
> I miss any more??
>
> My error for now :
> Exception in thread "main" org.apache.axis2.AxisFault:
> java.lang.NoClassDefFoundError:
> edu/emory/mathcs/backport/java/util/concurrent/locks/ReadWriteLock
> at
>
> org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435
> )
> at
>
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAx
> isOperation.java:371)
> at
>
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperatio
> n.java:417)
> at
>
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisO
> peration.java:229)
> at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
> at
> tutorial.rampart.service.SecureServiceStub.add(SecureServiceStub.java:191)
> at
>
> tutorial.rampart.service.SecureServiceCGClient.main(SecureServiceCGClient.ja
> va:100)
>
> I follow http://blog.rampartfaq.com/2009/11/exception-in-thread-main.html
> but nothing change.
>
> Thanks Thilina for your help.
>
> Jorge
>
> -----Original Message-----
> From: Thilina Mahesh Buddhika [mailto:thilinamb@gmail.com]
> Sent: domingo, 04 de abril de 2010 12:40
> To: rampart-dev@ws.apache.org
> Subject: Re: Failed to implement UsernameToken in Rampart.
>
> Please try this tutorial.
>
> http://wso2.org/library/3190
>
> Thanks.
> /thilina
>
>
> Thilina Mahesh Buddhika
> http://blog.thilinamb.com
>
>
>
>

RE: Failed to implement UsernameToken in Rampart.

Posted by Jorge Infante Osorio <jo...@uci.cu>.
I think the problem in this tutorial are not the tutorial, but the version
of axis2 and rampart and the additional jars to use....as I say I used axis2
1.5.1 with rampart 1.4, and have some errors yet.

The jars I use:

axis2-mex-1.2.jar
jaxen-1.1.1.jar
opensaml-1.1.jar
rampart-core-1.4.jar
rampart-policy-1.4.jar
rampart-trust-1.4.jar
saxpath.jar
wss4j-1.5.4.jar
xmlsec-1.4.1.jar
httpcore-4.0-alpha6.jar
backport-util-concurrent.jar

I miss any more??

My error for now : 
Exception in thread "main" org.apache.axis2.AxisFault:
java.lang.NoClassDefFoundError:
edu/emory/mathcs/backport/java/util/concurrent/locks/ReadWriteLock
at
org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435
)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAx
isOperation.java:371)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperatio
n.java:417)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisO
peration.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at
tutorial.rampart.service.SecureServiceStub.add(SecureServiceStub.java:191)
at
tutorial.rampart.service.SecureServiceCGClient.main(SecureServiceCGClient.ja
va:100)

I follow http://blog.rampartfaq.com/2009/11/exception-in-thread-main.html
but nothing change.

Thanks Thilina for your help.

Jorge

-----Original Message-----
From: Thilina Mahesh Buddhika [mailto:thilinamb@gmail.com] 
Sent: domingo, 04 de abril de 2010 12:40
To: rampart-dev@ws.apache.org
Subject: Re: Failed to implement UsernameToken in Rampart.

Please try this tutorial.

http://wso2.org/library/3190

Thanks.
/thilina


Thilina Mahesh Buddhika
http://blog.thilinamb.com




Re: Failed to implement UsernameToken in Rampart.

Posted by Thilina Mahesh Buddhika <th...@gmail.com>.
Please try this tutorial.

http://wso2.org/library/3190

Thanks.
/thilina


Thilina Mahesh Buddhika
http://blog.thilinamb.com


On Sun, Apr 4, 2010 at 9:54 PM, Jorge Infante Osorio <jo...@uci.cu> wrote:

> I have errors with this tutorial too, using axis2 1.5.1 and rampart 1.4.
> Exist any problem with this two components to work together?
>
>
> Jorge.
>
> -----Original Message-----
> From: Thilina Mahesh Buddhika [mailto:thilinamb@gmail.com]
> Sent: domingo, 04 de abril de 2010 12:05
> To: rampart-dev@ws.apache.org
> Subject: Re: Failed to implement UsernameToken in Rampart.
>
> Hi Peng,
>
> Which versions of Axis2 and Rampart, are you using?
>
> Thanks.
> /thilina
>
> Thilina Mahesh Buddhika
> http://blog.thilinamb.com
>
>
> On Sat, Apr 3, 2010 at 4:53 PM, peng peng <pe...@gmail.com> wrote:
>
> > Hi,
> >
> > I am integrating axis2 , rampart and tomcat these days. I followed the
> > tutorial of http://wso2.org/library/240 , and i tried to implement the
> > client in eclipse3.4.
> >
>
>
>

RE: Failed to implement UsernameToken in Rampart.

Posted by Jorge Infante Osorio <jo...@uci.cu>.
I have errors with this tutorial too, using axis2 1.5.1 and rampart 1.4.
Exist any problem with this two components to work together?


Jorge.

-----Original Message-----
From: Thilina Mahesh Buddhika [mailto:thilinamb@gmail.com] 
Sent: domingo, 04 de abril de 2010 12:05
To: rampart-dev@ws.apache.org
Subject: Re: Failed to implement UsernameToken in Rampart.

Hi Peng,

Which versions of Axis2 and Rampart, are you using?

Thanks.
/thilina

Thilina Mahesh Buddhika
http://blog.thilinamb.com


On Sat, Apr 3, 2010 at 4:53 PM, peng peng <pe...@gmail.com> wrote:

> Hi,
>
> I am integrating axis2 , rampart and tomcat these days. I followed the 
> tutorial of http://wso2.org/library/240 , and i tried to implement the 
> client in eclipse3.4.
>



Re: Failed to implement UsernameToken in Rampart.

Posted by Thilina Mahesh Buddhika <th...@gmail.com>.
Hi Peng,

Which versions of Axis2 and Rampart, are you using?

Thanks.
/thilina

Thilina Mahesh Buddhika
http://blog.thilinamb.com


On Sat, Apr 3, 2010 at 4:53 PM, peng peng <pe...@gmail.com> wrote:

> Hi,
>
> I am integrating axis2 , rampart and tomcat these days. I followed the
> tutorial of http://wso2.org/library/240 , and i tried to implement the
> client in eclipse3.4.
>
> --service
> public class SimpleService {
>
>    public String echo(String arg) {
>        return "Hello "+arg;
>    }
> }
>
> --service.xml
> <service name="SimpleService ">
>  <operation name="echo">
>  <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>  </operation>
>  <parameter name="ServiceClass"
>
> locked="false">org.apache.rampart.samples.sample02.SimpleService</parameter>
>
>  <module ref="rampart" />
>
>  <parameter name="InflowSecurity">
>      <action>
>        <items>UsernameToken</items>
>
>
> <passwordCallbackClass>org.apache.rampart.samples.sample02.PWCBHandler</passwordCallbackClass>
>      </action>
>    </parameter>
> </service>
>
>
> and i tried to get the message from a client using ADB.
>
> --client
>
> public static void main(String[] args) throws Exception {
>
>  System.setProperty("javax.net.ssl.trustStore", "C:/Program Files/Apache
> Software Foundation/Tomcat 6.0/mykey/tomcat.keystore");
>  System.setProperty("javax.net.ssl.trustStorePassword", "tomcat");
>
> // I used ant client.02 to generate the repository which include
> /conf/axis2.xml and /modules/rampart-SNAPSHOT.mar
>  String repository="C:/Documents and Settings/wenjund/My
> Documents/erp/rampart-ut-samples/build/client_repositories/sample02";
>
>  ConfigurationContext ctx =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository,
> repository + "/conf/axis2.xml");
>
>  SimpleServiceStub stub = new SimpleServiceStub(ctx,"
> https://localhost:8443/axis2/services/SimpleService");
>  try {
>   ServiceClient client = stub._getServiceClient();
>   Options options = client.getOptions();
>   options.setUserName("admin");
>   options.setPassword("axis2");
>   client.engageModule("rampart");
>  } catch (Exception e1) {
>   e1.printStackTrace();
>  }
>
>  String in="peng";
>  String out=stub.echo(in);
>  System.out.println("in="+in);
>  System.out.println("out="+out);
> }
>
> When i ran the client in eclipse , an  error occur at
>
> ConfigurationContext ctx =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository,
> repository + "/conf/axis2.xml");.
>
> --error
>  org.apache.axis2.deployment.DeploymentException: The "Dispatch" phase is
> not found on the global "InFlow" phase of the axis2.xml file. Make sure the
> phase is within the axis2.xml file.
>
>
> I checked both the client and the server axis2.xml file and BOTH have the
> <phaseOrder type="InFlow"> node which include a <phase name="Dispatch">
> node.
>
> Why i can use ant to get the service message but i can not get the message
> from a client using eclipse? Any ideas, thanks.
>
> I am new in the feild of axis2 and rampart , and if i sent a wrong email
> address, please tell me. I attached the client axis2.xml here.
>
> --client axis2.xml
> <axisconfig name="AxisJava2.0">
>  <module ref="rampart" />
>
>  <parameter name="OutflowSecurity">
>     <action>
>         <items>UsernameToken</items>
>         <user>bob</user>
>
>
>  <passwordCallbackClass>org.apache.rampart.samples.sample02.PWCBHandler</passwordCallbackClass>
>       </action>
>    </parameter>
>
>    <parameter name="hotdeployment" locked="false">true</parameter>
>    <parameter name="hotupdate" locked="false">true</parameter>
>    <messageReceiver mep="INOUT"
> class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
>    <transportSender name="http"
> class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
>        <parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
>    </transportSender>
>   <phaseOrder type="inflow">
>        <!--  System pre defined phases       -->
>         <phase name="Transport">
>            <handler name="RequestURIBasedDispatcher"
>
> class="org.apache.axis2.engine.RequestURIBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="SOAPActionBasedDispatcher"
>
> class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>        </phase>
>        <phase name="Security"/>
>        <phase name="PreDispatch"/>
>        <phase name="Dispatch"
> class="org.apache.axis2.engine.DispatchPhase">
>            <handler name="AddressingBasedDispatcher"
>
> class="org.apache.axis2.engine.AddressingBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="SOAPMessageBodyBasedDispatcher"
>
> class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="InstanceDispatcher"
>                     class="org.apache.axis2.engine.InstanceDispatcher">
>                <order phase="PostDispatch"/>
>            </handler>
>        </phase>
>        <!--  System pre defined phases       -->
>        <!--   After Postdispatch phase module author or or service author
> can add any phase he want      -->
>        <phase name="OperationInPhase"/>
>    </phaseOrder>
>    <phaseOrder type="outflow">
>        <!--      user can add his own phases to this area  -->
>        <phase name="OperationOutPhase"/>
>        <!--system predefined phase-->
>        <!--these phase will run irrespective of the service-->
>        <phase name="PolicyDetermination"/>
>        <phase name="MessageOut"/>
>    </phaseOrder>
>    <phaseOrder type="INfaultflow">
>        <phase name="PreDispatch"/>
>        <phase name="Dispatch"
> class="org.apache.axis2.engine.DispatchPhase">
>            <handler name="RequestURIBasedDispatcher"
>
> class="org.apache.axis2.engine.RequestURIBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="SOAPActionBasedDispatcher"
>
> class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="AddressingBasedDispatcher"
>
> class="org.apache.axis2.engine.AddressingBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="SOAPMessageBodyBasedDispatcher"
>
> class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
>                <order phase="Dispatch"/>
>            </handler>
>            <handler name="InstanceDispatcher"
>                     class="org.apache.axis2.engine.InstanceDispatcher">
>                <order phase="PostDispatch"/>
>            </handler>
>        </phase>
>        <!--      user can add his own phases to this area  -->
>        <phase name="OperationInFaultPhase"/>
>    </phaseOrder>
>    <phaseOrder type="Outfaultflow">
>        <!--      user can add his own phases to this area  -->
>        <phase name="OperationOutFaultPhase"/>
>        <phase name="PolicyDetermination"/>
>        <phase name="MessageOut"/>
>    </phaseOrder>
> </axisconfig>
>