Build.xml File Example of Adding Security to MTOM Web Service

Configuring Message-Level Security 2-99 cpm = wtm.createConfigurationPropertyConfidentialityKeyPassword cpm.setEncryptValueRequiredBooleantrue keyPass=sys.argv[8] cpm.setEncryptedValuekeyPass Custom keystore for xml digital signature cpName=IntegrityKeyStore cpm=wtm.lookupConfigurationPropertycpName if cpm == None: cpm = wtm.createConfigurationPropertycpName keyStoreName=sys.argv[5] cpm.setValuekeyStoreName cpName=IntegrityKeyStorePassword cpm=wtm.lookupConfigurationPropertycpName if cpm == None: cpm = wtm.createConfigurationPropertycpName cpm.setEncryptValueRequiredBooleantrue KeyStorePasswd=sys.argv[6] cpm.setEncryptedValueKeyStorePasswd cpName=IntegrityKeyAlias cpm=wtm.lookupConfigurationPropertycpName if cpm == None: cpm = wtm.createConfigurationPropertycpName keyAlias=sys.argv[7] cpm.setValuekeyAlias cpName=IntegrityKeyPassword cpm=wtm.lookupConfigurationPropertycpName if cpm == None: cpm = wtm.createConfigurationPropertycpName cpm.setEncryptValueRequiredBooleantrue keyPass=sys.argv[8] cpm.setEncryptedValuekeyPass Create token handler for x509 token cpName=default_x509_handler th=defaultWss.lookupWebserviceTokenHandlercpName if th == None: th = defaultWss.createWebserviceTokenHandlercpName th.setClassNameweblogic.xml.crypto.wss.BinarySecurityTokenHandler th.setTokenTypex509 cpm = th.createConfigurationPropertyUseX509ForIdentity cpm.setValuetrue save activateblock=true disconnect exit

2.22.5 Build.xml File

The build.xml file has the targets shown in Table 2–1 . 2-100 Securing WebLogic Web Services for Oracle WebLogic Server The complete build.xml file is shown in Example 2–28 . Example 2–28 build.xml File ?xml version=1.0 encoding=ISO-8859-1? project name=webservices.security_mtom default=all basedir=. -- set global properties for this build -- property file=......examples.properties property name=client.dir value={client.classes.dir}webservicesSecurityMtom_Client property name=package.dir value=exampleswebservicessecurity_mtom property name=package value=examples.webservices.security_mtom property name=ws.file value=SecurityMtomService property name=ear.dir value={examples.build.dir}webservicesSecurityMtomEar property name=cert.dir value={basedir}certs property name=certs.dir value={basedir}certs --client keystore-- property name=client-keystore-name value=clientKeyStore.jks property name=client-keystore-pass value=keystorepw property name=client-cert value=ClientCert property name=client-key value=ClientKey property name=client-key-pass value=ClientKeyPass property name=client-cert-alias value=testClientCert --server keystore-- property name=server-keystore-name value=serverKeyStore.jks property name=server-keystore-pass value=keystorepw property name=server-cert value=ServerCert property name=server-key value=ServerKey property name=server-key-pass value=ServerKeyPass property name=server-cert-alias value=testServerCert path id=client.class.path pathelement path={client.dir} pathelement path={java.class.path} path -- Web Service WLS Ant task definitions -- Table 2–13 build.xml targets Target Description client Target that builds the Security MTOM Web service client. config.server.security Target that configures the Web service security. deploy Target that deploys the Web service. server Target that builds the Security MTOM Web service. clean Deletes temporary directories. build Depends on server, client, and clean. run Target that runs the Security MTOM Web service client. all Default target. Depends on build, deploy. Configuring Message-Level Security 2-101 taskdef name=jwsc classname=weblogic.wsee.tools.anttasks.JwscTask taskdef name=clientgen classname=weblogic.wsee.tools.anttasks.ClientGenTask target name=all depends=build, deploy target name=build depends=clean,server,client target name=clean delete dir={ear.dir} delete dir={client.dir} target -- Target that builds the MTOM Web Service -- target name=server description=Target that builds the MTOM Web Service jwsc srcdir={examples.src.dir}{package.dir} sourcepath={examples.src.dir} destdir={ear.dir} classpath={java.class.path} fork=true keepGenerated=true deprecation={deprecation} debug={debug} jws file=SecurityMtomService.java explode=true jwsc target -- Target that builds the MTOM Web Service client -- target name=client description=Target that builds the source Web Service mkdir dir={client.dir}{package.dir}client clientgen wsdl={ear.dir}{ws.file}WEB-INF{ws.file}Service.wsdl destDir={client.dir} classpath={java.class.path} packageName={package}.client copy file=MtomClient.java todir={client.dir}{package.dir}client javac srcdir={client.dir} destdir={client.dir} classpath={java.class.path} includes={package.dir}client.java target -- Target that deploys the MTOM Web Service -- target name=deploy description=Target that deploys the reliable destination Web Service wldeploy action=deploy source={ear.dir} user={wls.username} password={wls.password} verbose=true adminurl=t3:{wls.hostname}:{wls.port} targets={wls.server.name} failonerror={failondeploy} target -- Target that runs the MTOM Web Service client -- target name=run 2-102 Securing WebLogic Web Services for Oracle WebLogic Server java fork=true classname=examples.webservices.security_mtom.client.MtomClient failonerror=true jvmarg line=-Dweblogic.wsee.verbose= classpath refid=client.class.path arg line= {basedir}certs{client-keystore-name} {client-keystore-pass} {client-cert-alias} {client-key-pass} {basedir}certstestServerCertTempCert.der http:{wls.hostname}:{wls.port}SecurityMtomServiceSecurityMtomService?WSDL java target -- Target the configure the web service security -- target name=config.server.security description=Target the configure the web service security copy todir={examples.domain.dir} overwrite=true fileset dir={certs.dir} includes={server-keystore-name} copy java classname=weblogic.WLST fork=true failonerror=true arg line=configWss.py {wls.username} {wls.password} {wls.hostname} {wls.port} {server-keystore-name} {server-keystore-pass} {server-cert-alias} {server-key-pass} java target project

2.22.6 Building and Running the Example