WS-SecurityPolicy - 6.2

Talend ESB Service Developer Guide

EnrichVersion
6.2
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
Installation and Upgrade
EnrichPlatform
Talend ESB

CXF 2.2 introduced support for using WS-SecurityPolicy to configure WSS4J instead of the custom configuration documented on the WS-Security page. However, all of the "background" material on the WS-Security page still applies and is important to know. WS-SecurityPolicy just provides an easier and more standards based way to configure and control the security requirements. With the security requirements documented in the WSDL as WS-Policy fragments, other tools such as .NET can easily know how to configure themselves to inter-operate with CXF services.

Enabling WS-SecurityPolicy

In CXF 2.2, if the cxf-rt-ws-policy and cxf-rt-ws-security modules are available on the classpath, the WS-SecurityPolicy stuff is automatically enabled. Since the entire security runtime is policy driven, the only requirement is that the policy engine and security policies be available.

If you are using the full "bundle" jar, all the security and policy stuff is already included.

Policy description

With WS-SecurityPolicy, the binding and/or operation in the wsdl references a WS-Policy fragment that describes the basic security requirements for interacting with that service. The WS-SecurityPolicy specification allows for specifying things like asymmetric/symmetric keys, using transports (https) for encryption, which parts/headers to encrypt or sign, whether to sign then encrypt or encrypt then sign, whether to include timestamps, whether to use derived keys, etc... Basically, it describes what actions are necessary to securely interact with the service described in the WSDL.

However, the WS-SecurityPolicy fragment does not include "everything" that is required for a runtime to be able to able to create the messages. It does not describe things such as locations of key stores, user names and passwords, etc... Those need to be configured in at runtime to augment the WS-SecurityPolicy fragment.

Configuring the extra properties

There are several extra properties that may need to be set to provide the additional bits of information to the runtime.

Table 1. User Properties

security.username

The user's name. It is used differently by each of the Security functions, see the JavaDoc for more information.

security.password

The user's password when security.callback-handler is not defined. It is currently only used for the case of adding a password to a UsernameToken. See the JavaDoc for more information.

security.signature.username

The user's name for signature. It is used as the alias name in the keystore to get the user's cert and private key for signature. See the JavaDoc for more information.

security.encryption.username

The user's name for encryption. It is used as the alias name in the keystore to get the user's public key for encryption. See the JavaDoc for more information.


Table 2. Callback Class and Crypto properties

security.callback-handler

The WSS4J security CallbackHandler class used for passwords.

security.saml-callback-handler

The SAML CallbackHandler class used to construct SAML Assertions.

security.signature.properties

The Crypto property configuration to use for signature, if "security.signature.crypto" is not set instead.

security.encryption.properties

The Crypto property configuration to use for encryption, if "security.encryption.crypto" is not set instead.

security.signature.crypto

A Crypto object to be used for signature. If this is not defined then "security.signature.properties" is used instead.

security.encryption.crypto

A Crypto object to be used for encryption. If this is not defined then "security.encryption.properties" is used instead.


Table 3. Boolean Security configuration tags (true or false values only)

Constant

Default

Description

security.validate.token

true

Whether to validate the password of a received UsernameToken or not.

security.enableRevocation

false

Whether to enable Certificate Revocation List (CRL) checking or not when verifying trust in a certificate.

security.username-token.always.encrypted

true

Whether to always encrypt UsernameTokens that are defined as a SupportingToken. This should not be set to false in a production environment, as it exposes the password (or the digest of the password) on the wire.

security.is-bsp-compliant

true

Whether to enforce compliance with the Basic Security Profile (BSP) 1.1 or not.

security.self-sign-saml-assertion

false

Whether to self-sign a SAML Assertion or not. If this is set to true, then an enveloped signature will be generated when the SAML Assertion is constructed.

security.enable.nonce.cache

(varies)

Whether to cache UsernameToken nonces. See See the JavaDoc for more information.

security.enable.timestamp.cache

(varies)

Whether to cache Timestamp Created Strings. See the JavaDoc for more information.


Table 4. Non-boolean Security Configuration parameters

security.timestamp. timeToLive

The time in seconds to append to the Creation value of an incoming Timestamp to determine whether to accept the Timestamp as valid or not. The default value is 300 seconds (5 minutes).

security.timestamp. futureTimeToLive

This configuration tag specifies the time in seconds in the future within which the Created time of an incoming Timestamp is valid. The default value is 60 seconds. See the JavaDoc for more information.

security. saml-role-attributename

The attribute URI of the SAML AttributeStatement where the role information is stored. The default is "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role".

security.kerberos.client

A reference to the Kerberos client object class used to obtain a service ticket.

security.spnego.client.action

The SpnegoClientAction implementation to use for SPNEGO. This allows the user to plug in a different implementation to obtain a service ticket.

security.kerberos.jaas.context

The JAAS Context name to use for Kerberos. This is currently only supported for SPNEGO.

security.kerberos.spn

The Kerberos Service Provider Name (spn) to use. This is currently only supported for SPNEGO.

security.nonce.cache.instance

This holds a reference to a ReplayCache instance used to cache UsernameToken nonces. The default instance that is used is the EHCacheReplayCache.

security.timestamp.cache.instance

This holds a reference to a ReplayCache instance used to cache Timestamp Created Strings. The default instance that is used is the EHCacheReplayCache.

security.cache.config.file

Set this property to point to a configuration file for the underlying caching implementation. The default configuration file that is used is cxf-ehcache.xml in the cxf-rt-ws-security module.

org.apache.cxf.ws.security. tokenstore.TokenStore

The TokenStore instance to use to cache security tokens. By default this uses the EHCacheTokenStore if EhCache is available. Otherwise it uses the MemoryTokenStore

security.subject.cert.constraints

A comma separated String of regular expressions which will be applied to the subject DN of the certificate used for signature validation, after trust verification of the certificate chain associated with the certificate. These constraints are not used when the certificate is contained in the keystore (direct trust).


Table 5. Validator implementations for validating received security tokens

security.ut.validator

The WSS4J Validator instance to use to validate UsernameTokens. The default value is the UsernameTokenValidator.

security.saml1.validator

The WSS4J Validator instance to use to validate SAML 1.1 Tokens. The default value is the SamlAssertionValidator.

security.saml2.validator

The WSS4J Validator instance to use to validate SAML 2.0 Tokens. The default value is the SamlAssertionValidator.

security.timestamp.validator

The WSS4J Validator instance to use to validate Timestamps. The default value is the TimestampValidator.

security.signature.validator

The WSS4J Validator instance to use to validate trust in credentials used in Signature verification. The default value is the SignatureTrustValidator.

security.bst.validator

The WSS4J Validator instance to use to validate BinarySecurityTokens. The default value is the NoOpValidator.

security.sct.validator

The WSS4J Validator instance to use to validate SecurityContextTokens. The default value is the NoOpValidator.


Table 6. STS Client Configuration tags

security.sts.client

A reference to the STSClient class used to communicate with the STS.

security.sts.applies-to

The "AppliesTo" address to send to the STS. The default is the endpoint address of the service provider.

security.sts.token.usecert

If true, writes out an X509Certificate structure in UseKey/KeyInfo. If false (the default), writes out a KeyValue structure instead.

security.sts.token.do.cancel

Whether to cancel a token when using SecureConversation after successful invocation. The default is "false".

security.cache.issued. token.in.endpoint

Set this to "false" to not cache a SecurityToken per proxy object in the IssuedTokenInterceptorProvider. This should be done if a token is being retrieved from an STS in an intermediary. The default value is "true".

security.sts.disable-wsmex-call-using-epr-address

Whether to avoid STS client trying send WS-MetadataExchange call using STS EPR WSA address when the endpoint contract contains no WS-MetadataExchange info. The default value is "false".

security.sts.token.crypto

A Crypto object to be used for the STS. See the JavaDoc for more information.

security.sts.token.properties

The Crypto property configuration to use for the STS. See the JavaDoc for more information.

security.sts.token.username

The alias name in the keystore to get the user's public key to send to the STS for the PublicKey KeyType case.

security.sts.token.act-as

The token to be sent to the STS in an "ActAs" field. See the JavaDoc for more information.

security.sts.token.on-behalf-of

The token to be sent to the STS in an "OnBehalfOf" field. See the JavaDoc for more information.


Note: for Symmetric bindings that specify a protection token, the security-encryption properties are used.

Configuring via Spring

The properties are easily configured as client or endpoint properties--use the former for the SOAP client, the latter for the web service provider.

<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 name="{http://cxf.apache.org}MyPortName"
      createdFromAPI="true">
      <jaxws:properties>
         <entry key="security.callback-handler"
             value="interop.client.KeystorePasswordCallback"/>
         <entry key="security.signature.properties"
             value="etc/client.properties"/>
         <entry key="security.encryption.properties"
             value="etc/service.properties"/>
         <entry key="security.encryption.username"
             value="servicekeyalias"/>
      </jaxws:properties>
   </jaxws:client>
 
</beans>

For the jaxws:client's name attribute above, use the namespace of the WSDL along with the name attribute of the desired wsdl:port element under the WSDL's service section. (See here and here for an example.)

<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:endpoint
      id="MyService"
      address="https://localhost:9001/MyService"
      serviceName="interop:MyService"
      endpointName="interop:MyServiceEndpoint"
      implementor="com.foo.MyService">
 
      <jaxws:properties>
         <entry key="security.callback-handler"
             value="interop.client.UTPasswordCallback"/>
         <entry key="security.signature.properties"
             value="etc/keystore.properties"/>
         <entry key="security.encryption.properties"
             value="etc/truststore.properties"/>
         <entry key="security.encryption.username"
             value="useReqSigCert"/>
      </jaxws:properties>
 
   </jaxws:endpoint>
</beans>
Configuring via API's

Configuring the properties for the client just involves setting the properties in the client's RequestContext:

Map<String, Object> ctx = ((BindingProvider)port).getRequestContext();
ctx.put("security.encryption.properties", properties);
port.echoString("hello");