I am new to Spring WS and I make some changes to the airline-server & airline-client-spring-ws sample to try the WS signature. However, server can verify the client request but client fails to verify the server response with following error: Would any experts here give me a helping hand? thanks
Client securityPolicy.xmlCode:May 29, 2012 4:29:15 PM com.sun.xml.wss.impl.dsig.KeySelectorImpl resolveToken SEVERE: WSS1364: Unable to validate certificate May 29, 2012 4:29:15 PM com.sun.xml.wss.impl.dsig.KeySelectorImpl resolve SEVERE: WSS1353: Error occurred while resolving key information Throwable occurred: com.sun.xml.wss.impl.WssSoapFaultException: Certificate validation failed at com.sun.xml.wss.impl.SecurableSoapMessage.newSOAPFaultException(SecurableSoapMessage.java:336) at com.sun.xml.wss.impl.dsig.KeySelectorImpl.resolveToken(KeySelectorImpl.java:1332) at com.sun.xml.wss.impl.dsig.KeySelectorImpl.resolve(KeySelectorImpl.java:640) at com.sun.xml.wss.impl.dsig.KeySelectorImpl.select(KeySelectorImpl.java:246) at org.jcp.xml.dsig.internal.dom.DOMXMLSignature$DOMSignatureValue.validate(Unknown Source) at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.validate(Unknown Source) at com.sun.xml.wss.impl.dsig.SignatureProcessor.verify(SignatureProcessor.java:786) at com.sun.xml.wss.impl.filter.SignatureFilter.process(SignatureFilter.java:537) at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:93) at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:268) at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:863) at com.sun.xml.wss.impl.SecurityRecipient.processMessagePolicy(SecurityRecipient.java:815) at com.sun.xml.wss.impl.SecurityRecipient.validateMessage(SecurityRecipient.java:256) at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.verifyInboundMessage(XWSSProcessor2_0Impl.java:148) at org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.validateMessage(XwsSecurityInterceptor.java:162) at org.springframework.ws.soap.security.AbstractWsSecurityInterceptor.handleResponse(AbstractWsSecurityInterceptor.java:235) at org.springframework.ws.client.core.WebServiceTemplate.triggerHandleResponse(WebServiceTemplate.java:732) at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:595) at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537) at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492) at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:436) at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:427) at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:417)
client spring configCode:<?xml version="1.0" encoding="UTF-8"?> <xwss:SecurityConfiguration dumpMessages="true" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config"> <xwss:Sign includeTimestamp="true"> </xwss:Sign> <xwss:RequireSignature requireTimestamp="true" /> </xwss:SecurityConfiguration>
Server securityPolicy.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> <bean id="abstractClient" abstract="true"> <constructor-arg ref="messageFactory" /> <property name="defaultUri" value="http://localhost:18080/SpringWS-airline-server/services" /> </bean> <bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" /> <bean id="getFlights" parent="abstractClient" class="org.springframework.ws.samples.airline.client.sws.GetFlights"> <property name="marshaller" ref="marshaller" /> <property name="unmarshaller" ref="marshaller" /> </bean> <bean id="getFrequentFlyerMileage" parent="abstractClient" class="org.springframework.ws.samples.airline.client.sws.GetFrequentFlyerMileage"> <property name="interceptors" ref="securityInterceptor2" /> </bean> <bean id="securityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"> <property name="securementActions" value="UsernameToken" /> <property name="securementUsername" value="john" /> <property name="securementPassword" value="changeme" /> </bean> <bean id="securityInterceptor2" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor"> <property name="secureRequest" value="true" /> <property name="secureResponse" value="true" /> <property name="policyConfiguration" value="classpath:org/springframework/ws/samples/airline/client/sws/securityPolicy.xml" /> <property name="callbackHandlers"> <list> <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler"> <property name="keyStore" ref="keyStore" /> <property name="trustStore" ref="trustStore" /> <property name="defaultAlias" value="WASClientCertificate" /> <property name="privateKeyPassword" value="sslwebsv" /> </bean> </list> </property> </bean> <bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean"> <property name="location" value="file:///G:/COMMON/Kelvin/SSLCert/ClientKeyStore/ClientKeyStore.jks" /> <property name="password" value="sslwebsv" /> </bean> <bean id="trustStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean"> <property name="location" value="file:///G:/COMMON/Kelvin/SSLCert/ClientTrustStore/ClientTrustStore.jks" /> <property name="password" value="sslwebsv" /> </bean> </beans>
Server Spring config:Code:<?xml version="1.0" encoding="UTF-8"?> <xwss:SecurityConfiguration dumpMessages="true" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config"> <xwss:Sign includeTimestamp="true"> </xwss:Sign> <xwss:RequireSignature requireTimestamp="true" /> </xwss:SecurityConfiguration>
Code:<?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:context="http://www.springframework.org/schema/context" xmlns:sws="http://www.springframework.org/schema/web-services" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd"> <sws:annotation-driven /> <sws:interceptors> <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" /> <bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"> <property name="xsdSchemaCollection" ref="schemaCollection" /> <property name="validateRequest" value="true" /> <property name="validateResponse" value="true" /> </bean> <sws:payloadRoot localPart="GetFrequentFlyerMileageRequest" namespaceUri="http://www.springframework.org/spring-ws/samples/airline/schemas/messages"> <bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor"> <property name="secureRequest" value="true" /> <property name="secureResponse" value="true" /> <property name="policyConfiguration" value="classpath:org/springframework/ws/samples/airline/security/securityPolicy.xml" /> <property name="callbackHandlers"> <list> <!-- <bean class="org.springframework.ws.soap.security.xwss.callback.SpringDigestPasswordValidationCallbackHandler"> --> <!-- <property name="userDetailsService" ref="securityService"/> --> <!-- </bean> --> <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler"> <property name="keyStore" ref="keyStore" /> <property name="trustStore" ref="trustStore" /> <property name="defaultAlias" value="WASServerCertificate" /> <property name="privateKeyPassword" value="sslwebsv" /> </bean> </list> </property> </bean> </sws:payloadRoot> </sws:interceptors> <context:component-scan base-package="org.springframework.ws.samples.airline.ws" /> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> <bean id="messageReceiver" class="org.springframework.ws.soap.server.SoapMessageDispatcher" /> <bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection"> <description> This bean wrap the messages.xsd (which imports types.xsd), and inlines them as a one. </description> <property name="xsds" value="/messages.xsd" /> <property name="inline" value="true" /> </bean> <bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean"> <property name="location" value="file:///G:/COMMON/Kelvin/SSLCert/ServerKeyStore/ServerKeyStore.jks" /> <property name="password" value="sslwebsv" /> </bean> <bean id="trustStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean"> <property name="location" value="file:///G:/COMMON/Kelvin/SSLCert/ServerTrustStore/ServerTrustStore.jks" /> <property name="password" value="sslwebsv" /> </bean> </beans>


Reply With Quote