axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Kempf" <petek...@gmail.com>
Subject Re: can't get axis2 security working for client code
Date Wed, 17 Sep 2008 09:07:01 GMT
Thanks!  Yes, I was able to get this working if I attached an actual policy
file.  I looked to sample02 in rampart
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-samples/policy/sample02/src/org/apache/rampart/samples/policy/sample02/Client.java?view=markup

Using this

options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy(args[2]));

But is there any way to add the wss10 configuration via code, without a
policy file?  Not that it matters to me now - but the code example that I
was working off of did not have a policy file.
https://wso2.org/library/3415


On Wed, Sep 17, 2008 at 12:09 AM, Dimuthu Leelarathne
<muthulee@apache.org>wrote:

> Hi,
>
> Please add the following assertion at the AsymmetricBinding assertion
> level.
>
> <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>               <wsp:Policy>
>                   <sp:MustSupportRefKeyIdentifier/>
>                   <sp:MustSupportRefIssuerSerial/>
>               </wsp:Policy>
> </sp:Wss10>
>
> Thank you,
> Dimuthu
>
>
>
> Peter Kempf wrote:
>
>> Using Axis2 1.4.1, Rampart 1.4, eclipse 3.4, jdk 1.5
>> I am unable to get the security to work.
>> I am basing it on this article
>> https://wso2.org/library/3415
>> only I'm running in eclipse.
>>
>> This is the exception I get when I execute.  Any ideas what I'm doing
>> wrong?
>> Obviously I'm missing something, probably related to the rampartconfig.
>>
>>
>> java.lang.NullPointerException
>>        at
>> org.apache.rampart.util.RampartUtil.setKeyIdentifierType(RampartUtil.java:1141)
>>        at
>> org.apache.rampart.builder.BindingBuilder.getSignatureBuider(BindingBuilder.java:243)
>>        at
>> org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:626)
>>        at
>> org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:413)
>>        at
>> org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:93)
>>        at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147)
>>        at
>> org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
>>        at org.apache.axis2.engine.Phase.invoke(Phase.java:317)
>>        at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
>>        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:429)
>>        at
>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
>>        at
>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>>        at
>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>>        at
>> com.myco.ws.test.JmeterserviceSecStub.addition(JmeterserviceSecStub.java:240)
>>        at com.myco.ws.test.TestClient.main(TestClient.java:57)
>>
>>                  package com.myco.ws.test;
>>
>>
>> import java.util.Properties;
>>
>> import com.myco.ws.test.PWCBHandler;
>> import org.apache.axis2.client.ServiceClient;
>> import org.apache.axis2.context.ConfigurationContext;
>> import org.apache.axis2.context.ConfigurationContextFactory;
>> import org.apache.axis2.description.PolicyInclude;
>> import org.apache.neethi.Policy;
>> import org.apache.rampart.policy.model.CryptoConfig;
>> import org.apache.rampart.policy.model.RampartConfig;
>>
>> import com.myco.ws.test.JmeterserviceSecStub.Addition;
>> import com.myco.ws.test.JmeterserviceSecStub.AdditionResponse;
>>
>> public class TestClient {
>>
>>        /**
>>         * @param args
>>         */
>>        public static void main(String[] args) {
>>                                            try {
>>
>> //                        System.setProperty("javax.net.ssl.trustStore",
>> "WebContent/WEB-INF/.keystore");
>> //
>>  System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
>>
>>                                        ConfigurationContext ctx =
>> ConfigurationContextFactory.createConfigurationContextFromFileSystem("WebContent/WEB-INF",
>> null);
>>                          JmeterserviceSecStub stub = new
>> JmeterserviceSecStub(ctx,"
>> https://localhost:58443/WSTestService/services/JmeterserviceSec?wsdl");
>>                                      ServiceClient sc =
>> stub._getServiceClient();
>>                sc.engageModule("rampart");
>>                                      Policy rampartPolicy =
>> getRampartConfig();
>>
>>  //sc.getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,
>> rampartPolicy);
>>                //AxisService.getPolicyInclude()     Deprecated. As of
>> release 1.4, replaced by getPolicySubject()
>>
>>  sc.getAxisService().getPolicySubject().attachPolicy(rampartPolicy);
>>                                            /*
>>                Options options = sc.getOptions();
>>                options.setUserName("apache");
>>                options.setPassword("password");
>>                */
>>                                      //JmeterserviceStub stub = new
>> JmeterserviceStub("
>> http://localhost:58080/WSTestService/services/Jmeterservice?wsdl");
>>                        Addition add = new Addition();
>>                        add.setX(1);
>>                        add.setY(2);
>>                        AdditionResponse addresp = stub.addition(add);
>>                        System.out.println("Response=" +
>> addresp.get_return());
>>
>>                              } catch (Exception e) {
>>                        System.out.println("Exception:"+e);
>>                        e.printStackTrace();
>>                }
>>
>>        }
>>
>>        private static Policy getRampartConfig () {
>>                              RampartConfig rampartConfig = new
>> RampartConfig();
>>                  rampartConfig.setUser("client");
>>
>>  rampartConfig.setPwCbClass("com.myco.ws.test.PWCBHandler");
>>
>>                                    CryptoConfig sigCrypto = new
>> CryptoConfig();
>>
>>  sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
>>
>>                  Properties props = new Properties();
>>
>>  props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type",
>> "JKS");
>>
>>  props.setProperty("org.apache.ws.security.crypto.merlin.file","WebContent/WEB-INF/keystore");
>>
>>  props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password",
>> "changeit");
>>
>>                  sigCrypto.setProp(props);
>>
>>                  rampartConfig.setSigCryptoConfig(sigCrypto);
>>
>>                  Policy policy = new Policy();
>>                  policy.addAssertion(rampartConfig);
>>
>>                  return policy;
>>        }
>>      }
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Mime
View raw message