Author: saminda
Date: Fri Jun  6 13:52:33 2008
New Revision: 18093
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18093

Log:
Added patch from Ruchith 


Added:
   branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/
   branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/client.jks   
(contents, props changed)
   branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/service.jks  
 (contents, props changed)
Modified:
   branches/wsas/java/2.3/wsas/modules/distribution/pom.xml
   branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/pom.xml
   
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/src/org/wso2/wsas/sample/commodityquote/client/Client.java

Modified: branches/wsas/java/2.3/wsas/modules/distribution/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/wsas/modules/distribution/pom.xml?rev=18093&r1=18092&r2=18093&view=diff
==============================================================================
--- branches/wsas/java/2.3/wsas/modules/distribution/pom.xml    (original)
+++ branches/wsas/java/2.3/wsas/modules/distribution/pom.xml    Fri Jun  6 
13:52:33 2008
@@ -445,8 +445,9 @@
                                         <exclude 
name="**/default_epr*.properties"/>
                                     </fileset>
                                 </copy>
+                                <!-- TODO -->
                                 <copy 
todir="${dist.temp.dir}/samples/CommodityQuote/keys">
-                                    <fileset 
dir="../samples/CommodityQuote/target/keys"/>
+                                    <fileset 
dir="../samples/CommodityQuote/keys"/>
                                 </copy>
 
                                 <!-- Coping to main www stuff to Chad folder 
-->

Added: 
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/client.jks
URL: 
http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/client.jks?pathrev=18093
==============================================================================
Binary file. No diff available.

Added: 
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/service.jks
URL: 
http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/keys/service.jks?pathrev=18093
==============================================================================
Binary file. No diff available.

Modified: branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/pom.xml?rev=18093&r1=18092&r2=18093&view=diff
==============================================================================
--- branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/pom.xml  
(original)
+++ branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/pom.xml  Fri Jun 
 6 13:52:33 2008
@@ -63,7 +63,7 @@
                                     <classpath 
refid="maven.runtime.classpath"/>
                                 </java>
                                 <!-- Generate keys for the samples -->
-                                <mkdir dir="${keys.dir}"/>
+                                <!--<mkdir dir="${keys.dir}"/>
                                 <genkey alias="client" storepass="testing" 
keyalg="RSA"
                                         keystore="${keys.dir}/client.jks"
                                         validity="99999">
@@ -104,7 +104,7 @@
                                     <classpath 
refid="maven.dependency.classpath"/>
                                     <classpath 
refid="maven.compile.classpath"/>
                                     <classpath 
refid="maven.runtime.classpath"/>
-                                </java>
+                                </java>-->
                             </tasks>
                         </configuration>
                         <goals>

Modified: 
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/src/org/wso2/wsas/sample/commodityquote/client/Client.java
URL: 
http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/src/org/wso2/wsas/sample/commodityquote/client/Client.java?rev=18093&r1=18092&r2=18093&view=diff
==============================================================================
--- 
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/src/org/wso2/wsas/sample/commodityquote/client/Client.java
       (original)
+++ 
branches/wsas/java/2.3/wsas/modules/samples/CommodityQuote/src/org/wso2/wsas/sample/commodityquote/client/Client.java
       Fri Jun  6 13:52:33 2008
@@ -40,10 +40,6 @@
 import org.wso2.utils.NetworkUtils;
 import org.wso2.wsas.security.WSS4JUtil;
 import org.wso2.www.types.client.*;
-import org.wso2.mercury.callback.MercuryErrorCallback;
-import org.wso2.mercury.exception.RMException;
-import org.wso2.mercury.util.MercuryClientConstants;
-import org.wso2.mercury.client.MercuryClient;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -64,7 +60,7 @@
     private static final String INVOCATION_TYPE_ASYNC = "async";
     private static final String INVOCATION_TYPE_SYNC = "sync";
     private static final String MODULE_SECURITY = "rampart";
-    private static final String MODULE_RM = "Mercury";
+    private static final String MODULE_RM = "sandesha2";
     private static String invocationType = null;
     private static String qosValue = null;
 
@@ -303,19 +299,27 @@
         }
     }
 
-
     private void configureRM() throws AxisFault, IOException {
-        stub._getServiceClient().engageModule(MODULE_RM);
-        
stub._getServiceClient().engageModule(org.apache.axis2.Constants.MODULE_ADDRESSING);
+        stub._getServiceClient().engageModule(new QName(MODULE_RM));
+        stub._getServiceClient().engageModule(new QName(
+                org.apache.axis2.Constants.MODULE_ADDRESSING));
 
         Options clientOptions = stub._getServiceClient().getOptions();
-        clientOptions.setUseSeparateListener(true);
 
-        clientOptions.setProperty(MercuryClientConstants.ERROR_CALLBACK,
-                                  new MercuryErrorCallbackImpl());
-        MercuryClient mercuryClient = new 
MercuryClient(stub._getServiceClient());
-        mercuryClient.setRMSSequenceRetransmitTime(5000);
 
+        String sequenceKey = UUIDGenerator.getUUID();  //sequence key for thie 
sequence.
+        clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY, 
sequenceKey);
+
+        clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER,
+                                  new SandeshaListenerImpl());
+
+        clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        clientOptions.setUseSeparateListener(true);
+        clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER,
+                                  new SandeshaListenerImpl());
+
+        String offeredSequenceId = UUIDGenerator.getUUID();
+        clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID, 
offeredSequenceId);
     }
 
     private void configureMail() throws AxisFault {
@@ -357,9 +361,9 @@
      */
     private int configureSecurity(String[] args, EndpointReference epr)
             throws AxisFault, IOException, XMLStreamException {
-        stub._getServiceClient().engageModule(MODULE_SECURITY);
+        stub._getServiceClient().engageModule(new QName(MODULE_SECURITY));
         stub._getServiceClient()
-                .engageModule(org.apache.axis2.Constants.MODULE_ADDRESSING);
+                .engageModule(new 
QName(org.apache.axis2.Constants.MODULE_ADDRESSING));
         String clientSSLStore = wso2wsasHome + File.separator + "conf" + 
File.separator +
                                 "client-truststore.jks";
 
@@ -455,8 +459,8 @@
         RampartConfig rc = new RampartConfig();
 
         Policy policy = loadPolicy(scenario);
-        rc.setUser("client");
-        rc.setEncryptionUser("service");
+        rc.setUser("alice");
+        rc.setEncryptionUser("bob");
         rc.setPwCbClass(PWCallback.class.getName());
 
         CryptoConfig sigCryptoConfig = new CryptoConfig();
@@ -470,7 +474,7 @@
         Properties prop1 = new Properties();
         prop1.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
         prop1.put("org.apache.ws.security.crypto.merlin.file", keystore);
-        prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"testing");
+        prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"password");
         sigCryptoConfig.setProp(prop1);
 
         CryptoConfig encrCryptoConfig = new CryptoConfig();
@@ -482,7 +486,7 @@
 
 
         prop2.put("org.apache.ws.security.crypto.merlin.file", keystore);
-        prop2.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"testing");
+        prop2.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"password");
         encrCryptoConfig.setProp(prop2);
 
         rc.setSigCryptoConfig(sigCryptoConfig);
@@ -499,14 +503,14 @@
         }
 
     }
-    
+
     private void configureUtKeystoreSec(Stub stub, int scenario) throws 
AxisFault, FileNotFoundException,
                                                                                
              XMLStreamException {
         System.out.println("In this demonstration, client will use client.jks 
and server should use\n" +
                                                                                
                      "service.jks.");
         RampartConfig rc = new RampartConfig();
         Policy policy = loadPolicy(scenario);
-        
+
         System.out.println("Please enter your username :");
 
         String username = readOption();
@@ -515,45 +519,45 @@
         String password = readOption();
         Parameter param = WSS4JUtil.getClientUsernameTokenHandler(password);
         stub._getServiceClient().getAxisService().addParameter(param);
-       
-        rc.setUserCertAlias("client");
-        rc.setEncryptionUser("service");
+
+        rc.setUserCertAlias("alice");
+        rc.setEncryptionUser("bob");
         rc.setPwCbClass(PWCallback.class.getName());
-        
+
         CryptoConfig sigCryptoConfig = new CryptoConfig();
-        
+
         
sigCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");
-        
+
         String keystore = wso2wsasHome + File.separator + "samples" +
         File.separator + "CommodityQuote" + File.separator +
         "keys" + File.separator + "client.jks";
-        
+
         Properties prop1 = new Properties();
         prop1.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
         prop1.put("org.apache.ws.security.crypto.merlin.file", keystore);
-        prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"testing");
+        prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"password");
         sigCryptoConfig.setProp(prop1);
-        
+
         CryptoConfig encrCryptoConfig = new CryptoConfig();
         
encrCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");
-        
+
         Properties prop2 = new Properties();
-        
+
         prop2.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
-        
-        
+
+
         prop2.put("org.apache.ws.security.crypto.merlin.file", keystore);
         prop2.put("org.apache.ws.security.crypto.merlin.keystore.password", 
"testing");
         encrCryptoConfig.setProp(prop2);
-        
+
         rc.setSigCryptoConfig(sigCryptoConfig);
         rc.setEncrCryptoConfig(encrCryptoConfig);
-        
+
         policy.addAssertion(rc);
-        
+
         stub._getServiceClient().getServiceContext()
         .setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-        
+
         if (QOS_VALUE_SECURE_RM.equals(qosValue)) {
         stub._getServiceClient().getServiceContext().getConfigurationContext()
         
.getAxisConfiguration().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_POLICY,
 policy);
@@ -626,7 +630,8 @@
             }
 
             EndpointReference epr = new EndpointReference(serviceEPR);
-            BufferedReader console = new BufferedReader(new 
InputStreamReader(System.in));
+            BufferedReader console = new BufferedReader(new InputStreamReader(
+                    System.in));
 
             System.out.println("COMMODITY QUOTE SAMPLE CLIENT");
             System.out.println("=============================\n");
@@ -713,10 +718,13 @@
                            "       : endpoint url of the CommodityQuote 
service");
     }
 
-    private static class MercuryErrorCallbackImpl implements 
MercuryErrorCallback {
+    private static class SandeshaListenerImpl implements SandeshaListener {
+        public void onError(AxisFault fault) {
+            System.out.println("ERROR:" + fault.getMessage());
+        }
 
-        public void onError(RMException rmException) {
-            System.out.println("ERROR: " + rmException.getMessage());
+        public void onTimeOut(SequenceReport report) {
+            System.out.println("ERROR: RM Sequence timed out");
         }
     }
 
@@ -775,4 +783,4 @@
         }
         return null;
     }
-}
+}
\ No newline at end of file

_______________________________________________
Wsas-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev

Reply via email to