Java web services example, trustmanager version.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 3 Oct 2008 10:32:09 +0000 (10:32 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 3 Oct 2008 10:32:09 +0000 (10:32 +0000)
org.glite.lb.client/examples/webservices/java-trustmanager/Makefile [new file with mode: 0644]
org.glite.lb.client/examples/webservices/java-trustmanager/README [new file with mode: 0644]
org.glite.lb.client/examples/webservices/java-trustmanager/src/LBClientTM.java [new file with mode: 0644]
org.glite.lb.client/examples/webservices/java/Makefile

diff --git a/org.glite.lb.client/examples/webservices/java-trustmanager/Makefile b/org.glite.lb.client/examples/webservices/java-trustmanager/Makefile
new file mode 100644 (file)
index 0000000..c7204ba
--- /dev/null
@@ -0,0 +1,29 @@
+CLASSPATH:=${shell echo `find lib -type f | tr '\n' ':'`build}
+CLASSES=LBClientTM.class
+VPATH=src:build
+
+all: wsdl build
+
+wsdl: org/glite/wsdl/services/lb/stubs
+
+build: $(CLASSES)
+
+run:
+       if test -z "${FILE}" ; then echo 'Specify the FILE variable.'; exit 1; fi
+       java -classpath $(CLASSPATH) org.glite.wsdl.services.lb.example.LBClientTM ${FILE} ${ENDPOINT}
+
+clean:
+       rm -rvf build/
+
+org/glite/wsdl/services/lb/stubs:
+       java -classpath $(CLASSPATH) org.apache.axis.wsdl.WSDL2Java -v \
+         --buildFile \
+         --package org.glite.wsdl.services.lb.stubs \
+         --output build \
+         http://egee.cesnet.cz/cms/export/sites/egee/en/WSDL/HEAD/LB.wsdl
+
+LBClientTM.class: build/org/glite/wsdl/services/lb/stubs LBClientTM.java
+       -mkdir build
+       javac -classpath $(CLASSPATH) -d build src/*.java build/org/glite/wsdl/services/lb/{stubs,stubs/holders}/*.java
+
+.PHONY: all wsdl run clean
diff --git a/org.glite.lb.client/examples/webservices/java-trustmanager/README b/org.glite.lb.client/examples/webservices/java-trustmanager/README
new file mode 100644 (file)
index 0000000..0a5cdd8
--- /dev/null
@@ -0,0 +1,39 @@
+How to build
+============
+
+1) copy following files to lib/ directory:
+
+# AXIS
+axis-ant.jar
+axis.jar
+commons-discovery-0.2.jar
+commons-logging-1.0.4.jar
+jaxrpc.jar
+log4j.properties
+log4j-1.2.13.jar
+saaj.jar
+wsdl4j-1.5.1.jar
+
+# trustmanager
+glite-security-trustmanager.jar
+glite-security-util-java.jar
+
+# bouncycastle
+bcmail-jdk14-122.jar
+bcpg-jdk14-122.jar
+bcprov-jdk14-122.jar
+bctest-jdk14-122.jar
+
+2) generate source stubs and build the example by:
+
+  make
+
+
+Launch
+======
+
+  make run FILE=/tmp/x509up_u`id -u` ENDPOINT=https://host:9003
+
+or:
+
+  java -cp `find lib -type f | tr '\n' ':'`:build org.glite.wsdl.services.lb.example.LBClientTM /tmp/x509up_u`id -u` https://host:9003
diff --git a/org.glite.lb.client/examples/webservices/java-trustmanager/src/LBClientTM.java b/org.glite.lb.client/examples/webservices/java-trustmanager/src/LBClientTM.java
new file mode 100644 (file)
index 0000000..afab681
--- /dev/null
@@ -0,0 +1,64 @@
+package org.glite.wsdl.services.lb.example;
+
+import java.net.URL;
+import org.apache.axis.AxisFault;
+import org.apache.axis.AxisProperties;
+import org.apache.log4j.Logger;
+import org.apache.log4j.ConsoleAppender;
+
+import org.glite.security.trustmanager.ContextWrapper;
+
+import org.glite.wsdl.services.lb.stubs.LoggingAndBookkeeping_ServiceLocator;
+import org.glite.wsdl.services.lb.stubs.LoggingAndBookkeepingPortType;
+import org.glite.wsdl.services.lb.stubs.JobStatus;
+
+public class LBClientTM {
+       private static String proxyFile = null;
+       private static String endpoint = "https://localhost:9003";
+       private static Logger log = Logger.getLogger(LBClientTM.class);
+       
+       public static void main(String[] args) throws Exception {
+               if (args.length > 0) proxyFile = args[0];
+               if (args.length > 1) endpoint = args[1];
+
+               ConsoleAppender ca = new ConsoleAppender(new org.apache.log4j.SimpleLayout());
+//             ca.activateOptions();
+               log.addAppender(ca);
+               
+               log.info("endpoint being used "+ endpoint);
+               if (proxyFile != null) log.info("proxy location being used " + proxyFile);
+               
+               URL url = new URL(endpoint);
+               int port = url.getPort();
+               String protocol = url.getProtocol();
+               String path = url.getPath();
+               log.info(" port number "+ port + ", protocol ("+ protocol + "), path: " + path);
+               
+               System.setProperty("sslProtocol", "SSLv3");
+               AxisProperties.setProperty("axis.socketSecureFactory","org.glite.security.trustmanager.axis.AXISSocketFactory");
+               // certificate based authentication */
+//             System.setProperty("sslCertFile","/home/valtri/.cert/hostcert.pem");
+//             System.setProperty("sslKey","/home/valtri/.cert/hostkey.pem");
+//             System.setProperty("sslKeyPasswd","");
+               
+               // proxy based authentication
+               if (proxyFile != null) System.setProperty("gridProxyFile", proxyFile);
+               
+               try {
+                       LoggingAndBookkeeping_ServiceLocator loc = new LoggingAndBookkeeping_ServiceLocator();
+                       String sn = loc.getLoggingAndBookkeepingWSDDServiceName();
+                       log.info(" service name " + sn);
+                       
+                       LoggingAndBookkeepingPortType stub = loc.getLoggingAndBookkeeping(url);
+                       log.info(" got endpoint ");
+                       
+                       String version = stub.getVersion(null);
+                       log.info("LB version "+ version);
+                       JobStatus status = stub.jobStatus("https://scientific.civ.zcu.cz:9000/PnSBRXoIHVzX68H5vAtxmA", null);
+                       log.info("job status "+ status);
+               } catch (AxisFault af) {
+                       log.error( " AxisFault - " + af.getFaultString());
+                       af.printStackTrace();
+               }
+       }
+}
index 4a24541..4d3f24c 100644 (file)
@@ -1,10 +1,11 @@
 CLASSPATH:=${shell echo `find lib -type f | tr '\n' ':'`build}
+VPATH=src:build
 
 all: wsdl build
 
-wsdl: build/org/glite/wsdl/services/lb/stubs
+wsdl: org/glite/wsdl/services/lb/stubs
 
-build: build/org/glite/wsdl/services/lb/example
+build: org/glite/wsdl/services/lb/example
 
 run:
        if test -z "${FILE}" -o -z "${PASS}"; then echo 'Specify FILE and PASS variables.'; exit 1; fi
@@ -13,14 +14,14 @@ run:
 clean:
        rm -rvf build/
 
-build/org/glite/wsdl/services/lb/stubs:
+org/glite/wsdl/services/lb/stubs:
        java -classpath $(CLASSPATH) org.apache.axis.wsdl.WSDL2Java -v \
          --buildFile \
          --package org.glite.wsdl.services.lb.stubs \
          --output build \
          http://egee.cesnet.cz/cms/export/sites/egee/en/WSDL/HEAD/LB.wsdl
 
-build/org/glite/wsdl/services/lb/example:
+org/glite/wsdl/services/lb/example: build/org/glite/wsdl/services/lb/stubs
        -mkdir build
        javac -classpath $(CLASSPATH) -d build src/*.java build/org/glite/wsdl/services/lb/{stubs,stubs/holders}/*.java