+

Search Tips   |   Advanced Search


Implement a custom security algorithm

You can define own security algorithms for SOAP security profiles by implementing custom security Java™ interfaces that can be used in the WSDL security editor. With custom security algorithms, you can implement proprietary security algorithms that transform the XML before sending and after receiving message content.

The custom security interface and the JAR file containing it are provided with RPTv8 in the customsecuritydefinition folder of the com.ibm.rational.test.lt.models.ws plugin. You need these interfaces to create own algorithms. See Extending test execution with custom code for more information about extending test capabilities with Java code. To create a custom security algorithm:

  1. In the test navigator or project explorer, create a new Java class in Web service test project folder.

  2. Implement a security algorithm in Java using the following interface:

    /**
    * ***************************************************************
    * IBM Confidential
    * 
    * (c) Copyright IBM Corporation. 2008. All Rights Reserved.
    * 
    * The source code for this program is not published or otherwise
    * divested of its trade secrets, irrespective of what has been
    * deposited with the U.S. Copyright Office.
    * *************************************************************** 
    * 
    */
    
    package com.ibm.rational.test.lt.models.wscore.datamodel.security.xmlsec;
    
    import java.util.Properties;
    import org.w3c.dom.Document;
    
    public interface ICustomSecurityAlgorithm {
        
        /**
         * The following methods can be used in both case:
         * Execution in the workbench and execution of the test.
         */
        
        
        /**
         * Called to process de Document sent over a transport.
         * @param subject
         */
        void process(Document subject);
        /**
         * Called to un process a document that is received from a server.
         * @param subject
         */
        void unProcess(Document subject);
        
        /**
         * Properties defined in the UI of the CustomSecurityAlgorithm.
         * @param map
         */
        void setProperties(Properties map);
        
        /**
         * The following methods can only be used in terms of cast to test service interface,
         * or in terms of access to the previous XML  information, when the jar containing
         * the custom security algorithm is deployed in the performance test project. In
         * this case you cannot use the algorimth directly from the workbench.
         */
        
        /**
         * This object corresponds to the ITestExecutionService object.
         * This applies only to an algorithm that must link to the execution of the test.
         * If you plan to use this object deploy the jar containing the
         * implementation into  performance test project and not directly into the JRE.
         * 
         * In case of a need of the previous xml document received from the execution you can 
         * obtain the value using:
         * IDataArea area = ((ITestExecutionService)executionObject).findDataArea(IDataArea.VIRTUALUSER);
         *String previousXML = (String) area.get("PREVIOUS_XML"); //$NON-NLS-1$
         * 
         */
        void setExecutionContext(Object executionObject);
    

    The process method modifies the XML before it is sent to the server.

    The unprocess method modifies the XML after it is received from the server.

    The setProperties method retrieves any properties that are defined in the security editor for this custom security interface.

    The setExecutionContext method is called during test with the object ITestExecutionServices that corresponds to the message using this custom security interface.

  3. The custom security interface can be used either in the WSDL security editor for Web services or in XML call elements in the Local XML security tab.

    • If you are testing a WSDL-based Web service, right-click the WSDL file in the test navigator or project explorer to open the WSDL security editor, select the Security Algorithms page; then, under Details of selected security algorithm stack, click...

        Add | Custom Security Algorithm

    • If you are testing an XML call, open the XML call element in the test editor, select the Local XML Security tab, and then, click...

        Add | Custom Security Algorithm

  4. In custom security, click Browse Class to select the class name of the custom security algorithm, for example : ICustomSecurityAlgorithm.

  5. Type an Algorithm name for the custom security algorithm.

  6. In the properties list, use Add, Remove, or Edit to specify any properties that are used by the setProperties method in custom security algorithm.


What to do next

After saving the security configuration or the call element, the Web Service Protocol Data view displays the effect of the security algorithm on the XML data of the Web service.


Related

  • Web service security editor overview


    Related tasks

  • Create a SOAP security profile for a WSDL
  • Add WS-Addressing to a security configuration