This entry focuses on some changes to the Crypto property files. These files are used to load keys and certificates for various WS-Security operations, and are loaded by the CryptoFactory class. CryptoFactory parses a single property in the file:
- org.apache.ws.security.crypto.provider - WSS4J specific provider used to create Crypto instances (default value is "org.apache.ws.security.components.crypto.Merlin").
- org.apache.ws.security.crypto.merlin.file - location of keystore
- org.apache.ws.security.crypto.merlin.keystore.provider - provider of keystore
- org.apache.ws.security.crypto.merlin.keystore.password - password used to load keystore
- org.apache.ws.security.crypto.merlin.keystore.type - type of keystore (defaults to java.security.KeyStore.getDefaultType())
- org.apache.ws.security.crypto.merlin.load.cacerts - whether to load the CA certs in ${java.home}/lib/security/cacerts or not (default is true)
- org.apache.ws.security.crypto.merlin.cacerts.password - the password to use to load the CA certs (default is "changeit")
- org.apache.ws.security.crypto.merlin.cert.provider - the provider to use to load certificates
- org.apache.ws.security.crypto.merlin.keystore.alias - the default keystore alias to use, if none is specified
Provider tags:
- org.apache.ws.security.crypto.merlin.keystore.provider - the provider used to load keystores (including the truststore)
- org.apache.ws.security.crypto.merlin.cert.provider - the provider used to load certificates
KeyStore tags:
- org.apache.ws.security.crypto.merlin.keystore.file - location of keystore
- org.apache.ws.security.crypto.merlin.keystore.password - password used to load keystore
- org.apache.ws.security.crypto.merlin.keystore.type - type of keystore (defaults to java.security.KeyStore.getDefaultType())
- org.apache.ws.security.crypto.merlin.keystore.alias - the default keystore alias to use, if none is specified
Truststore Tags:
- org.apache.ws.security.crypto.merlin.load.cacerts - whether to load the CA certs in ${java.home}/lib/security/cacerts or not (default is false)
- org.apache.ws.security.crypto.merlin.truststore.file - location of truststore
- org.apache.ws.security.crypto.merlin.truststore.password - truststore password (default value is "changeit")
- org.apache.ws.security.crypto.merlin.truststore.type - truststore type (defaults to java.security.KeyStore.getDefaultType())
How about adding ability to supply a preloaded keystore? I recently had to use wss4j in a project that has a configuration framework that provides the keystore instance but not the path to the keystore. I did work around it, but i think it would be nice to be able to supply KeyStore instance.
ReplyDeleteThanks for your comment - I fixed this in revision 1059964:
ReplyDeletehttp://svn.apache.org/viewvc?view=revision&revision=1059964
You can now set a keystore, truststore etc. on a Crypto instance.
Colm I am trying to build a client that needs to talk to a windows WSE service.
ReplyDeleteWill WSS4j allow me to build the derived keys and also encryopt message from a jks with x509 certs.
Do you have example scripts that use WSS4j to do above.Want to write a java class.
Hi Mahesh,
ReplyDeleteYes, WSS4J supports encryption with derived keys and X.509 certs from a jks.
If you have a WSDL for the service, you're probably better off using a web services stack like CXF, rather than WSS4J directly, as it will take care of all of the security stuff for you.
If you really want to work at a low level with the WSS4J API's, then take a look at the tests, e.g.:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java?view=markup
Colm.
This comment has been removed by the author.
ReplyDeleteFirst of all thanks a lot for your reply.
ReplyDeleteI am using Jdeveloper 10g 10.1.4 on current project and found both Jdeveloper 10.1.4 and 11g werent supporting the policy with derived keys.
It will be great if I can get this to work with Jdev 10.1.4 with OC4j Webserver.Is tied to Apache webserver.
Can I use CFX with any other webserver.
Take a look at this policy and let me know if you think Wss4j will be able to implement the policy
sp:SymmetricBinding
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
wsp:Policy
sp:ProtectionToken
wsp:Policy
sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"
wsp:Policy
sp:RequireDerivedKeys/
sp:RequireThumbprintReference
sp:WssX509V3Token10/
/wsp:Policy
/sp:X509Token
/wsp:Policy
/sp:ProtectionToken
sp:AlgorithmSuite
wsp:Policy
sp:Basic128Rsa15/
/wsp:Policy
/sp:AlgorithmSuite
sp:Layout
wsp:Policy
sp:Strict/
/wsp:Policy
/sp:Layout
sp:IncludeTimestamp/
sp:EncryptSignature/
sp:OnlySignEntireHeadersAndBody/
/wsp:Policy
/sp:SymmetricBinding
I downloaded CXF and implemented it in oC4j 10.1.3 per instructions on Apache CXF website
ReplyDeleteI need to now how to configure wss4j with CXF
Hi Mahesh,
ReplyDeleteYes CXF should be able to support that security policy. You don't really need to know about how to configure WSS4J with CXF, as WSS4J just works under the hood. The best way to find out how to configure security in CXF in general is to take a look at the docs, and also the security samples that ship with CXF:
http://cxf.apache.org/docs/ws-securitypolicy.html
Colm.
Colm,
ReplyDeleteDo i need Spring framework (Jdeveloper 10.1.3) or can CXF work without spring.I am thinking of creating a simple echo class and then create a client to call it.
Mahesh
Hi Mahesh,
ReplyDeleteProbably best to raise such questions on the CXF users mailing list rather than this blog:
http://cxf.apache.org/mailing-lists.html
Colm.
Ok will do that you have been good help.
ReplyDeleteI will use the mailing list
Mahesh
Colm,
ReplyDeleteI did some cxf examples and was able to implement ws security via interceptors.
However I realized I needed to implement ws policy via cxf. I could not make out how wsdl is provided for client.is the wsdl auto detected if the service is secured via ws policy
My cxfclient files looks like below
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="client" serviceClass="com.sungard.cxf.example.client.IHello" address="http://localhost:9000/HelloWorld">
<jaxws:properties>
<entry key="ws-security.signature.properties"
value="client-sign.properties"/>
<entry key="ws-security.signature.username" value="clientx509v1"/>
<entry key="ws-security.encryption.properties"
value="client-sign.properties"/>
<entry key="ws-security.encryption.username" value="clientx509v1"/>
<entry key="ws-security.callback-handler"
value="com.sungard.cxf.example.client.ClientPasswordCallback"/>
</jaxws:properties>
</jaxws:client>
</beans>
Hi Mahesh,
ReplyDeletePlease send all CXF specific questions to the CXF users mailing list.
Colm.
Colm,
Deletefinally got OC4J an CXF to work with the .NET webservice.Deployment was equally a challange
Thanks for your help
Mahesh
Colm,
ReplyDeleteFinally got the client working.but the final road block seems to be an exception
the signature or decryption was invalid
I have subscribed to the list and posted the error waiting for it to get approved
http://cxf.547215.n5.nabble.com/CXF-2-4-1-Client-is-giving-the-signature-or-decryption-was-invalid-td4507027.html
There are a number of issues with the old configuration values. The Java CA certs were loaded by default.
ReplyDeleteHome security