butek 02/04/25 07:03:23
Modified: java/samples/security Client.java
Added: java/samples/security readme
Log:
Added samples/security/readme (thanks to Ted Leung) and put the Client
main inside a try/catch for better readability of exceptions.
Revision Changes Path
1.5 +30 -19 xml-axis/java/samples/security/Client.java
Index: Client.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/security/Client.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Client.java 13 Feb 2002 17:00:24 -0000 1.4
+++ Client.java 25 Apr 2002 14:03:22 -0000 1.5
@@ -55,6 +55,7 @@
package samples.security;
+import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
@@ -65,25 +66,35 @@
public class Client {
static void main(String[] args) throws Exception {
- Options opts = new Options(args);
+ try {
+ Options opts = new Options(args);
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new java.net.URL(opts.getURL()));
-
- SOAPEnvelope env = new SOAPEnvelope();
- SOAPBodyElement sbe = new
SOAPBodyElement(XMLUtils.StringToElement("http://localhost:8080/LogTestService",
"testMethod", ""));
- env.addBodyElement(sbe);
-
- env = new SignedSOAPEnvelope(env, "http://xml-security");
-
- System.out.println("\n============= Request ==============");
- XMLUtils.PrettyElementToStream(env.getAsDOM(), System.out);
-
- call.invoke(env);
-
- MessageContext mc = call.getMessageContext();
- System.out.println("\n============= Response ==============");
-
XMLUtils.PrettyElementToStream(mc.getResponseMessage().getSOAPEnvelope().getAsDOM(),
System.out);
+ Service service = new Service();
+ Call call = (Call) service.createCall();
+ call.setTargetEndpointAddress(new java.net.URL(opts.getURL()));
+
+ SOAPEnvelope env = new SOAPEnvelope();
+ SOAPBodyElement sbe = new
SOAPBodyElement(XMLUtils.StringToElement("http://localhost:8080/LogTestService",
"testMethod", ""));
+ env.addBodyElement(sbe);
+
+ env = new SignedSOAPEnvelope(env, "http://xml-security");
+
+ System.out.println("\n============= Request ==============");
+ XMLUtils.PrettyElementToStream(env.getAsDOM(), System.out);
+
+ call.invoke(env);
+
+ MessageContext mc = call.getMessageContext();
+ System.out.println("\n============= Response ==============");
+
XMLUtils.PrettyElementToStream(mc.getResponseMessage().getSOAPEnvelope().getAsDOM(),
System.out);
+ }
+ catch (Exception e) {
+ if (e instanceof AxisFault) {
+ System.err.println(((AxisFault) e).dumpToString());
+ }
+ else {
+ e.printStackTrace();
+ }
+ }
}
}
1.1 xml-axis/java/samples/security/readme
Index: readme
===================================================================
The security sample demonstrates how to use the Axis architecture to
add digital signatures to your application.
To run the sample,
1. Set up your CLASSPATH.
2. Start an Axis server.
3. Install the server side handler.
4. Run the client application.
1. Set up your CLASSPATH.
The CLASSPATH must contain: an XML parser (ie., Xerces), JUnit
(www.junit.org), xmlsec.jar (xml.apache.org/security/index.html),
xalan.jar (comes with xmlsec.jar, or xml.apache.org/xalan-j), log4j.jar
(comes with xmlsec.jar, or jakarta.apache.org/log4j), xml-apis.jar (comes
with xmlsec.jar), jce-jdk13-113.jar (www.bouncycastle.org), all the jars
in the lib directory, and the directory containing the samples
subdirectory.
1.5. NOTE: If the build you have wasn't built with security turned on, you
will have to build this sample by hand. From the samples/security
directory, simply run:
javac *.java
2. Start an Axis server.
To run the sample, you will first need to run a server. To run a very
simple server you could run, in a separate window:
java org.apache.axis.transport.http.SimpleAxisServer -p 8080
3. Install the server side handler.
You need to install the server's digital signature handler. To do this:
java org.apache.axis.client.AdminClient securitydeploy.wsdd
4. Run the client application.
Finally, to run the client, run:
java samples.security.Client
This sample also allows you to setup an Axis server to allow transparent
digital signature of all SOAP messages being processed by the server. To
enable this, in addition to step 3 above, do the following:
3.3. Install the client side handler.
On the client side, ClientSigningHandler is installed in the global
request chain. You must run the following command two directories above
the security sample directory:
java org.apache.axis.utils.Admin client
samples/security/clientsecuritydeploy.wsdd
3.5. Install the server side handler: On the server side, LogHandler is
installed in the global request chain. You must run the following
command two directories above the security sample directory:
java org.apache.axis.client.AdminClient
samples/security/serversecuritydeploy.wsdd