Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
9.2. STS Demonstration
9.2.1. Overview of the Demonstration Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
CXFInstallDir/samples/sts
CXFInstallDir/samples/sts
The demonstration scenario Copier lienLien copié sur presse-papiers!
Figure 9.5. STS Demonstration Scenario
The client-STS connection Copier lienLien copié sur presse-papiers!
The client-server connection Copier lienLien copié sur presse-papiers!
greetMe
WSDL operation. This connection is secured by an asymmetric binding (for message protection and authentication).
Invocation steps Copier lienLien copié sur presse-papiers!
- The secure invocation is initiated when the client calls the
greetMe()
method. - Before sending a request message to the server, the client must ask the STS to issue the token that will be used for single sign-on. The client delegates this task to the
STSClient
bean, which is itself a fully-fledged WS client that can communicate with the STS.To establish the connection to the STS, theSTSClient
bean must initialize a symmetric binding, as follows:- The
STSClient
generates an ephemeral key (the symmetric session key). - The
STSClient
encrypts the ephemeral key using the STS public key (X.509 certificate). - The ephemeral key is then used for signing and encrypting the SOAP message parts sent between the
STSClient
bean and the STS.
- The
STSClient
bean now constructs the RequestSecurityToken (RST) message, which it sends to the STS. TheSTSClient
embeds the client's X.509 certificate (to be used as the client's identity in the Holder-of-Key scenario) and the client's UsernameToken credentials (UT) into the RST message.TheSTSClient
bean now uses the RST message to invoke the STS Issue operation. - When the RST message arrives in the STS, the STS endpoint immediately tries to authenticate the embedded UsernameToken credentials. If the UsernameToken credentials could not be authenticated, the message would be rejected.
- The STS now processes the issue token request. The RST asks the STS to generate a SAML token, using the client's X.509 certificate as the Holder-of-Key identity. The STS constructs a RequestSecurityTokenResponse (RSTR) message containing a SAML token, taking care to sign the generated SAML token using the STS signing key.
- The STS returns the RSTR message containing the signed SAML token.
- The client is now ready to send the
greetMe
request to the server. The signed SAML token that was issued by the STS is embedded in the SOAP security header of the request message. - The first thing that the server does is to check that the SAML token is signed by the STS public key. To be more precise, what the server actually does is to check whether the SAML token is signed by any trusted key—that is, any of the public keys that can be found in the
servicestore.jks
keystore file.If the SAML token is not signed by a trusted key, the message is rejected, because it is then impossible to establish trust in the SAML token. - The server now performs the Holder-of-Key check, to establish the client's identity (effectively, authenticating the client).The X.509 certificate embedded in the SAML token is meant to be the client identity, but the client must also prove that it possesses the corresponding private key for the certificate, in order to be authentic. It turns out that, as part of the natural configuration of the asymmetric binding policy, the client is configured to sign various parts of the SOAP message using the
myclientkey
private key. The server therefore checks all of the message's signing keys and if it finds one that matches the X.509 certificate in the SAML token, it knows that the client is in possession of the private key. - If all of the security checks have been successful, the server now invokes the implementation of the
greetMe
WSDL operation.
Single-sign on and scalability Copier lienLien copié sur presse-papiers!
myservicekey
certificate). The server's certificate must be distributed to the clients using some out-of-band approach, which creates some extra work when scaling up to a large system.
9.2.2. STS WSDL Contract Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
Location of the STS WSDL contract Copier lienLien copié sur presse-papiers!
CXFInstallDir/samples/sts/wsdl/ws-trust-1.4-service.wsdl
CXFInstallDir/samples/sts/wsdl/ws-trust-1.4-service.wsdl
Parts of the contract Copier lienLien copié sur presse-papiers!
- STS port type—the standard WSDL port type for the STS, as defined the WS-Trust specification.NoteThere are some other standard WSDL port types defined in the WSDL file, but these port types are not used in this demonstration.
- WSDL binding—the SOAP binding for the STS port type. Policies are enabled by applying them to various parts of the WSDL binding.
- WSDL service and port—the WSDL port element specifies the address of the STS Web service endpoint.
- Binding policy—a WS-Policy element that specifies how connections to the STS must be secured.
- Signed/encrypted parts policies—a WS-Policy element for input messages and a WS-Policy element for output messages, specifying which parts of the incoming SOAP messages and the outgoing SOAP messages must be signed and encrypted.
STS port type Copier lienLien copié sur presse-papiers!
WSDL binding Copier lienLien copié sur presse-papiers!
wsdl2soap
utility), except for the wsp:PolicyReference
elements, which are used to apply the relevant security policies to the binding. Hence, the policy identified by UT_policy
is applied to the whole binding and the Input_policy
and the Output_policy
are applied respectively to the input messages and the output messages of each operation.
WSDL service and port Copier lienLien copié sur presse-papiers!
location
attribute of soap:address
).
Binding policy Copier lienLien copié sur presse-papiers!
UT_policy
, defines what kind of security is applied to incoming STS connections.
sp:ProtectionToken
element (which is ultimately configured to be the mystskey
private key and X.509 certificate on the STS server). The client is required to include a WSS UsernameToken in the SOAP security header, which is used by the STS to authenticate the client.
Signed parts and encrypted parts policies Copier lienLien copié sur presse-papiers!
Input_policy
policy is used to specify exactly which parts of an input message should be encrypted and/or signed by the symmetric session keys. In addition to signing and encrypting the SOAP body, the standard WS-Addressing SOAP headers are also signed (which protects them from tampering by third-parties).
Output_policy
policy is used to specify exactly which parts of an output message should be encrypted and/or signed by the symmetric session keys.
9.2.3. Security Token Service Configuration Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
Figure 9.6. Demonstration STS Configuration
Aspects of configuration Copier lienLien copié sur presse-papiers!
- WSDL contract and security policies—as already discussed in Section 9.2.2, “STS WSDL Contract”, the policies in the WSDL contract are used to define the type of security that protects incoming connections to the STS. In particular, it is important that some form of client authentication is required by these security policies.
- STS plug-in configuration—as described in Section 9.1.1, “Overview of the STS”, the STS has a plug-in architecture. In order to instantiate an STS server, you must assemble and configure the STS plug-ins that you want to use.
- STS signing key—you must configure the STS with its own signing key, which effectively provides the stamp of authenticity for any tokens issued by the STS.
- List of known Web service endpoints—you can optionally install a service plug-in into the STS, which is used to define a list of known Web service endpoints that can use the STS (see Section 9.4, “Enabling AppliesTo in the STS”).
- JAX-WS endpoint configuration—you must define a Web service endpoint for the STS, which clients use to connect to the STS. In the JAX-WS endpoint you specify the X.509 certificate and private key that are used as the protection token in the symmetric binding and you also specify a callback handler, that accesses the database of UsernameToken credentials for authenticating clients.
Location of the STS Spring configuration Copier lienLien copié sur presse-papiers!
CXFInstallDir/samples/sts/src/main/resources/wssec-sts.xml
CXFInstallDir/samples/sts/src/main/resources/wssec-sts.xml
STS plug-in configuration Copier lienLien copié sur presse-papiers!
wssec-sts.xml
Spring configuration file is concerned with instantiating the STS implementation and specifying the relevant STS plug-ins to use:
utIssueDelegate
bean, and Validate, implemented by the utValidateDelegate
bean. The Validate operation is not used in the current demonstration.
utIssueDelegate
bean is configured with the following properties:
tokenProviders
- A list of plug-ins that can generate various kinds of token. In this demonstration, this list is initialized with a single provider,
SAMLTokenProvider
, which is capable of generating SAML tokens. services
- (Optional) The
services
property enables you to specify the Web services that are secured by the STS, by specifying a list of regular expressions that must match the Web service URLs. stsProperties
- The
stsProperties
specifies some generic configuration settings that are common to many of the plug-ins in the STS.
STS signing key Copier lienLien copié sur presse-papiers!
StaticSTSProperties
class:
signaturePropertiesFile
- A WSS4J properties file that defines the properties for accessing the
keys/stsstore.jks
Java keystore file. signatureUsername
- The alias of the STS signing key in the Java keystore file.
callbackHandlerClass
- A callback handler class that returns the password for accessing the STS signing key.
StaticSTSProperties
class is instantiated as the utSTSProperties
bean in the wssec-sts.xml
configuration file:
List of known Web service endpoints Copier lienLien copié sur presse-papiers!
utService
bean enables you to specify the Web service endpoints that are known to the STS, as follows:
utEndpoints
bean instantiates a java.util.List
object containing a list of regular expressions that must match the server's endpoint URL. When a client requests a new token from the STS, it includes the server's endpoint URL in the request, so that the STS can check whether or not the target endpoint is a known endpoint.
JAX-WS endpoint configuration Copier lienLien copié sur presse-papiers!
jaxws:element
, as follows:
jaxws:endpoint
element defines properties for accessing the protection token and a reference to a callback handler instance.
Protection token for the symmetric binding Copier lienLien copié sur presse-papiers!
jaxws:endpoint
are, in fact, used to specify the protection token:
ws-security.signature.properties
- A WSS4J properties file that defines the properties for accessing the
keys/stsstore.jks
Java keystore file. ws-security.signature.username
- The alias of the protection token (X.509 certificate and private key pair) in the Java keystore file.
ws-security.callback-handler
- A callback handler class that returns the password for accessing the protection token.
STS callback handler Copier lienLien copié sur presse-papiers!
jaxws:endpoint
element is also configured with a callback handler (through the ws-security.callback-handler
property), as follows:
jaxws:element
is used for the following purposes:
- Retrieving the password for the protection tokenthe protection token consists of a private key/public key pair and a password is needed to access the private key (which is stored in a Java keystore file).
- Retrieving the password for a client's UsernameToken credentialsthe symmetric binding policy in this demonstration requires the client to send UsernameToken credentials to the STS, for the purpose of authenticating the client. The callback handler must therefore have access to a database of UsernameToken credentials, in order to authenticate the incoming UsernameToken credentials. In this example, just a single UsernameToken credential is supported, with username,
alice
, and password,clarinet
.NoteIn an enterprise security system, it is more likely that you would use an LDAP server to store the client UsernameToken credentials.
9.2.4. Server WSDL Contract Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
InitiatorToken
is specified by an IssuedToken
policy element. It is the presence of the IssuedToken
element in the policy which triggers the client to call out to the STS, requesting the STS to issue a SAML token for single sign-on.
Location of the server WSDL contract Copier lienLien copié sur presse-papiers!
CXFInstallDir/samples/sts/wsdl/hello_world.wsdl
CXFInstallDir/samples/sts/wsdl/hello_world.wsdl
Parts of the contract Copier lienLien copié sur presse-papiers!
- Greeter port type—a simple hello world interface consisting of a single WSDL operation,
greetMe
. - WSDL binding—the SOAP binding for the
Greeter
port type. Policies are enabled by applying them to various parts of the WSDL binding. - WSDL service and port—the WSDL port element specifies the address of the
Greeter
Web service endpoint. - Binding policy—a WS-Policy element that specifies how connections to the server must be secured.
- Signed/encrypted parts policies—a WS-Policy element for input messages and a WS-Policy element for output messages, specifying which parts of the incoming SOAP messages and the outgoing SOAP messages must be signed and encrypted.
Greeter port type Copier lienLien copié sur presse-papiers!
Greeter
port type defines the logical interface to the Web service provided by the server, as follows:
Binding Copier lienLien copié sur presse-papiers!
Greeter
port type is a regular SOAP binding, except for the wsp:PolicyReference
elements, which are used to apply the relevant security policies to the binding. Hence, the policy identified by AsymmetricSAML2Policy
is applied to the whole binding and the Input_policy
and the Output_policy
are applied respectively to the input messages and the output messages of each operation.
Service and port Copier lienLien copié sur presse-papiers!
Greeter
WS endpoint (specified by the location
attribute of soap:address
).
Binding policy Copier lienLien copié sur presse-papiers!
AsymmetricSAML2Policy
, defines what kind of security is applied to incoming server connections.
Greeter
server security policy to be an asymmetric binding. This implies that security is applied at the SOAP message level, where parts of the SOAP payload are liable to be encrypted and/or signed. Because this is an asymmetric binding, two keys must be provided:
- Initiator token—a SAML token, which has the client's X.509 certificate embedded inside it. Because the initiator token is defined to be an
IssuedToken
token, it is actually obtained by the querying the STS (using anSTSClient
object). - Recipient token—an X.509 certificate (public key) and private key pair, which is provided by the server side.
IssuedToken policy Copier lienLien copié sur presse-papiers!
IssuedToken
policy, which is the IntiatorToken in the server's asymmetric binding. It is defined as follows:
IssuedToken
policy is the key component of WS-Trust. It triggers the client to request an issued token from the STS. The sp:RequestSecurityTokenTemplate
element specifies some elements that are to be included in the request that is sent to the STS. It includes the following elements:
<t:TokenType>...#SAMLV2.0</t:TokenType>
- Indicates that the client wishes the STS to issue a SAML 2.0 token.
<t:KeyType>.../PublicKey</t:KeyType>
- Indicates that the client wants the STS to support the Holder-of-Key scenario, where an X.509 certificate (public key) is used to verify the client identity. This implies that the client's X.509 certificate will be included in the request sent to the STS.
Signed parts and encrypted parts policies Copier lienLien copié sur presse-papiers!
Input_policy
policy is used to specify exactly which parts of an input message should be encrypted and/or signed by the asymmetric session keys (initiator token and recipient token). In addition to signing and encrypting the SOAP body, the standard WS-Addressing SOAP headers are also signed (which protects them from tampering by third-parties).
Output_policy
policy is used to specify exactly which parts of an output message should be encrypted and/or signed by the asymmetric session keys (initiator token and recipient token).
9.2.5. Server Configuration Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
Figure 9.7. Demonstration Server Configuration
Aspects of configuration Copier lienLien copié sur presse-papiers!
- WSDL contract and security policies—as already discussed in Section 9.2.4, “Server WSDL Contract”, the policies in the WSDL contract are used to define the type of security that protects incoming connections to the
Greeter
server. - JAX-WS endpoint configuration—in the JAX-WS endpoint you specify the X.509 certificate and private key that are used as the recipient token in the asymmetric binding and you also specify the certificate (or certificates) for checking the signature of a SAML token.
- Recipient token—is specified by setting the relevant properties in the JAX-WS endpoint configuration.
- Server-side SAML token interceptor—the SAML token interceptor checks the signature of the SAML token, using the X.509 certificates (public keys) stored in the keystore file referenced by the
ws-security.encryption.properties
property. - Server callback handler—is used to provide the passwords for private keys.
- Related STS configuration—when setting up a new server, you must remember to add an appropriate regular expression to the list of known Web service endpoints in the STS, or the STS will refuse to perform any operations for this server.
JAX-WS endpoint configuration Copier lienLien copié sur presse-papiers!
jaxws:element
, as follows:
jaxws:endpoint
element defines properties for accessing the recipient token, properties for accessing SAML signature-checking tokens, and a reference to a callback handler instance.
Recipient token Copier lienLien copié sur presse-papiers!
jaxws:endpoint
element:
ws-security.signature.properties
- A WSS4J properties file that defines the properties for accessing the private key part of the recipient token.
ws-security.signature.username
- The alias of the recipient token (X.509 certificate and private key pair) in the Java keystore file.
ws-security.callback-handler
- A callback handler class that returns the password for accessing the private key part of the recipient token.
ws-security.encryption.properties
- A WSS4J properties file that defines the properties for accessing the public key part of the recipient token.
Server-side SAML token interceptor Copier lienLien copié sur presse-papiers!
IssuedToken
policy. The SAML token interceptor is responsible for verifying the signature of the SAML token received from the client (initiator token).
ws-security.encryption.properties
property. Any trusted certificates found in the Java keystore file specified by ws-security.encryption.properties
will be used for checking the signature of the SAML token. The configuration of the SAML token interceptor is thus the very same configuration that was used to specify the public key part of the recipient token:
ws-security.encryption.properties
.
Server callback handler Copier lienLien copié sur presse-papiers!
jaxws:endpoint
element is also configured with a callback handler (through the ws-security.callback-handler
property), as follows:
myservicekey
).
Related STS configuration Copier lienLien copié sur presse-papiers!
wssec-sts.xml
file as follows:
9.2.6. Client Configuration Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
Figure 9.8. Demonstration Client Configuration
Aspects of configuration Copier lienLien copié sur presse-papiers!
- Configure the connection to the STS (STSClient)—the client uses an
STSClient
instance to connect to the STS. TheSTSClient
instance is a complete client in itself, requiring you to specify the STS Web service address and to specify the relevant security properties for the connection. - Configure the connection to the server—the client must also be configured to connect to the server, including the relevant security properties for the connection and a reference to the
STSClient
instance. - Client callback handler—is used to provide the passwords for private keys and to provide the passwords for UsernameToken credentials.
- Related STS configuration—you must ensure that the client's UsernameToken credentials are made available to the STS, so that the client can be authenticated.
Configure the connection to the STS Copier lienLien copié sur presse-papiers!
ws-security.sts.client
property with an STSClient
instance, as follows:
wsdlLocation
, serviceName
, and endpointName
properties), you must set the following security-related properties:
ws-security.username
- In this demonstration, the STS is configured to authenticate the client using UsernameToken credentials. This property specifies the username part of the UsernameToken credentials.
ws-security.callback-handler
- The callback handler class provides both private key passwords and UsernameToken passwords.
ws-security.encryption.properties
- A WSS4J properties file that defines the properties for accessing the STS X.509 certificate. This certificate is needed by the symmetric binding protocol, which uses it to generate a symmetric session key.
ws-security.encryption.username
- The alias of the X.509 certificate referenced by
ws-security.encryption.properties
. ws-security.sts.token.properties
- A WSS4J properties file that defines the properties for accessing the client's X.509 certificate. This is the certificate that is used to identify the client to the server in the Holder-of-Key scenario. This token gets embedded in the request that is sent to the STS (and is also embedded in the SAML token returned from the STS).
ws-security.sts.token.username
- The alias of the STS X.509 certificate referenced by
ws-security.sts.token.properties
. ws-security.sts.token.usecert
- Setting this boolean property to
true
indicates that the specified token should be included in the request sent to the STS (theRequestSecurityToken
message).
Configure the connection to the server Copier lienLien copié sur presse-papiers!
ws-security.signature.properties
- A WSS4J properties file that defines the properties for accessing the client's signing key.
ws-security.signature.username
- The alias of the client's signing key in the corresponding Java keystore file.
ws-security.callback-handler
- The callback handler instance that can return the password for accessing the client's signing key.
ws-security.encryption.properties
- A WSS4J properties file that defines the properties for accessing the client's encryption key (X.509 certificate).
ws-security.encryption.username
- The alias of the client's encryption key in the corresponding Java keystore file.
ws-security.sts.client
property, as already described in the section called “Configure the connection to the STS”.
Client callback handler Copier lienLien copié sur presse-papiers!
Related STS configuration Copier lienLien copié sur presse-papiers!
9.2.7. Build and Run the Demonstration Copier lienLien copié sur presse-papiers!
Steps to run the demonstration Copier lienLien copié sur presse-papiers!
- Open a command prompt and change directory to the
CXFInstallDir/samples/sts
directory. Enter the following command to build the demonstration:mvn clean install
mvn clean install
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To start the STS process, enter the following command:
mvn -Psts
mvn -Psts
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To start the WS server process, open a new command prompt, change directory to the
CXFInstallDir/samples/sts
directory, and enter the following command:mvn -Pserver
mvn -Pserver
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To run the WS client, open a new command prompt, change directory to the
CXFInstallDir/samples/sts
directory, and enter the following command:mvn -Pclient
mvn -Pclient
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Because CXF logging has been enabled, you should see the SOAP messages being logged to each of the command windows. If the client runs successfully, you should see the following message in the client command window:... -------------------------------------- Server responded with: Hello YourName
... -------------------------------------- Server responded with: Hello YourName
Copy to Clipboard Copied! Toggle word wrap Toggle overflow