实现定制安全算法

可通过实施可在 WSDL 安全编辑器中使用的定制安全 Java™ 接口来为 SOAP 安全概要文件定义您自己的安全算法。 通过定制安全算法,您可以实施在发送消息内容之前以及在接收消息内容之后转换 XML 的专用安全算法。

开始之前

定制安全接口与包含该接口的 JAR 文件随产品提供,其位置在 com.ibm.rational.test.lt.models.ws 插件的 customsecuritydefinition 文件夹中。您需要这些接口来创建自己的算法。请参阅通过定制代码扩展测试执行以获取关于通过 Java 代码扩展测试功能的更多信息。

过程

  1. 在测试导航器或 Project Explorer 中,在 Web Service 测试项目文件夹中创建新的 Java 类。
  2. 使用以下接口在 Java 中实施安全算法:
    /**
    * ***************************************************************
    * 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 that is 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 you will need to deploy the jar containing the
    	 * implementation into your 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);

    process 方法会在将 XML 发送到服务器之前对其进行修改。

    unprocess 会在从服务器接收 XML 之后对其进行修改。

    setProperties 方法接收在安全编辑器中为该定制安全接口定义的任何属性。

    在使用该定制安全接口对与消息对应的对象 ITestExecutionServices 进行测试期间将调用 setExecutionContext 方法。

  3. 可在 Web Service 的“WSDL 安全编辑器”中或在本地 XML 安全选项卡的 XML 调用元素中使用定制安全接口。
    • 如果要测试基于 WSDL 的 Web Service,请右键单击测试导航器或 Project Explorer 中的 WSDL 文件以打开 WSDL 安全编辑器,选择安全算法页面;然后在选定安全算法堆栈的详细信息下,单击添加 > 定制安全算法
    • 如果要测试 XML 调用,请在测试编辑器中打开 XML 调用元素,选择本地 XML 安全选项卡,然后单击添加 > 定制安全算法
  4. 在定制安全中,单击浏览类以选择定制安全算法的类名称,例如:ICustomSecurityAlgorithm
  5. 输入定制安全算法的算法名称
  6. 在属性列表中,使用添加除去编辑来指定定制安全算法中的 setProperties 方法使用的任何属性。

下一步做什么

保存安全配置或调用元素后,“Web Service 协议数据”视图将显示安全算法对 Web Service 的 XML 数据产生的效果。

反馈