Version 8.0 SP4
 —  Configuration  —

Security

Web Services Stack has security facilities for securing the message content, support for HTTP basic authentication, SSL support for securing the communication channel, and user authentication based on Software AG SIN LoginModules.

This document covers the following topics:


Message-Level Security

This section covers the following topics:

Overview

The symmetric message security and the asymmetric message security are both part of the WS-Security specification. Message-level security is applied between the web service client and the web service itself in both directions.

Message-level security secures the message content itself, but it does not secure the communication channel. This is in contrast to transport-level security, where the communication channel is secured. To apply message security, you have to make several configurations on both the client side and the server side.

There are many different ways you can configure message-level security, based on your security needs. For examples, see Web Services Security: SOAP Message Security 1.1 and WS-Security Policy Language.

Web Services Stack provides an Eclipse plug-in graphical user interface that can be used to create the needed security configuration. You can install the plug-in in Eclipse and use it to create web service archives (that is, AAR archives). For more information, see Eclipse Plug-in.

Security configurations in Web Services Stack are based on WS-Security Policy specification.

Server-side Configuration

You can configure the server side by changing the properties in the services.xml file

You need a keystore file that contains the X.509 certificate of the server. It may also contain client public keys.

You can re-use initialized (loaded) keystore instances by caching them the first time they are loaded. Any other configuration (such as key aliases and password callback handlers) will be retrieved from the Rampart configuration separately for every invocation.

You have the option to set caching globally in the axis2.xml for all services that are deployed in Web Services Stack runtime, or for a service, service group, specific operation or message in the services.xml descriptor of your service. However, keep in mind that keystore caching is per message because the keystore configuration itself may be different for each message.

Start of instruction setTo enable keystore caching

Note:
When a service is undeployed or simply stopped any cached keystores will be removed. You can deactivate (stop) services using the Administration module or deacivate and undeploy (delete completely the service and all its files) using the Administration Tool of the System Management Hub.

Depending on the security policy, the client may be required to send the token used for encryption signature within the message itself. Thus, there is no need to have all client certificates at the server side. Rampart, however, still verifies whether the certificates are trustworthy and therefore requires that at least the certificate of the issuer is present in the truststore. In this case, instruct Rampart/WSS4J (used to sign the request) to use the client’s certificate.

Following is the value assigned to the <encryptionUser> field:

<encryptionUser>useReqSigCert</encryptionUser>

“useReqSigCert” is a special fictional encryption user that is recognized by the security module. In this case, your certificate (that is used to verify your signature) is used for the encryption of the response. Thus, it is possible to have only one configured encryption user for all clients that access the service.

Look at the following example of symmetric binding security configuration in the services.xml file:

<ramp:encryptionUser>client</ramp:encryptionUser>

The original value "client" is in fact an example of an alias for a client’s certificate that has to be stored into the keystore used at server side.

If you want to authenticate a client who uses a user name token, you have to provide a password callback handler class to validate the user name and the password received from the client.

When you provide a password using the callback handler class, you make a check towards a given authentication module. The module may be a JAAS module, or some other one.

Note:
This authentication mechanism applies to the user name security token and is used in a similar way with other security tokens, too.

The keystore properties can be configured by adding a Rampart custom policy assertion to the services.xml file. Following is an example of symmetric binding security configuration in the services.xml file:

<wsp:Policy wsu:Id="User defined" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
      xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsp:ExactlyOne>
        <wsp:All>
          <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
            <wsp:Policy>
              <sp:ProtectionToken>
                <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                  <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
                    <wsp:Policy>
                      <sp:WssX509V3Token10/>
                      <sp:RequireDerivedKeys/>
                    </wsp:Policy>
                  </sp:X509Token>
                </wsp:Policy>
              </sp:ProtectionToken>
              <sp:AlgorithmSuite xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                <wsp:Policy>
                  <sp:Basic128/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
  <sp:IncludeTimestamp/>
            </wsp:Policy>
          </sp:SymmetricBinding>
          <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
            <sp:Policy>
              <sp:MustSupportRefKeyIdentifier/>
              <sp:MustSupportRefIssuerSerial/>
            </sp:Policy>
          </sp:Wss10>
          <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
            <wsp:Policy/>
          </sp:SignedSupportingTokens>
          <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
            <ramp:user>service</ramp:user>
            <ramp:encryptionUser>client</ramp:encryptionUser>
            <ramp:passwordCallbackClass>com.softwareag.wsstack.pwcb.PasswordCallbackHandler</ramp:passwordCallbackClass>
            <ramp:signatureCrypto>
              <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
                <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
                <ramp:property name="org.apache.ws.security.crypto.merlin.file">service.jks</ramp:property>
                <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">openssl</ramp:property>
              </ramp:crypto>
            </ramp:signatureCrypto>
            <ramp:encryptionCypto>
              <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
                <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
                <ramp:property name="org.apache.ws.security.crypto.merlin.file">service.jks</ramp:property>
                <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">openssl</ramp:property>
              </ramp:crypto>
            </ramp:encryptionCypto>
          </ramp:RampartConfig>
        </wsp:All>
      </wsp:ExactlyOne>
    </wsp:Policy>

You can configure the keystores for signing and encrypting using the custom Rampart configuration (the code listing in bold in the preceding example.

Configurations on the server side can also be done using the Web Services Stack Eclipse plug-ins. With the Eclipse plug-in, you can complete the preceding configuration using graphical user interface.

For more information, see Eclipse Plug-in, Web Services Security: SOAP Message Security 1.1, and WS-Security Policy Language.

Client-side Configuration

When you use the client API to invoke web services that require security, you can specify security configuration settings through a properties file.

Specify in the client axis2.xml configuration file the file name and the path to it. This file must be a part of the client’s CLASSPATH file. This file holds the required parameters for the client configuration, that is, the securityConfigFile parameter:

<parameter
name="securityConfigFile">D:/wsdev/SampleWSClient/wsclientsec.properties
</parameter>

If you do not define such a parameter, the client implementation looks for a wsclientsec.properties file in the current working directory.

If a securityConfigFile parameter exists but the file specified cannot be found, you get an exception. If the parameter is not defined or a wsclientsec.properties file is not present in the current working directory, then the configuration loading routine does not throw any exceptions.

Note:
The loading of the security configuration settings takes place only if the web service policy contains security assertions (that is only if the security module is engaged).

Following is the list of the supported configuration keys:

Key Description
USERNAME This is the user's name. It is used by the WS-Security functions for the following functions:
  • The UsernameToken function sets this name in the UsernameToken.

  • The signing function uses this name as the alias name in the keystore to get the user's certificate and the private key to perform signing.

  • The encryption function uses this parameter as fallback if ENCRYPTION_USER is not set.

.
ENCRYPTION_USER

The user's name for encryption. The encryption function uses the public key of this user's certificate to encrypt the generated symmetric key. If this parameter is not set, then the encryption function falls back to the USERNAME parameter to get the certificate.

USER_CERTIFICATE_ALIAS

The alias of the key pair in the keystore, to get the private key used for the signature. If this is not set, the signature function falls back to USERNAME property.

STS_ALIAS

The STS alias is used as an encryption user in case of a STS authentication.

POLICY_VALIDATOR_CLASS

The policy validator callback class is responsible for validating the security header against the security policy. The default callback class is the org.apache.rampart.PolicyBasedResultsValidator.

TIMESTAMP_PRECISION_IN_MS

Defines whether timestamp precision is in milliseconds.

The default value is TRUE.

The expected values are TRUE or FALSE.

This parameter is passed to wss4j WSSConfig. The setting concerns the Timestamp element that may be required/ included in the security header. If the precision is set to be in milliseconds, the timestamp is written in milliseconds, otherwise the time stamp is written in the following simple date format: yyyy-MM-dd'T'HH:mm:ss'Z'

TIMESTAMP_TTL

Timestamp time-to-live in seconds. An integer value is expected. Default is 300.

TIMESTAMP_MAX_SKEW

Used in timestamp validation where the timestamp creation timestamp must not be later than current time plus the time skew. The max time skew is an integer and is expected in seconds. Default is 300.

PASSWORD_CALLBACK_HANDLER_CLASS

A class that implements the javax.security.auth.callback.CallbackHandler callback interface. The security module loads the class and calls the callback method to get the password. That class must have a public default constructor with no parameters.

OPTIMIZE_PARTS_EXPRESSIONS

A list of Xpath expressions that refer to nodes that must be MTOM-optimized. The configured value is a semicolon delimited list of Xpath expressions. Note that if this property is set, it overwrites any previously configured list of expressions and does not add them to the list.

OPTIMIZE_PARTS_NAMESPACES

A list of namespaces that is taken into consideration when searching for the nodes that are to be MTOM-optimized. It is essential for the correct retrieval of the nodes from the document, that the namespace prefixes used in the OPTIMIZE_PARTS_EXPRESSIONS list are recognized by the optimizing utility. It has by default following registered namespaces:

    xmlns:ds=http://www.w3.org/2000/09/xmldsig#
    xmlns:xenc=http://www.w3.org/2001/04/xmlenc#
    xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
    xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd

plus all the declared namespaces here. That property is expected as a semicolon delimited list of XML namespace declarations (for example, OPTIMIZE_PARTS_NAMESPACES=xmlns:ns1=http://myns1;xmlns:ns2=http://myns2 ).

Note:
If this property is set, it overwrites any previously configured list of namespaces and does not add them to the list.

CRYPTO_PROVIDER_SIGN

The WSS4J-specific Crypto implementation that is to be used for generating the signature. It can be set to one of the following:

  • org.apache.ws.security.components.crypto.Merlin is the default one if the property is not set.

  • org.apache.ws.security.components.crypto.BouncyCastle

KEYSTORE_PROVIDER_SIGN

The signature keystore provider.

If not set the JVM uses the default (normally Sun’s) keystore provider. For additional information, refer to java.security.Provider javadocs.

KEYSTORE_TYPE_SIGN The signature keystore type. If not set, the JVM uses the default keystore type (normally “jks”). For additional information, refer to the java.security.KeyStore#getDefaultType() method javadocs.
KEYSTORE_FILE_SIGN

The signature keystore file.

KEYSTORE_PASSWORD_SIGN

The signature keystore password.

CRYPTO_PROVIDER_ENCRYPT The WSS4J-specific Crypto implementation to use for encryption. It can be set to one of the following:
  • org.apache.ws.security.components.crypto.Merlin

    This is the default one if the property is not set.

  • org.apache.ws.security.components.crypto.BouncyCastle

KEYSTORE_PROVIDER_ENCRYPT

The encryption keystore provider. If not set the JVM uses the default (normally Sun’s) keystore provider.

For additional information, refer to java.security.Provider javadocs.

KEYSTORE_TYPE_ENCRYPT

The encryption keystore type. If not set, the JVM uses the default keystore type (normally “jks”).

For additional information, refer to java.security.Provider javadocs.

KEYSTORE_FILE_ENCRYPT The encryption keystore file.
KEYSTORE_PASSWORD_ENCRYPT The encryption keystore password.
CRYPTO_PROVIDER_STS The WSS4J-specific Crypto implementation to use for protection in case of a STS. Currently, it can be set to one of the following:
  • org.apache.ws.security.components.crypto.Merlin is the default one if the property is not set.

  • org.apache.ws.security.components.crypto.BouncyCastle

KEYSTORE_PROVIDER_STS

The keystore provider used in case of a STS. If not set the JVM uses the default (normally Sun's) keystore provider

For additional information, refer to java.security.Provider javadocs.

KEYSTORE_TYPE_STS

The keystore type used in case of a STS. If not set, the JVM uses the default keystore type (normally JKS).

For additional information, refer to thejava.security.KeyStore#getDefaultType() method javadocs.

KEYSTORE_FILE_STS

The keystore file used in case of a STS.

KEYSTORE_PASSWORD_STS

The keystore password used in case of a STS.

SSL_KEYSTORE_TYPE

The type of the keystore specified under KEYSTORE_SSL_LOCATION.

SSL_KEYSTORE_PASSWORD

The password for the keystore specified under KEYSTORE_SSL_LOCATION. This property corresponds to the JSSE javax.net.ssl.keyStorePassword system property.

KEYSTORE_SSL_LOCATION

The keystore file for SSL authentication. This property corresponds to the JSSE javax.net.ssl.keyStore system property.

For more information, refer to the JSSE Reference Guide.

Note:
Specifying the keystore is required only if the remote SSL server requires client authentication.

TRUSTSTORE_SSL_LOCATION

The truststore file for SSL authentication. The client requires that the server's certificate is installed in this truststore and it is trusted. This property corresponds to the JSSE javax.net.ssl.trustStore system property. If the property is not set the client falls back to <java-home>lib/security/jssecacerts and <java-home>/lib/security/cacerts in that order.

Note:
For more information, refer to the JSSE Reference Guide.

TRUSTSTORE_SSL_PASSWORD

The password for the truststore specified under TRUSTSTORE_SSL_LOCATION. This property corresponds to the javax.net.ssl.trustStorePassword system property.

Note:
For more information, refer to the JSSE Reference Guide.

Note:
The last five entries actually refer to transport-level security configuration (SSL settings).

The configuration loading routine puts all those entries in the client options. Thus, you can overwrite any particular option every other time Rampart is to be executed. For example, all security keys can be specified programmatically using the Web Services Stack client options:

//create the WS Stack client:
IWSStaxClient client = ...

...
	
IWSOptions options = client.getWSOptions();

options.setProperty(WSClientConstants.KEYSTORE_PASSWORD_SIGN, "changeit");
options.setProperty(WSClientConstants.KEYSTORE_FILE_SIGN, "C:\\client.jks");

//set the options, overwriting the ones loaded from the wsclientsec.properties //file:
client.setOptions(options);
		    
//execute the client
client.sendReceive(...);

The Rampart is afterwards configured through a Rampart assertion that is generated by the RampartConfigLoader handler. The Web Services Stack client takes care of engaging that handler if Rampart itself is engaged. The function of the RampartConfigHandler is basically to gather all the security configuration keys, build up the Rampart configuration assertion, and put it as a property in the message context options where Rampart can find it.

Top of page

Transport-Level Security

This section covers the following topics:

Prerequisites for the Setup and Use of Transport-Level Security

Transport-level security addresses the problem of securing web service conversation by securing the communication channel instead of the message data itself. Although the web service security policy specification does not state that the transport-level security requires the use of HTTP transport over SSL, it is the most typical use case.

This section provides details on the configuration and usage of web service communication over HTTPS.

To enable transport-level security, configure your application server to use SSL:

Start of instruction setTo configure Tomcat to use SSL at server side

  1. Navigate to <TOMCAT_INSTALL_DIR>\conf and open the server.xml file to configure an SSL Connector.

    Note:
    <TOMCAT_INSTALL_DIR> is the path where your copy of Tomcat is installed.

  2. The configured scheme needed for the SSL communication is https. The required parameters are listed in the following table:

    Property name Description
    KEYSTORE_FILE_PATH The path to the keystore file that is used by Tomcat to decrypt the requests and encrypt the responses.
    KEYSTORE_PASSWORD The password that protects the keystore.
    ENCRYPTION_KEY_ALIAS The alias that identifies the key pair in the keystore (in case there is more than one public-private key pair in the keystore).

    Following is a sample code listing for an SSL connector configuration:

    <Connector port="8443" maxHttpHeaderSize="8192" maxThreads="150"   
         minSpareThreads="25" maxSpareThreads="75" enableLookups="false" 
         disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" 
         clientAuth="false" sslProtocol="TLS" 
         keystoreFile="="<KEYSTORE_FILE_PATH>" 
         keystorePass="<KEYSTORE_PASSWORD>"
         keyAlias="<ENCRYPTION_KEY_ALIAS>"/>
    

    Note:
    The value of the connector port is "8443" because this is the standard Tomcat HTTPS port.

If a server declares explicitly the use of the HTTPS transport in its services.xml, you have to define that such a transport listener is defined in the axis2.xml configuration file. Otherwise, the runtime throws an exception while trying to deploy the respective service.

As of Web Services Stack ver. 8.x, the com.softwareag.wsstack.transport.http.HTTPListener and the com.softwareag.wsstack.transport.http.HTTPSListener are introduced to solve the problem when Web Services Stack is served by a servlet container.

In that case, the actual transport receiver is the SAGAdminServlet that registers itself as an HTTP listener only. However, you still need to have an HTTPS listener configured in the axis2.xml file. The com.softwareag.wsstack.transport.http.HTTPSListener is a full functional replacement of the previously available org.apache.axis2.transport.http.HTTPSListener in Web Services Stack 1.2.

To use the new HTTPS listener, uncomment the respective configuration in the axis2.xml file shipped with Web Services Stack. Following is a sample configuration:

<transportReceiver name="https"
class="com.softwareag.wsstack.transport.http.HTTPSListener">
        <parameter name="port">8443</parameter>
    </transportReceiver>

In this code listing, the configured port number must be set to the port configured for the HTTPS connector of the servlet container. The newly configured HTTPSListener is responsible for generating correct endpoint addresses in the WSDL and supplying a SessionContext, although the actual requests are served by the SAGAdminServlet.

In this case, the SSL configuration uses only server authentication (see clientAuth="false" in the preceding configuration) and the client encrypts automatically the requests with the server public key.

Start of instruction setTo configure SSL at the client side

  1. The client must send a request against HTTPS endpoint with a port that is equal to the one specified at server side (that is "8443").

  2. Set the properties in your security configuration file. You can configure this file as a parameter in the axis2.xml configuration file:

    <parameter
    name="securityConfigFile">your client security config file path
    </parameter>
     

    For information on the axis2.xml configuration file, see Web Services Stack Runtime.

    If you do not define a security configuration file, the client uses information in the wsclientsec.properties file in the current working directory.

    Or:
    Use the Web Services Stack client API to set the required properties:

    //create the WS Stack client:
    IWSStaxClient client = ...
    
    ...
    	
    IWSOptions options = client.getWSOptions();
    
    options.setProperty(WSClientConstants.KEYSTORE_PASSWORD_SIGN, "changeit");
    options.setProperty(WSClientConstants.KEYSTORE_FILE_SIGN, "C:\\client.jks");
    
    //set the options, overwriting the ones loaded from the wsclientsec.properties //file:
    client.setOptions(options);
    		    
    //execute the client
    client.sendReceive(...);
    
     

    The following security properties at the client side relate to the SSL configuration:

    Property name Description
    SSL_KEYSTORE_TYPE The type of the keystore specified under the KEYSTORE_SSL_LOCATION.
    SSL_KEYSTORE_PASSWORD The password for the keystore specified under KEYSTORE_SSL_LOCATION. This property corresponds to the JSSE javax.net.ssl.keyStorePassword system property.
    KEYSTORE_SSL_LOCATION

    The keystore file for SSL authentication. This property corresponds to the JSSE javax.net.ssl.keyStore system property. Note that specifying the keystore is required only if the remote SSL server requires client authentication.

    For more information, refer to the JSSE Reference Guide.

    TRUSTSTORE_SSL_LOCATION

    The truststore file for SSL authentication. The client requires that the server's certificate is installed in this truststore and it is trusted. This property corresponds to the JSSE javax.net.ssl.trustStore system property. If the property is not set, the client falls back to <java-home>lib/security/jssecacerts and <java-home>/lib/security/cacerts in that order.

    For more information, refer to the JSSE Reference Guide.

    TRUSTSTORE_SSL_PASSWORD

    The password for the truststore specified under TRUSTSTORE_SSL_LOCATION. This property corresponds to the javax.net.ssl.trustStorePassword system property.

    For more information, refer to the JSSE Reference Guide.

SSL with Client Authentication

  1. Server-side Configuration
    The Tomcat web server may also be configured to use a client certificate to encrypt the transferred data.

    Start of instruction setTo use client authentication with Tomcat

    Set the following parameters in the HTTPS connector settings in the Tomcat server.xml configuration file.

    1. Set clientAuth to "true".

    2. Set the keystore properties.

    3. Set the truststore properties.

    Important:
    You can also configure the truststore location of Tomcat by starting it with the respective Java system property, because if the truststore properties are not set in your configuration, Tomcat uses the default Java trusted authority keystore.

    Start of instruction setTo configure the truststore location of Tomcat by starting it with the respective Java system property

    Use the following settings to configure the truststore properties in the HTTPS connector:

    Property name Description
    truststoreFile

    The TrustStore file to use to validate client certificates.

    truststorePass

    The password to access the truststore. This defaults to the value of keystorePass.

    truststoreType

    Add this element if your are using a different format for the truststore than you are using for the keystore. The keystoreType defaults to "JKS".

    Look at the following example to see a sample of the connector configuration:

    <Connector port="8443" maxHttpHeaderSize="8192" 
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" scheme="https" secure="true"
    clientAuth="true" sslProtocol="TLS"
    keystoreFile="<KEYSTORE_FILE_PATH>"
    keystorePass="<KEYSTORE_PASSWORD>"
    keyAlias="<KEY_ALIAS>"
    truststoreFile="<TRUSTSTORE_FILE_PATH>"
    truststorePass="<TRUSTSTORE_PASSWORD>"
    truststoreType="<TRUSTSTORE_TYPE>"/>
    

    Note:
    If you encounter a problem with a service that declares the usage of the HTTPS transport in its services.xml descriptor, uncomment the respective HTTPS listener configuration in the axis2.xml file shipped with Web Services Stack. For details, see how to configure Tomcat to use SSL at server side in Prerequisites for the Setup and Use of Transport-Level Security

  2. Client-side Configuration
    It is also possible to use client certificate with the Web Services Stack client, although additional work is needed to use the Java 1.4 compatible HTTP sender (utilizing the Jakarta Commons HttpClient component). In order to make the Commons HttpClient use client certificate for the encryption one needs to register a new HTPPS socket factory since the default one does not handle the case with the client certificate. The Commons HttpClient library does not provide the appropriate socket factory implementation but there is one in the contrib package (commons-httpclient-contib) that is part of the commons-httpclient project, namely AuthSSLProtocolSocketFactory. This can be set in the following way:

    IWSStaxClient client = ...
    ...
    ProtocolSocketFactory socketactory = new AuthSSLProtocolSocketFactory(
            		new File("keystore.jks").toURL(),
                      "keystorePassword", 
    new File("truststore.jks").toURL(),
                      "truststorePassword");
    Protocol authhttps = new Protocol("https", socketactory, 8443);
    client.getWSOptions().setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLE,
                                      authhttps);
    

Setup and Use of HTTP Basic Authentication

To use the HTTP basic authentication, you must configure a specific endpoint that is to use the HTTP basic authentication scheme. The needed configuration is not server-specific and is part of the J2EE specification.

Start of instruction setTo configure a specific endpoint to use the HTTP basic authentication scheme

  1. Open your web application descriptor of Web Services Stack (the web.xml file that is located in the \webapps\wsstack\WEB-INF directory).

  2. Add a security constraint for a particular URL.

    In the following sample code listing, the constraint is the web service endpoint. The relative URL that you are securing is <url-pattern>/services/ut_asym_xpath</url-pattern>:

    <security-constraint>
    		<web-resource-collection>
    			<web-resource-name>Protected Pages</web-resource-name>
    			<url-pattern>/services/ut_asym_xpath</url-pattern>
       <http-method>POST</http-method>
    			<http-method>GET</http-method>
    		</web-resource-collection>
    		<auth-constraint>
    			<role-name>manager</role-name>
    		</auth-constraint>
    </security-constraint>
    <security-role>
    		<role-name>tomcat</role-name>
    		<description>Web Services Stack user realm</description>
    	</security-role>
    <login-config>
    	<auth-method>BASIC</auth-method>
    	<realm-name>Basic Authentication</realm-name>
    </login-config>
    

Note:
Set <role-name>tomcat</role-name> to configure a role that ensures client authentication. This configuration is server-specific.

The http methods from the preceding code listing can be used for different purposes.

Note:
For more information, see Java™ Servlet Specification version 2.4.

With the <http-method> tag, you can list the "http" methods that require authentication. By removing <http-method>GET</http-method>, you can access the ?wsdl formed URL without authentication (for example, http://myhost:port/MyWebContext/MyService?wsdl). If no http methods are listed explicitly in the configuration, all http methods require authentication by default.

When using Tomcat, you can use the HTTP basic authentication with tomcat-users.xml.

Note:
Software AG Tomcat Kit is not installed in one location as with any other arbitrary installation of Apache Tomcat and does not contain a default tomcat-users.xml. If tomcat-users.xml is missing in your Tomcat configuration directory (\Documents and Settings\All Users\Application Data\Software AG\Tomcat\v5.5\conf), you must create it.

Start of instruction setTo use the HTTP basic authentication with tomcat-users.xml

  1. Define the role name in the tomcat-users.xml.

    Following is a sample of a tomcat-users.xml file:

    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
    </tomcat-users>
    

    Note:
    For information on how roles are defined in Tomcat, see Tomcat documentation.

  2. Restart Tomcat for the changes to take effect.

Once you have configured your endpoint for HTTP basic authentication, you can configure your web service client, so that it is aware of the changes.

Start of instruction setTo configure your web service client to use HTTP basic authentication

  1. Supply the HttpTransportProperties.Authenticator object

  2. Set the user name to “tomcat”.

  3. Set the password to “tomcat”.

  4. Set this configuration as an option of the web service client.

Following is a sample code listing of a web service client implementation when you want to use HTTP basic authentication:

IWSStaxClient client = (IWSStaxClient)WSClientFactory.newClient(
  WSClientConstants.STAX_WSCLIENT,		            
  "C:/ut_asym_xpath.wsdl",
  null,
  null,
 "C:\\Software AG\\WS-Stack\\repository");
			
HttpTransportProperties.Authenticator auth = new    
                HttpTransportProperties.Authenticator();
auth.setUsername ("tomcat");
auth.setPassword ("tomcat");
auth.setPreemptiveAuthentication (true);
            
IWSOptions options = client.getWSOptions();
options.setProperty(
      org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
client.setOptions(options);

Important:
In the above example, you must supply the HttpTransportProperties. Authenticator object first, and then set up a user name and a password according to the configured Tomcat role. Finally, you need to set this configuration as an option of the web service's client.

Top of page

Client Authentication

Web Services Stack provides a mechanism for authenticating clients in Web Services Stack runtime layer using the common Java Authentication and Authorization Service (JAAS) security framework.

Software AG Security Infrastructure (SIN) provides you with an implementation of JAAS LoginModules for client authentication.

When you log on using JAAS LoginContext, a javax.security.auth.Subject is produced. That subject contains user principals and credentials and is available to anyone on the execution chain through the message context.

Web Services Stack collects all available security credentials from the client request and populates them in SIN SagCredentials. After that, the logon process is performed in the policy validator implementation of Rampart.

The information is organized under the following headings:

JAAS Configuration

Before you can log on, you must configure JAAS. For information about the JAAS configuration file, see SIN documentation in the webMethods Product Suite 8.0 folder on the Software AG Documentation Web site.

Security Credentials

There are two types of user credentials that are used for authentication in Web Services Stack:

Implementation of Password Callback Handlers

You use password callback handlers in particular identifiers to provide passwords, which are used in the following use cases:

The callback handlers can retrieve passwords from configuration files, data bases, LDAP servers, or other application components which are used for user management (for example Security Infrastructure).

Web Services Stack has a predefined set of password callback handlers, which facilitate different scenarios for retrieving passwords. You can use these handlers directly or you can develop your own password callback handlers out of them. The following password callback handlers are available:

The Web Services Stack installation contains samples of custom password callback handlers (on provider and consumer sides) which retrieve identifier-password pairs from configuration files or LDAP servers. You can find the samples in the following location: /samples/PWCBHandlersExample. The folder contains the following projects:

Note that these sample projects enable you to create custom password callback handlers. They do not enable you to reuse handlers which retrieve identifier-password pairs from a common central location.

Implementations of Policy Validation Callbacks

In the wsstack-jaas.jar module, there are ready-to-use policy validator implementations that may be configured and used easily to log on.

Following are examples of those implementations:

These policy validator callbacks extend the standard callback that is provided by Rampart. This means that all basic functionality for validating security policy conformation is still present.

Note:
To use one of the preceding callbacks, specify the policyValidatorCbClass in the Rampart policy assertion.

Authentication Steps

This section provides you with guidelines on the authentication steps when you use SIN in Web Services Stack.

Start of instruction setTo authenticate using SIN

You must include the path to SIN JAR in the classpath. All classes that are used in the JAAS configuration file must also be set in the classpath.

  1. Configure the JAAS configuration file.

  2. Configure a web service to do the following:

With those settings, you are authenticated when logging on by SIN.

For information about the authentication steps, see SIN documentation in the webMethods Product Suite 8.0 folder on the Software AG Documentation Web site.

Top of page