SOA Suite 11g 开发指南之十一:使用OWSM配置安全策略

声明:该博文来自热爱JAVA,热爱生活。原文地址http://maping930883.blogspot.com/

我们希望设置如下安全策略:使用用户名/口令的方式保护POProcessing和validationForCC,信息要求签名与加密。
1. 使用用户名/口令的方式保护POProcessing。receivePO是POProcessing的入口服务,现在要求必须提供用户名/口令才能访问该服务,我们为receivePO配置wss_username_token_service_policy策略。

2. 使用SAML在多个SOA组件之间传播身份信息。
在POProcessing中调用validationForCC服务的Reference是getCrediCardStatus,为了把用户身份信息从receivePO中一路传播过来,我们为getCrediCardStatus配置wss11_saml_token_with_message_protection_client_policy策略。



3. 使用用户名/口令的方式保护validationForCC。getStatusByCC是validationForCC的入口服务,这里的用户名和口令是从前面的组件传播过来的,我们为其配置wss11_saml_token_with_message_protection_service_policy策略。



4. 在EM上测试。



如果想去掉某些策略,不必删除,可以Disable掉,这样如果想再启用不用重新配置。
5. 使用Java 客户端测试。
(1)JDeveloper中可以根据WSDL地址,创建WebService Proxy,它会帮助我们生成所有需要的类。
这里我把机器名改成了IP地址,否则JDeveloper会报告找不到WSDL,原因不明,留待以后查证。



(2)这一步是关键, 要选中“oracle/wss_username_token_client_policy”。



(3)修改代码如下:
main方法内容如下:
public static void main(String[] args) {
receivePO = new ReceivePO();
SecurityPoliciesFeature securityFeatures =
new SecurityPoliciesFeature(new String[] { "oracle/wss_username_token_client_policy" });
Execute_ptt execute_ptt = receivePO.getExecute_pt(securityFeatures);

Map reqContext = ((BindingProvider)execute_ptt).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "weblogic");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "welcome1");

PurchaseOrderType po = new PurchaseOrderType();
po.setCustID("1111");
po.setID("2121");
po.setProductName("Bluetooth Headset");
po.setItemType("Electronics");
po.setPrice(new BigDecimal("49.99"));
po.setQuantity(new BigDecimal(1));
po.setCcType("Mastercard");
po.setCcNumber("8765-8765-8765-8765");

execute_ptt.execute(po);
}

(4)在EM中,观察到传入的Payload内容如下:
可以看出使用username_token的方式,密码是明文的。



6. 使用ADF 测试。
这里笔者通过生成Web Service Data Control,然后在页面上调用该服务。
(1)



(2)生成的Data Control,内容如下:



新建一个.jspx页面后,拖放part1(三道橘红色图标对应的part1)生成表单。
拖放execute(Object) Operation生成Submit按钮。

(3)配置客户端WebService安全性。
因为被调用的服务配置了username_token Policy,因此需要调用者提供username和password。
选中.dcx文件,在Structure面板中,右键Data Control生成的服务,选择“Define Web Service Security..."




选中“oracle/wss_username_token_client_policy”,点击“Override Properties”,



加入用户weblogic/welcome1


测试,在EM上观察到传入的Payload内容,与5.4结果类似。

猜你喜欢

转载自c-life.iteye.com/blog/1622511