Return-Path: Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 88773 invoked by uid 500); 30 Jan 2001 07:15:35 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Received: (qmail 88769 invoked by uid 1247); 30 Jan 2001 07:15:34 -0000 Date: 30 Jan 2001 07:15:34 -0000 Message-ID: <20010130071534.88768.qmail@apache.org> From: nakamury@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/prototype/TRL_Proposal/samples/client SampleClient.java nakamury 01/01/29 23:15:34 Added: java/prototype/TRL_Proposal/samples/client SampleClient.java Log: A sample client application (includes digital signature) Revision Changes Path 1.1 xml-axis/java/prototype/TRL_Proposal/samples/client/SampleClient.java Index: SampleClient.java =================================================================== package samples.client; import org.apache.axis.Handler; import org.apache.axis.MessageContext; import org.apache.axis.ChainContainer; import org.apache.axis.transports.HttpTransportSender; import org.apache.axis.message.SOAPDocument; import org.apache.axis.message.impl.SOAPDocumentImpl; import org.apache.axis.handlers.Signer; import org.apache.axis.handlers.Verifier; import org.apache.axis.handlers.KeyStoreUtil; import org.apache.axis.util.xml.DOMConverter ; import org.apache.axis.util.Logger ; public class SampleClient { public static String ALIAS = "DSIG.ALIAS"; public static String KEYPASS = "DSIG.KEYPASS"; public static String KEY_STORE_PATH = "DSIG.KEY_STORE_PATH"; public static String KEY_STORE_PASS = "DSIG.KEY_STORE_PASS"; public static String SIGNER_URL = "DSIG.SIGNER_URL"; public static String VERIFIER_URL = "DSIG.VERIFIER_URL"; private Handler nextHandler; public void setNextHandler(Handler handler) { this.nextHandler = handler; } static void main(String args[]) { SampleClient client = new SampleClient(); client.configure(); String env = "\n" + "\n" + "\n" + "\n" + "\n" + "" ; try { SOAPDocument msg = new SOAPDocumentImpl(DOMConverter.toDOM(env)); MessageContext msgCntxt = new MessageContext(msg); Logger.normal("Sending Request "); Logger.normal(msg.toXML()); client.nextHandler.invoke(msgCntxt); Logger.normal("Received Request "); Logger.normal(msgCntxt.getMessage().toXML()); } catch(Exception ex) { ex.printStackTrace(); } } void configure() { try { // Setting digital signature properies String alias = System.getProperty(ALIAS); String keypass = System.getProperty(KEYPASS); String keyStorePath = System.getProperty(KEY_STORE_PATH); String keyStorePass = System.getProperty(KEY_STORE_PASS); String verifierURI = System.getProperty(SIGNER_URL); String signerURI = System.getProperty(VERIFIER_URL); if (alias == null || keypass == null || keyStorePath == null || keyStorePass == null || verifierURI == null || signerURI == null) { Logger.fatal("alias: " + alias); Logger.fatal("keypass: " + keypass); Logger.fatal("keyStorePath: " + keyStorePath); Logger.fatal("keyStorePass: " + keyStorePass); Logger.fatal("verifierURI: " + verifierURI); Logger.fatal("signerURI: " + signerURI); throw new Exception("Need to set up properties"); } System.setProperty("com.ibm.trl.soapimpl.security.KeyStorePath",keyStorePath); System.setProperty("com.ibm.trl.soapimpl.security.KeyStorePassword",keyStorePass); java.security.Key key = KeyStoreUtil.getKey(alias, keypass); java.security.cert.Certificate cert = KeyStoreUtil.getCertificate(alias); ChainContainer cc = new ChainContainer(); this.setNextHandler(cc); cc.addHandler(new Signer(key, cert, verifierURI)); // need to specify a key cc.addHandler(new HttpTransportSender()); // cc.addHandler(new Verifier()); } catch (Exception e) { e.printStackTrace(); } } };