Generate web service client secure policy from .wsdl for java

user2162417

I have been researching how to implement a web service client policies from a .wsdl file.

The policies of the web services implicates a signature and encryption using a .jks file with the necessary keys (asymmetric privateKey for signing, and a symmetric privateKey for encryption). The policy is: username:oracle/wss10_username_token_with_message_protection_service_policy.

I am able to make the .xsd files (request, response and service objects) using the wsimport tool for java (or with cxf or axis2). What i can't resolve is how to make the correct policy.

Is there any way to automatically generate the policies from the .wsdl or do i have to make them by myself

user2162417

The username:oracle/wss10_username_token_with_message_protection_service_policy is solved with spring ws this way:

<!-- == Ougoing interceptor == -->
<bean id="loginOutgoingWss4jSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor">
    <property name="securementActions" value="Timestamp Signature Encrypt" />

    <!--  == Set Outgoing Signature properties == -->
    <property name="securementUsername" value="alias"/>
    <property name="securementPassword" value="aliasPass"/>
    <property name="securementSignatureKeyIdentifier" value="DirectReference"/>
    <property name="securementSignatureCrypto" ref="cryptoFactoryBean" />
    <property name="securementSignatureParts" value="{Element}{}Body;{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;" />

    <!--  == Set Outgoing Encryption properties == -->
    <property name="securementEncryptionUser" value="alias"/> 
    <property name="securementEncryptionCrypto" ref="cryptoFactoryBean" />
    <property name="securementEncryptionKeyIdentifier" value="DirectReference"/>
    <property name="securementEncryptionParts" value="{Content}{}Body;" />
</bean>

<!-- == Incoming interceptor == -->
 <bean id="loginIncomingWss4jSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor">
    <property name="validationActions" value="Timestamp Signature Encrypt" />

    <!--  == Set Validations Response, This validate signature and decrypts response == -->
    <property name="validateResponse" value="true" />

    <!-- The lower operation validation. Less time consume-->
    <property name="validateRequest" value="false" />
    <property name="enableSignatureConfirmation" value="false"/>

    <!--  == Set Incoming Signature/Decryption keystore == -->
    <property name="validationDecryptionCrypto" ref="cryptoFactoryBean" />
    <property name="validationSignatureCrypto" ref="cryptoFactoryBean" />

    <!-- Sets the {@link org.apache.ws.security.WSPasswordCallback} handler to use when validating messages -->
    <property name="validationCallbackHandler">
        <bean class="org.springframework.ws.soap.security.wss4j2.callback.KeyStoreCallbackHandler">
            <property name="privateKeyPassword" value="aliasPass"/>
        </bean>
    </property> 
 </bean>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From wsdl to client java web service(Server has self signed certificate)

How to generate mock web service using WSDL in Java?

Consuming secure web service from JAVA

CXF create web service client from wsdl programmatically

Impossible to generate java client code from some wsdl

What is the easiest way to generate a Java client from an RPC encoded WSDL

How to generate a web service client in Java using Eclipse

ServiceConstructionException when creating a CXF web service client (scala+java+wsdl2java)

Generate WSDL from java class\source

Can't generate java code from WSDL

How to generate java classes from WSDL file

Creating a web-service client with a known but inaccessible wsdl

Embedding the WSDL for a web service in a JAX-WS client .jar

creating a client to call a web service without a wsdl in c#

Problem generating Java SOAP web services client with JDK tool wsimport from a WSDL generated by a .NET 2.0 application

How to generate client stubs from wsdl over https?

Error when trying to generate service reference from wsdl

How to consume liferay web service written in liferay from java client?

How to generate WebService client with CXF wsdl2java for online WSDL URL link

Generate from WSDL is failing

Generating client web services from Onvif wsdl file

How to create a client web service that send data with secure token to another soap web service in C#?

WSDL Web Service returns empty array from C#

Specifying Package Name When Using Maven to Generate Java from WSDL

Generate classes java from a wsdl url - returning error 401

Java generate secure certificate

Generate WSDL file from WSDL URL

How to connect to WSDL web service?

How to consume WSDL web service