Our web services service a variety of clients using differing security methods which I configure using a sort of security registry. All calls to our web services are routed to this security manager through a custom request handler. The security registry determines the security credentials required for the specific service/method call (could be something as simple to an ip address restriction to HTTP basic auth to WS-S) through a config doc. For the calls which require WS-S I simply invoke our custom handler which extends the WSDoAllReceiver capibilites. This allows me to handle exceptions, metrics, caching, etc on my own. I have overridden the loadSignatureCrypto in the WSDoAllReceiver class to retrieve the configured crypto as shown below.

 

- Jay

 


From: Olano, Ever [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 25 January 2006 8:30 AM
To: Weinberg, Jason; [email protected]
Subject: RE: Programmatically set crypto properties?

 

Thanks, Jason.  With this method, I still don’t know how I would make WSDoAllSender use the Crypto object that CryptoFactory.getInstance() just returned.  Do you know?  Am I missing something very obvious?  Or did you write your own Axis handler and are calling WSSignEnvelope.build() directly in it?

 

Thanks again,

Ever

 


From: Weinberg, Jason [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 24, 2006 1:14 PM
To: Olano, Ever; [email protected]
Subject: RE: Programmatically set crypto properties?

 

Ever,

 

I use something along the lines of the following to accomplish this. I had the same concern with password and have build a custom cipher storage mechanism which is responsible for storing such sensitive data in an encrypted form.

 

        Crypto crypto = null;

 

        Properties cryptoProperties = getJksCryptoProperties(); // Method imp follows

 

        crypto = CryptoFactory.getInstance(cryptoProperties.getProperty("org.apache.ws.security.crypto.provider"), cryptoProperties);

 

 

 

 

    private Properties getCryptoProperties()

    {

 

        Properties cryptoProperties = new Properties();

 

        String keystoreLocationKey = "tsr.services.security.wsshandlerconfig." + configurationDetailsKey + ".keystore.location";

        String keystorePasswordKey = "tsr.services.security.wsshandlerconfig." + configurationDetailsKey + ".keystore.password";

 

        String keystoreLocation = SecurityUtils.getValue(keystoreLocationKey);

        String keystorePassword = SecurityUtils.getValue(keystorePasswordKey);

 

        cryptoProperties.put("org.apache.ws.security.crypto.merlin.file", keystoreLocation);

        cryptoProperties.put("org.apache.ws.security.crypto.merlin.keystore.password", keystorePassword);

 

        cryptoProperties.put("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");

        cryptoProperties.put("org.apache.ws.security.crypto.merlin.keystore.type", "jks");

 

        return cryptoProperties;

    }

 

 

Hope it helps

 

- Jay

 

 


From: Olano, Ever [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 25 January 2006 6:21 AM
To: [email protected]
Subject: Programmatically set crypto properties?

 

Hello.  I am using WSDoAllSender.  I know that I can programmatically set the user and signature props file using the Stub object.  Can I also programmatically set the Properties passed to the crypto (Merlin) object instead of reading them from the signature props file?  I am particularly interested in getting rid of the entry:

 

org.apache.ws.security.crypto.merlin.keystore.password

 

in the signature props file and moving it into code.

 

Well, actually, I guess I could subclass Merlin and override the constructor to override the password that’s there (if any) with something else.  Is that the only way or is there a “more built-in” way?

 

Thanks,

Ever

Reply via email to