When you generate the code it adds the security policies to input and output messages. Here codegen tool normalize the policy and attached it as a string so that runtime it builds the policy from that.
See the attached test case. Amila. On Dec 21, 2007 2:59 AM, Stephen Souness <[EMAIL PROTECTED]> wrote: > Thanks for that Amila. > > I've tried the following: > > wsdl2java -pn A12Binding -o generated -uri C:\interop.wsdl > > > I haven't noticed anything in the generated EchoServiceStub.java that > deals with the X509 or other security aspects specified in the > A12Binding_policy policy. > > Is their some additional axis2 setup required? > > > -- > Stephen > > > > Amila Suriarachchi wrote: > > see some security samples here > > http://131.107.72.15/ilab/ > > > > Amila > > > > On Dec 20, 2007 1:49 AM, Stephen Souness < [EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]>> wrote: > > > > Hi all, > > > > Can anyone direct me to an example of a WSDL which includes valid > > policy > > references, which wsdl2java can interpret and generate an > appropriate > > client stub from? > > > > Alternatively, is there a better way to generate the client code? > > > > -- > > Stephen > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: [EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > > -- > > Amila Suriarachchi, > > WSO2 Inc. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Amila Suriarachchi, WSO2 Inc.
/* * Copyright 2004,2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.tempuri.security.sign; import junit.framework.TestCase; import org.apache.neethi.Policy; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.Constants; import org.apache.axis2.description.PolicyInclude; import org.apache.rampart.policy.model.CryptoConfig; import org.apache.rampart.policy.model.RampartConfig; import org.apache.ws.security.components.crypto.Merlin; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMNamespace; import org.tempuri.security10.PingService10MutualCertificate10SignEncrypt_IPingServiceStub; import org.xmlsoap.ping.Ping; import org.xmlsoap.ping.PingResponseBody; import java.util.Properties; import java.rmi.RemoteException; public class PingService10SignStubTest extends TestCase { public static final String AXIS2_XML = "security_client_wcf/conf/axis2.xml"; public static final String AXIS2_REPOSITORY = "security_client_wcf/repository"; private PingService10SignStub stub = null; Policy ramapConfigPolicy = null; protected void setUp() throws Exception { ConfigurationContext confContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_REPOSITORY, AXIS2_XML); stub = new PingService10SignStub(confContext); stub._getServiceClient().engageModule("rampart"); // set the proxy stub._getServiceClient().getOptions().setProperty(Constants.Configuration.TRANSPORT_URL, "http://localhost:8085/Security_WsSecurity_Service_Indigo/WsSecurity10Sign.svc/MutualCertificate10Sign"); // set the rampart config properties correctly CryptoConfig signcriptoInfo = new CryptoConfig(); signcriptoInfo.setProvider(Merlin.class.getName()); Properties properties = new Properties(); properties.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", "JKS"); properties.setProperty("org.apache.ws.security.crypto.merlin.file", "security_client_wcf/conf/sec.jks"); properties.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "password"); signcriptoInfo.setProp(properties); CryptoConfig encriptcriptoInfo = new CryptoConfig(); encriptcriptoInfo.setProp(properties); encriptcriptoInfo.setProvider(Merlin.class.getName()); RampartConfig config = new RampartConfig(); config.setUser("alice"); config.setEncryptionUser("bob"); config.setPwCbClass("util.PasswordCallbackHandler"); config.setSigCryptoConfig(signcriptoInfo); config.setEncrCryptoConfig(encriptcriptoInfo); ramapConfigPolicy = new Policy(); ramapConfigPolicy.addAssertion(config); } public void testEcho() { try { stub._getServiceClient().getAxisService().getPolicyInclude().addPolicyElement( PolicyInclude.ANON_POLICY, ramapConfigPolicy); String result = stub.echo("Test String"); assertEquals(result, "Test String"); } catch (RemoteException e) { fail(); } } public void testEchoXml() { try { stub._getServiceClient().getAxisService().getPolicyInclude().addPolicyElement( PolicyInclude.ANON_POLICY, ramapConfigPolicy); Request_type1 request_type1 = new Request_type1(); request_type1.setExtraElement(getTestElement()); EchoXmlResult_type0 result = stub.echoXml(request_type1); } catch (RemoteException e) { fail(); } } public void testPing() { stub._getServiceClient().getAxisService().getPolicyInclude().addPolicyElement( PolicyInclude.ANON_POLICY, ramapConfigPolicy); Ping ping = new Ping(); ping.setOrigin("test origin"); ping.setScenario("test senario"); ping.setText("test"); try { PingResponseBody result = stub.Ping(ping); } catch (RemoteException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } public void testEchoDataSet() { stub._getServiceClient().getAxisService().getPolicyInclude().addPolicyElement( PolicyInclude.ANON_POLICY, ramapConfigPolicy); Request_type0 request_type0 = new Request_type0(); request_type0.setSchema(getScheaElement()); request_type0.setExtraElement(getTestElement()); try { EchoDataSetResult_type0 result = stub.echoDataSet(request_type0); } catch (RemoteException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } private OMElement getScheaElement() { OMFactory omFactory = OMAbstractFactory.getOMFactory(); OMNamespace omNamespace = omFactory.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xs"); OMElement omElement = omFactory.createOMElement("Schema", omNamespace); return omElement; } private OMElement getTestElement() { OMFactory omFactory = OMAbstractFactory.getOMFactory(); OMNamespace omNamespace = omFactory.createOMNamespace("http://wso2.org", "ns"); OMElement omElement = omFactory.createOMElement("Test", omNamespace); return omElement; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
