wso2 IS:使用importPolicyFromRegistry API

时间:2014-04-11 07:04:11

标签: wso2is

我想使用SOAP importPolicyFromRegistry API将策略导入WSo2IS 我首先使用正在运行的wso2编辑器创建了1个模板策略。然后我想通过仅更改PolicyId和一些attributeValue来导入它们的副本。 ImportPolicyFromRegistry API似乎正是我正在寻找的, 不幸的是,似乎必须将policyRegistryPath设置为特定值(内部wso2注册表路径)。 当我尝试设置一个地方lime /tmp/mypolicy.xml时,我得到一个"索引超出范围-1和#34;。看一下wso2 java代码,看来这个API正在寻找一个包含CONFIG_REGISTRY_IDENTIFIER全局参数的路径......

如果你能给我一些例子或指导,这对我有很大帮助。!!

由于 VPL

3 个答案:

答案 0 :(得分:1)

这就是我要找的东西。

我终于成功使用了你的java示例,但发送到虚拟的http地址并使用wireskark跟踪流量......

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Body>
        <ns3:addPolicy xmlns:ns3="http://org.apache.axis2/xsd">
            <ns3:policyDTO>
                <ns1:policy xmlns:ns1="http://dto.entitlement.identity.carbon.wso2.org/xsd">    
                <![CDATA[
                    <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="policy-3" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0">
                       <Target>
                          <AnyOf>
                             <AllOf>
                                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/tenant-3/*</AttributeValue>
                                   <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
                                </Match>
                             </AllOf>
                          </AnyOf>
                       </Target>
                       <Rule Effect="Permit" RuleId="rule-31">
                          <Condition>
                             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in">
                                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">turlututu</AttributeValue>
                                <AttributeDesignator AttributeId="http://wso2.org/claims/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
                             </Apply>
                          </Condition>
                       </Rule>
                    </Policy>               
                ]]>
                </ns1:policy>
            </ns3:policyDTO>
        </ns3:addPolicy>
    </soapenv:Body>
</soapenv:Envelope>

答案 1 :(得分:0)

如果您使用importPolicyFromRegistry方法,则表示您的策略必须位于WSO2注册表位置。首先,您必须将您的策略​​上传到WSO2注册表,然后您可以使用上述方法将策略上传到实际的PDP。您需要提供策略路径作为注册表资源路径...这意味着,如果策略在配置注册表中。如果策略位于治理注册表conf:/{path to policy}

,则策略路径为gov:/{path to policy}

此外,如果您使用模板策略创建策略,我猜您可以使用addPolicy方法来执行此操作。您可以从here

找到策略管理Java客户端

答案 2 :(得分:0)

这就是我要找的东西。

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyId="testAnd" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" Version="1.0">
   <Description>Test And</Description>
   <Target></Target>
   <Rule Effect="Permit" RuleId="primary-group-emps-rule">
      <Target>
         <AnyOf>
            <AllOf>
               <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">http://localhost:8280/services/Customers/getEmployees</AttributeValue>
                  <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
               </Match>
               <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
                  <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
               </Match>
            </AllOf>
         </AnyOf>
      </Target>
      <Condition>
         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-set-equals">
            <AttributeDesignator AttributeId="group" DataType="http://www.w3.org/2001/XMLSchema#string" Category="urn:oasis:names:tc:xacml:3.0:example-group" MustBePresent="true"></AttributeDesignator>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin_emps</AttributeValue>
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue>
            </Apply>
         </Apply>
      </Condition>
   </Rule>
   <Rule Effect="Deny" RuleId="deny-rule"></Rule>
</Policy>

关心 VPL