|
[
Permalink
| « Hide
]
Chad Hahn added a comment - 30/Oct/07 12:30 PM
I'd like to see this get done and I'd be willing to help out. Is this already started or what is the status on this?
Great! It's not started yet; it's not even planned yet, but it would be great to get it before 1.1
I suggest looking at the given link, and this one: http://ws.apache.org/wss4j/api.html The extension point in SWS will probably be: http://static.springframework.org/spring-ws/site/apidocs/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.html Let me know if you need any more help No comments have been added for a while. It would be a great help to know if someone is already working on this.
I really would appreciate somebody working on this, since my TODO-list for version 1.5 is already pretty full.
I've implemented a limited support for wss4j. For the moment it only contains support for Username token, a SimplePasswordValidationCallbackHandler and an AcegiPlainTextPasswordValidationCallbackHandler. I tried to mime Xwss behavior in Spring-WS as closely as possible. I tested it with both Saaj and Axiom message factories.
Here's a configuration example: <bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"> <property name="callbackHandler"> <bean class="org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler"> <property name="users"> <props> <prop key="bob">hotdog</prop> </props> </property> </bean> </property> <property name="secureResponse" value="false"/> <property name="validateRequest" value="true"/> </bean> or <bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor "> It is still rough and incomplete. It could certainly use some more work. I hope you find it useful. Great! I will take a look at it as soon as possible.
Update:
Sorry. I attached the wrong file. Here's the new one.
Thanks, Tareq. It will surely make its way into 1.5.
I have request: can you please give me the guarantee that the code that you attached can be released under the Apache License 2.0? No problem. The code can be released under the Apache License 2.0. Would you like me to include the license in the header of each file?
BTW, I'd like to work on it some more to add features/doc/comments ... Ok, cool. Adding the license would help, saves me some work, and also makes our lawyers happy. (Yes, I hate this legal stuff just as much as the next guy, but it's important to get it right).
I've taken a look at the code, and I think we can make this work. Some remarks:
from the WSPasswordCallback javadoc: from UsernameTokenProcessor.handleUsernameToken javadoc: Is my understanding correct? Update:
Remarks:
Here's how the configuration looks like: Bean config looks good.
One thing I would change - if possible - is to make the crypto props another bean definition, rather than using <props>, which doesn't look very nice. However, most people will use the Merlin implementation anyway, since that's built into the JDK since 1.4. you're right, the properties are rather ugly. Are you suggesting replacing signatureCryptoProperties with signatureCrypto so that something like the following could be written?
<property name="signatureCrypto"> Yes, that's what I would prefer. We should probably make it a FactoryBean, to make it easier to configure for users.
Update:
-Added a CryptoFactoryBean as suggested. It basically does the same thing as CryptoFacotry but in a more Spring fashion. It is configured by injecting properties directly or a Spring Resource. Actually, I didn't delegate to CryptoFactory because it functions in a way that could be confusing for Spring users. CryptoFactory basically reads a property file from the class path (a different class loader can be used) and keeps a singleton instance of a Crypto. If no property file is found a NPE is thrown. CryptoFactoryBean implementation leaves scope management to Spring and is configured in a way familiar to Spring users. There are a couple of assertions to validate the configuration. If needed, a CryptoFactory could still be used. -Added some java doc and comments What do you think? Forgot to include a config example:
<bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"> <property name="action" value="Signature"/> <property name="signatureCrypto"> <bean class="org.springframework.ws.soap.security.wss4j.CryptoFactoryBean"> <!-- <property name="cryptoProvider" value="org.apache.ws.security.components.crypto.Merlin"/>--> <!-- <property name="config">--> <!-- <props>--> <!-- <prop key="org.apache.ws.security.crypto.provider">org.apache.ws.security.components.crypto.Merlin</prop>--> <!-- <prop key="org.apache.ws.security.crypto.merlin.keystore.type">jks</prop>--> <!-- <prop key="org.apache.ws.security.crypto.merlin.keystore.password">123456</prop>--> <!-- <prop key="org.apache.ws.security.crypto.merlin.file">e:/privkeystore</prop>--> <!-- </props>--> <!-- </property>--> <property name="configLocation" value="classpath:signatureCrypto.properties"/> </bean> </property> </bean> I'm working on decryption support at the moment. I have a problem with axiom messages : after calling wss4j to decrypt an incoming message I have to replace tho original encrypted envelope with the decrypted one. I couldn't find a way to achieve that through Axiom api. Something like webServiceMessage.getAxiomMessage().setSOAPEnvelope(envelopeFromDOMDocument) is not permitted by Axiom (throws an UnsupportedOperationException). I didn't find a way to replace a webServiceMessage in Spring WS either.
Any ideas? Well, there is a setSaajMessage on the SaajSoapEnvelope, but I've just noticed that there is no equivalent on the AxiomSoapMessage. I will add it.
Update:
I have implemented a working example (though not perfect) of a securement action (Username token) using the first method. <bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"> Update:
I would like to incorporate the attached code into SVN, so that it can be part of 1.5 M2.
Tareq, do you feel that it is ready? Hi Arjen,
I think that the securement part needs some more work. Here's what's left to do:
In addition to that I need your validation for the following points as they concern existent classes:
If possible I'd appreciate having this week to finalize as much as possible of the these points. Ok. 1.5 M2 is not planned until February 8th anyway, so I guess we still have some time.
As for the other questions:
Also, if you are going to change existing classes - which is fine by me, could you please a patch rather than a jar file? That makes it easier for me to track what has changed. All major IDEs have built-in patch functionality, so it shouldn't be hard to do. Hi Tareq/Arjen
I am trying to use this wss4j implementation in my project. I know its still under development but can you please help me out of the following issue. I am trying to validate signature of a soap request. The soap envelope is being signed using the crypto.merlin. When I valdate using directly WSSecurityEngine.processSecurityHeader(...) in a standalone it works fine but when i try to use org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor in a spring application deployed on tomcat 5.0, it throws exception for the same SoapEnvelope. After careful debugging I found that the exception is actually - org.apache.xml.security.signature.XMLSignatureException: The Reference for URI #id-24446859 has no XMLSignatureInput I am not sure what wrong I have done. Please help. Sandeep,
Thank you for testing the interceptor. I've not come across the exception you described. Have you resolved the problem? Arjen,
BTW, I've just added basic support for securement signature and encryption. Now that the basic features are there, I'll start adding support for more options and doing some refactoring. Tareq,
I also see same problem as Sandeep mentioned, and the cause for the same is that "The resulting xml is semantically identical to the source but not textually". I did see few namespace missing from the resulting xml. This causes the signature validation to fail. I believe that XML transformation is done by the Core module and Security module rebuilds the XML for verification, but the resultant xml is not complete. Is there a way to get the original XML (Original SOAP message received) and use that for verification. Thanks, Signature validation seemed to work for me. I'll check that again.
Update:
Arjen, Kaushik, Tareq, thanks for responding.
I'll execute the test case and let u know the results. Thanks, Update:
Tareq this is really cool. We are a lot of people that are forced on the WebSphere wagon (like it or not) so your effort is really appreciated.
Update:
The interceptor is almost complete I think. I still have to refactor callback handlers and do some cleaning. I'll finish that shortly. Claus, Update:
Remarks:
Aside from that, the interceptor is pretty finished. I would like to have your remarks on the above so that I can prepare a patch. Hi Tareq,
Good stuff! This is one of the most popular issues to be resolved for 1.5.
Then I think we should remove it. XWSS does remove the header, and the two interceptors need to be consistent.
Hmm, I'm not sure how to solve this. Which particular class do I need to look at? Hi Arjen,
Here's an update on the 2 issues:
A couple of remarks:
Weird. Well, let's just say that it isn't the first Axiom issue I've found (https://issues.apache.org/jira/secure/IssueNavigator.jspa?pid=12310250&reporter=poutsma It might make sense to add a removeHeaderElement(QName) to the SoapHeader interface to fix this. Is that something you want me to add to the core?
Hmm. Dependency-wise, I don't think this is a good idea, since it requires Spring AOP. I'd rather look for an alternate solution, if possible. It seems a bit hackish
OK, added
Not yet. But I must say that I have not delved into the code deeply (yet). For the moment, let's leave it open, and clearly mark it with a TODO. Then, when I will incorporate the code into SVN, I will take a good look at it. Does that seem OK? Sounds sensible. As for
By the way, when I was experimenting with the wss4j interceptor, I wrote a JaxRpcHandlerAdapterInterceptor which is, as its name suggests, an interceptor that runs JAX-RPC's handlers in Spring-WS. This could be useful for people wanting to migrate existing web services to Spring-WS, especially headers processing. As an example, I tried it with Wss4j's JAX-RPC handler. It seemed to work but with a couple of drawbacks: saaj only, ugly configuration and a bug in the handler with sun's saaj implementation. Would you like to see something like that in Spring-WS? Can I contribute it? Calling soapMessage.getEnvelope().getHeader().removeHeaderElement(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse")) to remove WS-Security headers doesn't seem to work. My unit tests (with xpath expressions) are failling for both axiom and saaj messages.
You need to remove it with the "Security" localname, and not "wsse" (which is the prefix).
How much time do you think you need after this? We have the 1.5-M2 release coming up next week, and I really want to make it part of that. I'll have time to work on it tonight. I had tried what you suggested though, with no success. I also made AbstractWsSecurityInterceptor.WS_SECURITY_NAME protected and used it. Anyhow, I'll debug that tonight and hopefully find what's wrong so that the interceptor can make it to M2.
I located and corrected the bug. It happens with Axiom messages only. removeHeaderElement works fine. I'll post an update later.
-update
Hi Tareq,
I really want to start incorporating this in the SWS codebase as soon as possible, hopefully tomorrow (5 feb). Is there anything I should be aware off? Thanks Hi Arjen,
I'm trying to prepare a complete patch to alleviate the task of integrating the code. As I changed the signature of secureMessage & validateMessage to take message context as a parameter, there is a slight impact on the code of XwsSecurityInterceptor and its unit tests. Update:
The archive contains a patch of the modified spring-ws classes (security module):
Remarks:
That's what I can think of for the moment. I you need more details or help please let me know. Ok, I've started incorporating this in the code base. Thanks again, Tareq!
Fixed. Many thanks to Tareq Abed Rabbo, for doing the hard work!
Note that the WSS4J still needs full reference documentation ( |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||