Skip to end of metadata
Go to start of metadata

ActAs WS-Trust Scenario

The ActAs feature is used in scenarios that require composite delegation.  It is commonly used in multi-tiered systems where an application calls a service on behalf of a logged in user or a service calls another service on behalf of the original caller.

ActAs is nothing more than a new sub-element in the RequestSecurityToken (RST).  It provides additional information about the original caller when a token is negotiated with the STS.  The ActAs element usually takes the form of a token with identity claims such as name, role, and authorization code, for the client to access the service.

The ActAs scenario is an extension of the basic WS-Trust scenario.  In this example the ActAs service calls the ws-service on behalf of a user.  There are only a couple of additions to the basic scenario's code.  An ActAs web service provider and callback handler have been added.  The ActAs web services' WSDL  imposes the same security policies as the ws-provider. UsernameTokenCallbackHandler is new.  It is a utility that generates the content for the ActAs element.  And lastly there are a couple of code additions in the STS to support the ActAs request.

Web service provider

This section examines the web service elements from the basic WS-Trust scenario that have been changed to address the needs of the ActAs example.  The components are

  • ActAs web service provider's WSDL
  • ActAs web service provider's Interface and Implementation classes.
  • ActAsCallbackHandler class
  • UsernameTokenCallbackHandler
  • Crypto properties and keystore files

Web service provider WSDL

The ActAs web service provider's WSDL is a clone of the ws-provider's WSDL.  The wsp:Policy section is the same. There are  changes to the service endpoint,  targetNamespace, portType, binding name, and service.

Web Service Interface

The web service provider interface class, ActAsServiceIface, is a simple web service definition.

Web Service Implementation

The web service provider implementation class, ActAsServiceImpl, is a simple POJO.  It uses the standard WebService annotation to define the service endpoint  and two Apache WSS4J annotations, EndpointProperties and EndpointProperty used for configuring the endpoint for the CXF runtime.  The WSS4J configuration information provided is for WSS4J's Crypto Merlin implementation.

ActAsServiceImpl is calling ServiceImpl acting on behalf of the user.  Method setupService performs the requisite configuration setup.


ActAsCallbackHandler is a callback handler for the WSS4J Crypto API.  It is used to obtain the password for the private key in the keystore.  This class enables CXF to retrieve the password of the user name to use for the message signature.  This class has been revised to return the passwords for this service, myactaskey and the "actas" user, alice.


The ActAs and OnBeholdOf sub-elements of the RequestSecurityToken are required to be defined as WSSE Username Tokens.  This utility generates the properly formated element.

Crypto properties and keystore files

The ActAs service must provide its own credentials.  The requisite properties file,, and keystore, actasstore.jks, were created.


When deployed on WildFly this application requires access to the JBossWS and Apache CXF APIs provided in modules  The module is also needed in handling the ActAs and OnBehalfOf extensions.  The dependency statement directs the server to provide them at deployment.

Security Token Service

This section examines the STS elements from the basic WS-Trust scenario that have been changed to address the needs of the ActAs example.  The components are.

  • STS's implementation class.
  • STSCallbackHandler class

STS Implementation class

The initial description of SampleSTS can be found here.

The declaration of the set of allowed token recipients by address has been extended to accept ActAs addresses and OnBehalfOf addresses.  The addresses are specified as reg-ex patterns.

The TokenIssueOperation requires class, UsernameTokenValidator be provided in order to validate the contents of the OnBehalfOf claims and class, UsernameTokenDelegationHandler to be provided in order to process the token delegation request of the ActAs on OnBehalfOf user.


The user, alice, and corresponding password was required to be added for the ActAs example.

Web service requester

This section examines the ws-requester elements from the basic WS-Trust scenario that have been changed to address the needs of the ActAs example.  The component is

  • ActAs  web service requester implementation class

Web service requester Implementation

The ActAs ws-requester, the client, uses standard procedures for creating a reference to the web service in the first four lines.  To address the endpoint security requirements, the web service's "Request Context" is configured via the BindingProvider. Information needed in the message generation is provided through it.  The ActAs user, myactaskey, is declared in this section and UsernameTokenCallbackHandler is used to provide the contents of the ActAs element to the STSClient.  In this example a STSClient object is created and provided to the proxy's request context. The alternative is to provide keys tagged with the ".it" suffix as was done in the Basic Scenario client. The use of ActAs is configured through the props map using the SecurityConstants.STS_TOKEN_ACT_AS key.  The alternative is to use the STSClient.setActAs method.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.