如何覆盖Soa Suite 12c中REST绑定参考的OWSM策略?

时间:2017-02-06 17:34:42

标签: java authentication oracle-fusion-middleware soa-suite

我正在研究Oracle融合中间件 12.1.3

在我的合成中,我添加了一个" Rest Binding"外部参考,我为其添加了 oracle / wss_http_token_client_policy 并覆盖了 csf-key 属性。

在文件中,它看起来像:

myComposite.BAS:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- Generated by Oracle SOA Modeler version 12.1.3.0.0 at [01-06-2016 16:01]. -->
<composite name="MyCompositeBAS"
           revision="9.8.8"
           label="2016-06-01_16-01-48_442"
           mode="active"
           state="on"
           xmlns="http://xmlns.oracle.com/sca/1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
           xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy"
           xmlns:ui="http://xmlns.oracle.com/soa/designer/"
           xmlns:sca-ext="http://xmlns.oracle.com/sca/1.0-ext">

  [.....]

  <component name="MyCompositeBASProcess" version="2.0">
    <implementation.bpel src="BPEL/MyCompositeBASProcess.bpel"/>
    <componentType>
      <service name="mycompositebasprocess_client" ui:wsdlLocation="WSDLs/MyCompositeBASProcess.wsdl">
        <interface.wsdl interface="http://xmlns.oracle.com/GDDSOA/MyCompositeBAS/MyCompositeBASProcess#wsdl.interface(MyCompositeBASProcess)"
                        callbackInterface="http://xmlns.oracle.com/GDDSOA/MyCompositeBAS/MyCompositeBASProcess#wsdl.interface(MyCompositeBASProcessCallback)"/>
      </service>
      <reference name="CMProxyRS" ui:wsdlLocation="WSDLs/CMProxyRS.wsdl">
        <interface.wsdl interface="http://xmlns.oracle.com/GDDSOA/MyCompositeBAS/CMProxyRS#wsdl.interface(CMProxyRS_ptt)"/>
      </reference>
    </componentType>
    <property name="bpel.config.oneWayDeliveryPolicy" type="xs:string" many="false">async.persist</property>
  </component>

  <reference name="CMProxyRS" ui:wsdlLocation="WSDLs/CMProxyRS.wsdl">
    <interface.wsdl interface="http://xmlns.oracle.com/GDDSOA/MyCompositeBAS/CMProxyRS#wsdl.interface(CMProxyRS_ptt)"/>
    <binding.rest config="Adapters/CMProxyRS.wadl" location="http://myUatServer/cmproxy/resources/v2/" />
  </reference>

  [....]

  <wire>
    <source.uri>MyCompositeBASProcess/CMProxyRS</source.uri>
    <target.uri>CMProxyRS</target.uri>
  </wire>
</composite>

wsm-assembly.xml:

<?xml version="1.0" encoding="windows-1252" ?>
<orawsp:wsm-assembly xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy">
  <sca11:policySet xmlns:sca11="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="policySet"
               appliesTo="SCA-REST-REFERENCE()" attachTo="REFERENCE('CMProxyRS')" orawsp:highId="2" 
               xml:id="SCA-REST-REFERENCE__REFERENCE__CMProxyRS__">
    <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy"
                     DigestAlgorithm="http://www.w3.org/ns/ws-policy/Sha1Exc"
                     URI="oracle/wss_http_token_client_policy" orawsp:status="enabled" orawsp:id="2">
      <orawsp:OverrideProperty xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy" orawsp:name="csf-key"
                           orawsp:value="cmproxy.rest"/>
    </wsp:PolicyReference>
  </sca11:policySet>
</orawsp:wsm-assembly>

这在我的UAT和PROD环境中运行良好,其中设置了基本身份验证。

我对DEV环境的问题:REST服务不需要任何身份验证。 如何在DEV环境中部署组合时更改或删除<wsp:PolicyReference ...>

在网上看,我找到了几个覆盖PolicyReference的例子,但对于&#34; SOAP Bindings&#34; SOA Suite 11g 上的外部参考。我没有找到任何针对REST服务和12c的具体内容。

我试图调整我在网上找到的样本:

**覆盖&#34;配置计划中的政策&#34; **

我写了一个专门用于DEV环境的配置计划:

<?xml version="1.0" encoding="UTF-8"?>
<SOAConfigPlan xmlns:jca="http://platform.integration.oracle/blocks/adapter/fw/metadata"
               xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"      
               xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy"
               xmlns:edl="http://schemas.oracle.com/events/edl" xmlns="http://schemas.oracle.com/soa/configplan">

    <composite name="MyCompositeBAS">
        <import>
            <searchReplace>
                <search/>
                <replace/>
            </searchReplace>
        </import>
        <reference name="CMProxyRS">
            <binding type="rest">
                <attribute name="location">
                    <replace>http://myDevServer/cmproxy/resources/v2/</replace>
                </attribute>
                <wsp:PolicyReference URI="oracle/no_authentication_client_policy" orawsp:category="security" orawsp:status="enabled"/>
            </binding>
        </reference>
    </composite>
</SOAConfigPlan>

或者,我也试过&#34;禁用&#34; (在配置计划中)通过在我的配置计划中替换最后一个块来wsm-assembly.xml中定义的策略:

    [....]
    <reference name="CMProxyRS">
        <binding type="rest">
            <attribute name="location">
                <replace>http://myDevServer/cmproxy/resources/v2/</replace>
            </attribute>
            <wsp:PolicyReference orawsp:category="security" orawsp:status="disabled" URI="oracle/wss_username_token_client_policy"/>
            <!--wsp:PolicyReference URI="oracle/no_authentication_client_policy" orawsp:category="security" orawsp:status="enabled"/ -->
        </binding>
    </reference>
    [....]

但它不起作用。我知道应用了配置计划,因为我可以看到复合体尝试访问myDevServer上的REST服务器,但是&#34;原始&#34;政策未被删除。这已在企业管理器上得到确认:在CMProxyRS政策标签上,oracle/wss_http_token_client_policy仍然可见,EffectiveEnabled已被检查。< / p>

覆盖&#34; composite.xml&#34;

中的政策

我还尝试直接在composite.xml中重新定义策略,以查看是否可以覆盖wsm-assembly.xml文件中定义的内容。我尝试了几种方式,改变:

composite.xml:

[....]
<binding.rest config="Adapters/CMProxyRS.wadl" location="http://myDevServer/cmproxy/resources/v2/" >
    <wsp:PolicyReference URI="oracle/wss_http_token_client_policy" orawsp:category="security" orawsp:status="disabled"/>
</binding.rest>
[....]

11g和12c之间的差异

我在网上找到的样品设计为11g,而不是12c。 通过jDeveloper GUI设置策略时可能会有不同的行为,如下所示:

  • 在12c中,<wsp:PolicyReference >标记已添加到wsm-assembly.xml文件中,并以<sca11:policySet >包裹;
  • 在11g中,似乎<wsp:PolicyReference >标记直接添加到composite.xml文件中。 (这就是为什么我试图在我之前的测试中直接在复合中设置策略...)

所以我也尝试在配置计划中添加<sca11:policySet >,但它失败了......

命名空间的差异

如果你照顾wsp:,你会看到:

  • wsm-assembly.xml中,在此处定义:xmlns:wsp="http://www.w3.org/ns/ws-policy"
  • 位于composite.xmlconfiguration plan,其定义如下:xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"

所以我也尝试在配置计划中强制命名空间为http://www.w3.org/ns/ws-policy,但部署失败(即未应用配置计划)。

我不知道如何进一步......

有人可以分享想法吗?有人在不同的环境中成功查询不同策略的REST服务吗?

非常感谢。

1 个答案:

答案 0 :(得分:1)

在DEV环境中部署项目后,

1)转到Oracle Fusion Middleware控制台。 2)打开项目。 3)在OWSM策略选项卡下,您可以添加或删除此策略。 4)删除后保存会话并重试。

还有另一种选择。

您可以通过复制oracle / wss_http_token_client_policy类型的 permit all 类型策略来创建新的自己的策略,而不是使用oracle / wss_http_token_client_policy策略。

在此新策略中,您可以添加您在weblogic上创建的用户或组。

在DEV服务器上部署项目时,请勿在此新策略中添加任何用户或组,默认情况下,这将允许所有用户访问此服务。