Wednesday, August 19, 2009

Can we avoid duplicating crypto info added to RampartConfig in different services.xml files?

When we have Signature and/or Encryption in a security policy - we need to add following crypto info into the RampartConfig.

<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:user>service</ramp:user>
<ramp:encryptionUser>client</ramp:encryptionUser>
<ramp:passwordCallbackClass>sample03.PWCBHandler</ramp:passwordCallbackClass>
<ramp:signatureCrypto>
<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.file">service.jks</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">apache</ramp:property>
</ramp:crypto>
</ramp:signatureCrypto>
<ramp:encryptionCypto>
<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.file">service.jks</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">apache</ramp:property>
</ramp:crypto>
</ramp:encryptionCypto>
</ramp:RampartConfig>
In most of the cases above settings are static for more than one service.

In such a case - you can avoid adding this configuration to each and every service.

Step - 1
Implement the interface org.apache.rampart.RampartConfigCallbackHandler

Step - 2
In the RampartConfigCallbackHandler implementation update the RampartConfig instance passed into the method update() programmetically.

Step - 3
Add following to the service policy of all the corresponding services.

<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:rampartConfigCallbackClass>RampartConfigCallbackHandlerImpl
</ramp:RampartConfig>

0 comments:

Post a Comment