You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/10/27 07:06:06 UTC

svn commit: r468274 - in /webservices/axis2/branches/java/1_1/modules/samples/security/policy: ./ sample01/ sample01/src/ sample01/src/org/ sample01/src/org/apache/ sample01/src/org/apache/rampart/ sample01/src/org/apache/rampart/samples/ sample01/src/...

Author: ruchithf
Date: Thu Oct 26 22:06:05 2006
New Revision: 468274

URL: http://svn.apache.org/viewvc?view=rev&rev=468274
Log:
Added security policy sample1; UsernameToken

Added:
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/build.xml
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/README.txt
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/policy.xml
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/services.xml
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/Client.java
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/PWCBHandler.java
    webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/SimpleService.java

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/build.xml?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/build.xml (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/build.xml Thu Oct 26 22:06:05 2006
@@ -0,0 +1,240 @@
+<project basedir="." default="clean">
+
+	<property name="service.repos.dir" value="build/service_repositories"/>
+	<property name="client.repos.dir" value="build/client_repositories"/>
+	<property name="temp.dir" value="build/temp"/>
+	<property name="keys.dir" value="../keys"/>
+	<property name="temp.client.dir" value="build/temp_client"/>
+	
+	<property name="addressing.mar" value="addressing-1.1-SNAPSHOT.mar"/>
+	<property name="rampart.mar" value="rampart-1.1-SNAPSHOT.mar"/>	
+	
+	<property name="client.port" value="9080"/>
+	<property name="server.port" value="8080"/>
+	
+	<property name="sample.services.url" value="http://localhost:${client.port}/axis2/services"/>
+	
+    <property environment="env"/>
+    	
+	<target name="check.dependency" unless="env.AXIS2_HOME">
+        <echo message="AXIS2_HOME must be set"/>
+    </target>
+	
+	<!-- Sample Service 01 -->
+	<target name="service.01" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="01"/>
+	</target>
+
+	<!-- Sample Client 01 -->
+	<target name="client.01" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="01"/>
+	</target>
+	
+	<!-- Sample Service 02 -->
+	<target name="service.02" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="02"/>
+	</target>
+
+	<!-- Sample Client 01 -->
+	<target name="client.02" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="02"/>
+	</target>
+
+	<!-- Sample Service 03 -->
+	<target name="service.03" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="03"/>
+	</target>
+
+	<!-- Sample Client 01 -->
+	<target name="client.03" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="03"/>
+	</target>
+
+	<!-- Sample Service 04 -->
+	<target name="service.04" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="04"/>
+	</target>
+
+	<!-- Sample Client 04 -->
+	<target name="client.04" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="04"/>
+	</target>
+
+	<!-- Sample Service 05 -->
+	<target name="service.05" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="05"/>
+	</target>
+
+	<!-- Sample Client 05 -->
+	<target name="client.05" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="05"/>
+	</target>
+	
+	<!-- Sample Service 06 -->
+	<target name="service.06" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="06"/>
+	</target>
+
+	<!-- Sample Client 06 -->
+	<target name="client.06" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="06"/>
+	</target>
+	
+	<!-- Sample Service 07 -->
+	<target name="service.07" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="07"/>
+	</target>
+
+	<!-- Sample Client 07 -->
+	<target name="client.07" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="07"/>
+	</target>
+
+	<!-- Sample Service 08 -->
+	<target name="service.08" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="08"/>
+	</target>
+
+	<!-- Sample Client 08 -->
+	<target name="client.08" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="08"/>
+	</target>
+
+	<!-- Sample Service 09 -->
+	<target name="service.09" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="09"/>
+	</target>
+
+	<!-- Sample Client 09 -->
+	<target name="client.09" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="09"/>
+	</target>
+
+	<!-- Sample Service 10 -->
+	<target name="service.10" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="10"/>
+	</target>
+
+	<!-- Sample Client 10 -->
+	<target name="client.10" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="10"/>
+	</target>
+	
+	<!-- Sample Service 11 -->
+	<target name="service.11" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.service.repo sample.number="11"/>
+	</target>
+
+	<!-- Sample Client 11 -->
+	<target name="client.11" if="env.AXIS2_HOME" depends="check.dependency">
+		<create.and.run.client sample.number="11"/>
+	</target>
+	
+	
+	<target name="clean">
+		<delete dir="build" />
+	</target>
+	
+	<!-- Macro to create a service repo for a given sample -->
+	<macrodef name="create.service.repo">
+	   	<attribute name="sample.number" default="sample"/>
+	   	<sequential>
+	   		
+	   		<property name="modules.dir" value="${env.AXIS2_HOME}/repository/modules/"/>
+	   		<property name="lib.dir" value="${env.AXIS2_HOME}/lib"/>
+	   		
+	   		<mkdir dir="${service.repos.dir}/sample@{sample.number}"/>
+	   		<mkdir dir="${service.repos.dir}/sample@{sample.number}/services"/>
+	   		<mkdir dir="${service.repos.dir}/sample@{sample.number}/modules"/>
+	   		
+	   		<!-- copy modules -->
+	   		<copy file="${modules.dir}/${addressing.mar}" tofile="${service.repos.dir}/sample@{sample.number}/modules/${addressing.mar}" overwrite="true"/>
+	   		<copy file="${modules.dir}/${rampart.mar}" tofile="${service.repos.dir}/sample@{sample.number}/modules/${rampart.mar}" overwrite="true"/>
+	   		
+	   		<!-- create service -->
+	   		<mkdir dir="${temp.dir}"/>
+	   		<mkdir dir="${temp.dir}/META-INF"/>
+	   		
+	   		<!-- Compile service -->
+            <javac srcdir="sample@{sample.number}/src" destdir="${temp.dir}">
+                    <classpath>
+                            <fileset dir="${lib.dir}">
+                                    <include name="**/*.jar"/>
+                            </fileset>
+                    </classpath>
+                    <exclude name="**/Client.java"/>
+            </javac>
+	   		
+	   		<copy file="sample@{sample.number}/services.xml" tofile="${temp.dir}/META-INF/services.xml" overwrite="true"/>
+	   		<copy file="${keys.dir}/service.jks" tofile="${temp.dir}/service.jks" overwrite="true"/>
+	   		<copy file="${keys.dir}/service.properties" tofile="${temp.dir}/service.properties" overwrite="true"/>
+
+	   		<jar destfile="${service.repos.dir}/sample@{sample.number}/services/sample@{sample.number}.aar">
+				<fileset dir="${temp.dir}"></fileset>
+			</jar>
+	   		
+			<delete dir="${temp.dir}" />
+	   		<!-- start SimpleHTTPserver -->
+            <java classname="org.apache.axis2.transport.http.SimpleHTTPServer" fork="true">
+                    <arg value="${service.repos.dir}/sample@{sample.number}"/>
+                    <arg value="-p${server.port}"/>
+                    <classpath>
+                            <fileset dir="${lib.dir}">
+                                    <include name="**/*.jar"/>
+                            </fileset>
+                    </classpath>
+            </java>
+
+	   </sequential>
+	</macrodef>
+
+	<macrodef name="create.and.run.client">
+	   	<attribute name="sample.number" default="sample"/>
+	   	<sequential>
+	   		
+	   		<property name="modules.dir" value="${env.AXIS2_HOME}/repository/modules/"/>
+	   		<property name="lib.dir" value="${env.AXIS2_HOME}/lib"/>
+	   		
+	   		<!-- Create the client repo -->
+	   		<mkdir dir="${client.repos.dir}/sample@{sample.number}"/>
+	   		<mkdir dir="${client.repos.dir}/sample@{sample.number}/conf"/>
+	   		<mkdir dir="${client.repos.dir}/sample@{sample.number}/modules"/>
+	   		
+	   		<!-- copy modules -->
+	   		<copy file="${modules.dir}/${addressing.mar}" tofile="${client.repos.dir}/sample@{sample.number}/modules/${addressing.mar}" overwrite="true"/>
+	   		<copy file="${modules.dir}/${rampart.mar}" tofile="${client.repos.dir}/sample@{sample.number}/modules/${rampart.mar}" overwrite="true"/>
+	   		
+	   		<mkdir dir="${temp.client.dir}"/>
+	   		
+	   		<!-- Compile client -->
+            <javac srcdir="sample@{sample.number}/src" destdir="${temp.client.dir}">
+                    <classpath>
+	                    <fileset dir="${lib.dir}">
+                            <include name="**/*.jar"/>
+	                    </fileset>
+                    </classpath>
+                    <exclude name="**/SimpleService.java"/>
+            </javac>
+
+	   		<copy file="${keys.dir}/client.jks" tofile="${temp.client.dir}/client.jks" overwrite="true"/>
+	   		<copy file="${keys.dir}/client.properties" tofile="${temp.client.dir}/client.properties" overwrite="true"/>
+
+	   		
+	   		<!-- Run client -->
+            <java classname="org.apache.rampart.samples.policy.sample@{sample.number}.Client" fork="true">
+                    <arg value="${sample.services.url}/sample@{sample.number}"/>
+                    <arg value="${client.repos.dir}/sample@{sample.number}"/>
+                    <arg value="sample@{sample.number}/policy.xml"/>
+                    <classpath>
+                        <fileset dir="${lib.dir}">
+                        	<include name="**/*.jar"/>
+                        </fileset>
+                  		<dirset dir="${temp.client.dir}" />
+                    </classpath>
+            </java>
+
+<!--	   		<delete dir="${temp.client.dir}"/> -->
+		</sequential>		
+	</macrodef>
+
+</project>

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/README.txt?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/README.txt (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/README.txt Thu Oct 26 22:06:05 2006
@@ -0,0 +1,6 @@
+Rampart Engaged and no configuration
+
+This sample shows that Apache Rampart does not work on the messages when simply
+engagd without any configuration
+
+Note: <module ref="rampart"/> in both client.axis2.xml and services.xml
\ No newline at end of file

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/policy.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/policy.xml?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/policy.xml (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/policy.xml Thu Oct 26 22:06:05 2006
@@ -0,0 +1,37 @@
+<wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+	<wsp:ExactlyOne>
+	  <wsp:All>
+		<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+		  <wsp:Policy>
+			<sp:TransportToken>
+			  <wsp:Policy>
+				<sp:HttpsToken RequireClientCertificate="false"/>
+			  </wsp:Policy>
+			</sp:TransportToken>
+			<sp:AlgorithmSuite>
+			  <wsp:Policy>
+				<sp:Basic256/>
+			  </wsp:Policy>
+			</sp:AlgorithmSuite>
+			<sp:Layout>
+			  <wsp:Policy>
+				<sp:Lax/>
+			  </wsp:Policy>
+			</sp:Layout>
+			<sp:IncludeTimestamp/>
+		  </wsp:Policy>
+		</sp:TransportBinding>
+		<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+			<wsp:Policy>
+				<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" />
+		  </wsp:Policy>
+		</sp:SignedSupportingTokens>
+		
+		<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> 
+			<ramp:user>alice</ramp:user>
+			<ramp:passwordCallbackClass>org.apache.rampart.samples.policy.sample01.PWCBHandler</ramp:passwordCallbackClass>
+		</ramp:RampartConfig>
+		
+	  </wsp:All>
+	</wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/services.xml?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/services.xml (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/services.xml Thu Oct 26 22:06:05 2006
@@ -0,0 +1,48 @@
+<!-- services.xml of sample-1 : No Security-->
+<service>
+	<operation name="echo">
+		<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+	</operation>    
+	<parameter name="ServiceClass" locked="false">org.apache.rampart.samples.policy.sample01.SimpleService</parameter>
+	
+	<module ref="rampart" />
+	<module ref="addressing" />
+
+	<wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+		<wsp:ExactlyOne>
+		  <wsp:All>
+			<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+			  <wsp:Policy>
+				<sp:TransportToken>
+				  <wsp:Policy>
+					<sp:HttpsToken RequireClientCertificate="false"/>
+				  </wsp:Policy>
+				</sp:TransportToken>
+				<sp:AlgorithmSuite>
+				  <wsp:Policy>
+					<sp:Basic256/>
+				  </wsp:Policy>
+				</sp:AlgorithmSuite>
+				<sp:Layout>
+				  <wsp:Policy>
+					<sp:Lax/>
+				  </wsp:Policy>
+				</sp:Layout>
+				<sp:IncludeTimestamp/>
+			  </wsp:Policy>
+			</sp:TransportBinding>
+			<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+				<wsp:Policy>
+					<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" />
+			  </wsp:Policy>
+			</sp:SignedSupportingTokens>
+			
+			<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> 
+				<ramp:passwordCallbackClass>org.apache.rampart.samples.policy.sample01.PWCBHandler</ramp:passwordCallbackClass>
+			</ramp:RampartConfig>
+			
+		  </wsp:All>
+		</wsp:ExactlyOne>
+	</wsp:Policy>
+
+</service>

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/Client.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/Client.java?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/Client.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/Client.java Thu Oct 26 22:06:05 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rampart.samples.policy.sample01;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.rampart.RampartMessageData;
+
+import javax.xml.namespace.QName;
+
+public class Client {
+
+    public static void main(String[] args) throws Exception {
+        
+        if(args.length != 3) {
+            System.out.println("Usage: $java Client endpoint_address client_repo_path policy_xml_path");
+        }
+        
+        ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], null);
+        
+        ServiceClient client = new ServiceClient(ctx, null);
+        Options options = new Options();
+        options.setAction("urn:echo");
+        options.setTo(new EndpointReference(args[0]));
+        options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,  loadPolicy(args[2]));
+        client.setOptions(options);
+        
+        client.engageModule(new QName("addressing"));
+        client.engageModule(new QName("rampart"));
+        
+        OMElement response = client.sendReceive(getPayload("Hello world"));
+        
+        System.out.println(response);
+        
+    }
+    
+    private static Policy loadPolicy(String xmlPath) throws Exception {
+        StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+        return PolicyEngine.getPolicy(builder.getDocumentElement());
+    }
+    
+    private static OMElement getPayload(String value) {
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMNamespace ns = factory.createOMNamespace("http://sample01.policy.samples.rampart.apache.org/xsd","ns1");
+        OMElement elem = factory.createOMElement("echo", ns);
+        OMElement childElem = factory.createOMElement("param0", null);
+        childElem.setText(value);
+        elem.addChild(childElem);
+        
+        return elem;
+    }
+    
+}

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/PWCBHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/PWCBHandler.java?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/PWCBHandler.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/PWCBHandler.java Thu Oct 26 22:06:05 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rampart.samples.policy.sample01;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import java.io.IOException;
+
+public class PWCBHandler implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            
+            //When the server side need to authenticate the user
+            WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+            if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
+                if(pwcb.getIdentifer().equals("bob") && pwcb.getPassword().equals("bobPW")) {
+                    return;
+                } else {
+                    throw new UnsupportedCallbackException(callbacks[i], "check failed");
+                }
+            }
+            
+            //When the client requests for the password to be added in to the 
+            //UT element
+            pwcb.setPassword("bobPW");
+        }
+    }
+
+}

Added: webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/SimpleService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/SimpleService.java?view=auto&rev=468274
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/SimpleService.java (added)
+++ webservices/axis2/branches/java/1_1/modules/samples/security/policy/sample01/src/org/apache/rampart/samples/policy/sample01/SimpleService.java Thu Oct 26 22:06:05 2006
@@ -0,0 +1,24 @@
+/*
+ * Copyright  2003-2005 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.rampart.samples.policy.sample01;
+
+public class SimpleService {
+    
+    public String echo(String arg) {
+        return arg;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org