示例:适用于 V5.x 应用程序的 Web Service 安全性样本配置
要使用 Web Service 安全性保护 V5.x 应用程序,必须在 IBM® 扩展部署描述符和 IBM 扩展绑定中定义安全性约束。为样本配置提供了样本密钥库文件和缺省绑定信息,以演示 IBM 部署描述符扩展和绑定可以实现的功能。
- ${USER_INSTALL_ROOT}/etc/ws-security/samples/dsig-sender.ks
- 密钥库密码为 client
- 具有别名的可信证书 soapca
- 依次由中间认证中心 Int CA2 和 soapca 发出的具有别名的个人证书 soaprequester 和密钥密码 client
- ${USER_INSTALL_ROOT}/etc/ws-security/samples/dsig-receiver.ks
- 密钥库密码为 server
- 具有别名的可信证书 soapca
- 依次由中间认证中心 Int CA2 和 soapca 发出的具有别名的个人证书 soapprovider 和密钥密码 server
- ${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-sender.jceks
- 密钥库密码为 storepass
- 密钥 CN=Group1、别名 Group1 和密钥密码 keypass
- 公用密钥 CN=Bob, O=IBM, C=US、别名 bob 和密钥密码 keypass
- 专用密钥 CN=Alice, O=IBM, C=US、别名 alice 和密钥密码 keypass
- ${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-receiver.jceks
- 密钥库密码为 storepass
- 密钥 CN=Group1、别名 Group1 和密钥密码 keypass
- 专用密钥 CN=Bob, O=IBM, C=US、别名 bob 和密钥密码 keypass
- 公用密钥 CN=Alice, O=IBM, C=US、别名 alice 和密钥密码 keypass
- ${USER_INSTALL_ROOT}/etc/ws-security/samples/intca2.cer
- 中间认证中心为 Int CA2。
缺省绑定(单元和服务器级别)
- 信任锚
- 用于验证签署者证书的信任度。
- SampleClientTrustAnchor 由响应接收方用于验证签署者证书。
- SampleServerTrustAnchor 由请求接收方用于验证签署者证书。
- 证书集合库
- 用于验证证书路径。
- SampleCollectionCertStore 由响应接收方和请求接收方用于验证签署者证书路径。
- 密钥定位器
- 用于定位用于签名、加密和解密的密钥。
- SampleClientSignerKey 由请求发送方用于签署 SOAP 消息。签署密钥名为 clientsignerkey,它可在签署信息中作为签署密钥名引用。
- SampleServerSignerKey 由响应发送方用于签署 SOAP 消息。签署密钥名为 serversignerkey,它可在签署信息中作为签署密钥名引用。
- SampleSenderEncryptionKeyLocator 由发送方用于对 SOAP 消息进行加密。它配置为使用 ${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-sender.jceks 密钥库和 com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator 密钥库密钥定位器。
- SampleReceiverEncryptionKeyLocator 由接收方用于解密已加密的 SOAP 消息。此实现配置为使用 ${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-receiver.jceks 密钥库和 com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator 密钥库密钥定位器。此实现是为对称加密(DES 或 TRIPLEDES)配置的。然而,要将它用作非对称加密 (RSA),您必须添加专用密钥 CN=Bob, O=IBM, C=US、别名 bob 和密钥密码 keypass。
- SampleResponseSenderEncryptionKeyLocator 由响应发送方用于加密 SOAP 响应消息。它配置为使用 ${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-receiver.jceks 密钥库和 com.ibm.wsspi.wssecurity.config.WSIdKeyStoreMapKeyLocator 密钥定位器。此密钥定位器将已认证标识(当前线程的)映射至用于加密的公用密钥。缺省情况下,WebSphere Application Server 配置为映射至公用密钥 alice,所以您必须更改 WebSphere Application Server 以映射至适当的用户。SampleResponseSenderEncryptionKeyLocator 密钥定位器还可设置用于加密的缺省密钥。缺省情况下,此密钥定位器配置为使用公用密钥 alice。
- 可信标识鉴别程序
- 用于在声明身份断言中的标识之前建立信任。SampleTrustedIDEvaluator 配置为使用 com.ibm.wsspi.wssecurity.id.TrustedIDEvaluatorImpl 实现。 com.ibm.wsspi.wssecurity.id.TrustedIDEvaluator 的缺省实现包含可信标识的列表。 当密钥和值与可信标识相同时,列表定义为具有 trustedId_* 的属性。 通过完成以下步骤,在管理控制台中定义有关服务器级别的这个信息:
- 单击 。
- 在“其他属性”下,单击 。
- 登录映射
- 用来认证 SOAP 消息的 Web Service 安全性 SOAP 头中的入局安全性令牌。
- BasicAuth 认证方法用于认证用户名安全性令牌(用户名和密码)。
- 签名认证方法用于将专有名称 (DN) 映射至 WebSphere Application Server Java™ 认证和授权服务 (JAAS) 主体集。
- IDAssertion 认证方法用于将可信的身份映射至 WebSphere Application Server JAAS 主体集以便声明身份。
- 轻量级第三方认证 (LTPA) 认证方法用于验证 LTPA 安全性令牌。
样本配置
以下示例演示了 IBM 部署描述符扩展和绑定可实现的功能。 从示例中移除了不必要的信息以提高清晰度。不要将这些示例复制并粘贴到您的应用程序部署描述符或绑定中。 这些示例仅做参考,它们不代表建议的配置。
- 使用组装工具来创建或编辑 IBM 部署描述符扩展。
- 使用组装工具或管理控制台来创建或编辑绑定文件。
- 签署 SOAP 主体、时间戳记和安全性令牌。
- 加密主体内容和用户名令牌。
- 发送用户名令牌(基本认证数据)。
- 生成请求的时间戳记。
对于响应,签署 SOAP 主体和时间戳记、加密主体内容和使用时间戳记检查 SOAP 消息的新鲜度。消息的新鲜度表明消息是否遵守预定义的时间约束。
请求发送方和请求接收方是一对。 相同的,响应发送方和响应接收方是一对。
客户端 IBM 部署描述符扩展
客户端 IBM 部署描述符扩展描述下列约束:
- 签署 SOAP 主体、时间戳记和安全性令牌
- 加密主体内容和用户名令牌
- 发送基本认证令牌(用户名和密码)
- 生成三分钟到期的时间戳记
- 验证签署了 SOAP 主体和时间戳记
- 验证加密了 SOAP 主体内容
- 验证存在时间戳记(也用于检查消息新鲜度)
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.etools.webservice.wscext:WsClientExtension xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.etools.webservice.wscext=
http://www.ibm.com/websphere/appserver/schemas/5.0.2/wscext.xmi">
<serviceRefs serviceRefLink="service/myServ">
<portQnameBindings portQnameLocalNameLink="Port1">
<clientServiceConfig actorURI="myActorURI">
<securityRequestSenderServiceConfig actor="myActorURI">
<integrity>
<references part="body"/>
<references part="timestamp"/>
<references part="securitytoken"/>
</integrity>
<confidentiality>
<confidentialParts part="bodycontent"/>
<confidentialParts part="usernametoken"/>
</confidentiality>
<loginConfig authMethod="BasicAuth"/>
<addCreatedTimeStamp flag="true" expires="PT3M"/>
</securityRequestSenderServiceConfig>
<securityResponseReceiverServiceConfig>
<requiredIntegrity>
<references part="body"/>
<references part="timestamp"/>
</requiredIntegrity>
<requiredConfidentiality>
<confidentialParts part="bodycontent"/>
</requiredConfidentiality>
<addReceivedTimeStamp flag="true"/>
</securityResponseReceiverServiceConfig>
</clientServiceConfig>
</portQnameBindings>
</serviceRefs>
<com.ibm.etools.webservice.wscext:WsClientExtension>
客户端 IBM 扩展绑定
示例 2 说明了先前有关客户端 IBM 部署描述符扩展的讨论中描述的安全性约束的客户端 IBM 扩展绑定。
消息的签署者密钥和加密(解密)密钥可从密钥库密钥定位器实现 (com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator) 中获取。 签署者密钥用于加密响应。该样本配置为使用 Java 证书路径 API,以验证数字签名签署者的证书路径。用户名令牌(基本认证)数据是使用其中一个缺省 JAAS 实现 :javax.security.auth.callback.CallbackHandler 实现 (com.ibm.wsspi.wssecurity.auth.callback.StdinPromptCallbackHandler)从标准输入 (stdin)提示中收集的。
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.etools.webservice.wscbnd:ClientBinding xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:com.ibm.etools.webservice.wscbnd=
"http://www.ibm.com/websphere/appserver/schemas/5.0.2/wscbnd.xmi">
<serviceRefs serviceRefLink="service/MyServ">
<portQnameBindings portQnameLocalNameLink="Port1">
<securityRequestSenderBindingConfig>
<signingInfo>
<signatureMethod algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<signingKey name="clientsignerkey" locatorRef="SampleClientSignerKey"/>
<canonicalizationMethod algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<digestMethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</signingInfo>
<keyLocators name="SampleClientSignerKey" classname=
"com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator">
<keyStore storepass="{xor}PDM2OjEr" path=
"$${USER_INSTALL_ROOT}/etc/ws-security/samples/dsig-sender.ks" type="JKS"/>
<keys alias="soaprequester" keypass="{xor}PDM2OjEr" name="clientsignerkey"/>
</keyLocators>
<encryptionInfo name="EncInfo1">
<encryptionKey name="CN=Bob, O=IBM, C=US" locatorRef=
"SampleSenderEncryptionKeyLocator"/>
<encryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
<keyEncryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
</encryptionInfo>
<keyLocators name="SampleSenderEncryptionKeyLocator" classname=
"com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator">
<keyStore storepass="{xor}LCswLTovPiws" path=
"$${USER_INSTALL_ROOT}/etc/ws-security/samples/enc-sender.jceks" type="JCEKS"/>
<keys alias="Group1" keypass="{xor}NDomLz4sLA==" name="CN=Group1"/>
</keyLocators>
<loginBinding authMethod="BasicAuth" callbackHandler=
"com.ibm.wsspi.wssecurity.auth.callback.StdinPromptCallbackHandler"/>
</securityRequestSenderBindingConfig>
<securityResponseReceiverBindingConfig>
<signingInfos>
<signatureMethod algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<certPathSettings>
<trustAnchorRef ref="SampleClientTrustAnchor"/>
<certStoreRef ref="SampleCollectionCertStore"/>
</certPathSettings>
<canonicalizationMethod algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<digestMethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</signingInfos>
<trustAnchors name="SampleClientTrustAnchor">
<keyStore storepass="{xor}PDM2OjEr" path=
"$${USER_INSTALL_ROOT}/etc/ws-security/samples/dsig-sender.ks" type="JKS"/>
</trustAnchors>
<certStoreList>
<collectionCertStores provider="IBMCertPath" name="SampleCollectionCertStore">
<x509Certificates path="$${USER_INSTALL_ROOT}/etc/ws-security/samples/intca2.cer"/>
</collectionCertStores>
</certStoreList>
<encryptionInfos name="EncInfo2">
<encryptionKey locatorRef="SampleReceiverEncryptionKeyLocator"/>
<encryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
<keyEncryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
</encryptionInfos>
<keyLocators name="SampleReceiverEncryptionKeyLocator" classname=
"com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator">
<keyStore storepass="{xor}PDM2OjEr" path=
"$${USER_INSTALL_ROOT}/etc/ws-security/samples/dsig-sender.ks" type="JKS"/>
<keys alias="soaprequester" keypass="{xor}PDM2OjEr" name="clientsignerkey"/>
</keyLocators>
</securityResponseReceiverBindingConfig>
</portQnameBindings>
</serviceRefs>
</com.ibm.etools.webservice.wscbnd:ClientBinding>
服务器端 IBM 部署描述符扩展
客户端 IBM 部署描述符扩展描述下列约束:
- 验证签署了 SOAP 主体、时间戳记和安全性令牌。
- 验证加密了 SOAP 主体内容和用户名令牌。
- 验证基本认证令牌(用户名和密码)在 Web Service 安全性 SOAP 头中。
- 验证存在时间戳记(也用于检查消息新鲜度)。消息的新鲜度表明消息是否遵守预定义的时间约束。
- 签署 SOAP 主体和时间戳记
- 加密 SOAP 主体内容
- 生成 3 分钟到期的时间戳记
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.etools.webservice.wsext:WsExtension xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:com.ibm.etools.webservice.wsext=
http://www.ibm.com/websphere/appserver/schemas/5.0.2/wsext.xmi">
<wsDescExt wsDescNameLink="MyServ">
<pcBinding pcNameLink="Port1">
<serverServiceConfig actorURI="myActorURI">
<securityRequestReceiverServiceConfig>
<requiredIntegrity>
<references part="body"/>
<references part="timestamp"/>
<references part="securitytoken"/>
</requiredIntegrity>
<requiredConfidentiality">
<confidentialParts part="bodycontent"/>
<confidentialParts part="usernametoken"/>
</requiredConfidentiality>
<loginConfig>
<authMethods text="BasicAuth"/>
</loginConfig>
<addReceivedTimestamp flag="true"/>
</securityRequestReceiverServiceConfig>
<securityResponseSenderServiceConfig actor="myActorURI">
<integrity>
<references part="body"/>
<references part="timestamp"/>
</integrity>
<confidentiality>
<confidentialParts part="bodycontent"/>
</confidentiality>
<addCreatedTimestamp flag="true" expires="PT3M"/>
</securityResponseSenderServiceConfig>
</serverServiceConfig>
</pcBinding>
</wsDescExt>
</com.ibm.etools.webservice.wsext:WsExtension>
服务器端 IBM 扩展绑定
下列绑定信息复用一些定义在服务器级别或单元级别上的缺省绑定信息,这取决于安装。 例如,请求接收方将引用定义在缺省绑定中的 SampleCollectionCertStore 证书库和SampleServerTrustAnchor 信任密钥库。然而,请求接收方中的加密信息将引用定义在应用程序级别绑定(同一 ibm-webservices-bnd.xmi 文件)中的 SampleReceiverEncryptionKeyLocator 密钥定位器。 响应发送方配置为使用请求的数字签名的签署者密钥,以使用其中一个缺省密钥定位器 (com.ibm.wsspi.wssecurity.config.CertInRequestKeyLocator) 实现来加密响应。
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.etools.webservice.wsbnd:WSBinding xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:com.ibm.etools.webservice.wsbnd=
http://www.ibm.com/websphere/appserver/schemas/5.0.2/wsbnd.xmi">
<wsdescBindings wsDescNameLink="MyServ">
<pcBindings pcNameLink="Port1" scope="Session">
<securityRequestReceiverBindingConfig>
<signingInfos>
<signatureMethod algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<certPathSettings>
<trustAnchorRef ref="SampleServerTrustAnchor"/>
<certStoreRef ref="SampleCollectionCertStore"/>
</certPathSettings>
<canonicalizationMethod algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<digestMethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</signingInfos>
<encryptionInfos name="EncInfo1">
<encryptionKey locatorRef="SampleReceiverEncryptionKeyLocator"/>
<encryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
<keyEncryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
</encryptionInfos>
<keyLocators name="SampleReceiverEncryptionKeyLocator" classname=
"com.ibm.wsspi.wssecurity.config.KeyStoreKeyLocator">
<keyStore storepass="{xor}LCswLTovPiws" path="$${USER_INSTALL_ROOT}/
etc/ws-security/samples/enc-receiver.jceks" type="JCEKS"/>
<keys alias="Group1" keypass="{xor}NDomLz4sLA==" name="CN=Group1"/>
<keys alias="bob" keypass="{xor}NDomLz4sLA==" name="CN=Bob, O=IBM, C=US"/>
</keyLocators>
</securityRequestReceiverBindingConfig>
<securityResponseSenderBindingConfig>
<signingInfo>
<signatureMethod algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<signingKey name="serversignerkey" locatorRef="SampleServerSignerKey"/>
<canonicalizationMethod algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<digestMethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</signingInfo>
<encryptionInfo name="EncInfo2">
<encryptionKey locatorRef="SignerKeyLocator"/>
<encryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
<keyEncryptionMethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
</encryptionInfo>
<keyLocators name="SignerKeyLocator" classname=
"com.ibm.wsspi.wssecurity.config.CertInRequestKeyLocator"/>
</securityResponseSenderBindingConfig>
</pcBindings>
</wsdescBindings>
<routerModules transport="http" name="StockQuote.war"/>
</com.ibm.etools.webservice.wsbnd:WSBinding>