XACML政策评估错误

时间:2014-03-10 09:12:23

标签: java web-services xacml xacml2 pdp

我跟随link在XACML上使用SAML信封运行pdp。然后我创建了webservice(pdp和pdpclient - 换句话说就是XACML Request Generator)。在这里,每件事都运行正常,即生成请求并使用给定的(link)策略给出的测试策略获得完美的结果。

现在我用我的政策测试pdp !!但是(在我看来)pdp并没有正确评估政策。例如,这是我的政策

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Policy xmlns="urn:oasis:names:tc:xacml:2.0:policy:schema:os"
    PolicyId="ServerDataDeletion" Version="2.0"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:deny-overrides">
    <Description>Server Data Deletion by Student</Description>
    <Target>
        <Subjects>
            <Subject>
                <SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Visitor</AttributeValue>
                    <SubjectAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:subject:outside-university"
                        DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                </SubjectMatch>
            </Subject>
        </Subjects>
        <Resources>
            <Resource>
                <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Server File</AttributeValue>
                    <ResourceAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:resource:file123"
                        DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                </ResourceMatch>
            </Resource>
        </Resources>
        <Actions>
            <Action>
                <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Delete</AttributeValue>
                    <ActionAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:action:delete123"
                        DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                </ActionMatch>
            </Action>
        </Actions>
    </Target>
    <Rule RuleId="ServerDataDeletion" Effect="Permit">
        <Description>Server Data Deletion</Description>
        <Target>
            <Subjects>
                <Subject>
                    <SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Student</AttributeValue>
                        <SubjectAttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:subject:inside-university123"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                    </SubjectMatch>
                </Subject>
            </Subjects>
            <Resources>
                <Resource>
                    <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Server File</AttributeValue>
                        <ResourceAttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:resource:file"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
                    </ResourceMatch>
                </Resource>
            </Resources>
            <Actions>
                <Action>
                    <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Delete</AttributeValue>
                        <ActionAttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:action:delete"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
                    </ActionMatch>
                </Action>
            </Actions>
        </Target>
    </Rule>
    <Rule RuleId="Default" Effect="Deny" />
</Policy>

这是我的要求

  

Subject-Id:urn:oasis:names:tc:xacml:1.0:subject:outside-university,   主题 - 价值:员工

     

Arttibute-ID:   urn:oasis:names:tc:xacml:1.0:resource:file123,Attribute-Value:Server   档案

     

Action-Id:urn:oasis:names:tc:xacml:1.0:action:delete123,   行动价值:删除

我得到的回应是拒绝。如您所见,主题,资源和策略目标和请求的行为MustBePresent = true包含无Id。根据XACML 2.0,如果MustBePresent为true且请求中不存在ID,则目标将为Indeterminate。如果目标是政策目标,那么整个政策将是不确定的。但在这种情况下,在不确定的策略目标之后,PDP仍然会根据规则组合算法评估规则并制定结果。

如果我错了,请告诉我。

1 个答案:

答案 0 :(得分:0)

实际上,快速浏览一下,你应该得到NotApplicable

您有以下结构:

  • 政策
    • 规则1:ServerDataDeletion产生许可
    • 规则2:默认收益率拒绝。

您的保单的目标如下:

<Target>
    <Subjects>
        <Subject>
            <SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Visitor</AttributeValue>
                <SubjectAttributeDesignator
                    AttributeId="urn:oasis:names:tc:xacml:1.0:subject:outside-university"
                    DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
            </SubjectMatch>
        </Subject>
    </Subjects>
    <Resources>
        <Resource>
            <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Server File</AttributeValue>
                <ResourceAttributeDesignator
                    AttributeId="urn:oasis:names:tc:xacml:1.0:resource:file123"
                    DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
            </ResourceMatch>
        </Resource>
    </Resources>
    <Actions>
        <Action>
            <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Delete</AttributeValue>
                <ActionAttributeDesignator
                    AttributeId="urn:oasis:names:tc:xacml:1.0:action:delete123"
                    DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
            </ActionMatch>
        </Action>
    </Actions>
</Target>

仅在您Visitor尝试Delete Server File时才适用。

在您的请求中,您发送的是Staff,而不是Visitor。因此,您应该获得NotApplicable

如果有机会,请转到XACML 3.0。查看ALFA plugin for Eclipse即可轻松编写政策。