有没有办法根据评估中使用的属性(例如环境)动态生成在XACML响应中返回的Advice
或Obligation
字符串?
例如,通过实现逻辑的扩展。
答案 0 :(得分:2)
在XACML 3.0中,Obligation
和Advice
元素可以包含属性分配。属性分配是可以用静态值或动态值填充的占位符,例如,来自另一个XACML属性的值。例如,我们可以使用以下内容(使用alfa表示法 - Axiomatics Language for Authorization):
obligation notifyManager = "com.axiomatics.examples.notification.notifyManager"
policy accessDocs{
apply firstApplicable
rule denyOutOfOffice{
target clause currentTime>"17:00:00":time or currentTime<"09:00:00":time
deny
on deny{
obligation notifyManager{
com.axiomatics.examples.message = "You cannot access anything outside office hours"
com.axiomatics.examples.user.managerEmail = com.axiomatics.examples.user.managerEmail
}
}
}
}
在此示例中,义务有2个占位符:
您可以在占位符中使用功能,例如字符串连接。
XACML源代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--This file was generated by the ALFA Plugin for Eclipse from Axiomatics AB (http://www.axiomatics.com).
Any modification to this file will be lost upon recompilation of the source ALFA file-->
<xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
PolicyId="http://axiomatics.com/alfa/identifier/example.accessDocs"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
Version="1.0">
<xacml3:Description />
<xacml3:PolicyDefaults>
<xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion>
</xacml3:PolicyDefaults>
<xacml3:Target />
<xacml3:Rule
Effect="Deny"
RuleId="http://axiomatics.com/alfa/identifier/example.accessDocs.denyOutOfOffice">
<xacml3:Description />
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:time-less-than">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#time">17:00:00</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time"
DataType="http://www.w3.org/2001/XMLSchema#time"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:time-greater-than">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#time">09:00:00</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time"
DataType="http://www.w3.org/2001/XMLSchema#time"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
<xacml3:ObligationExpressions>
<xacml3:ObligationExpression ObligationId="com.axiomatics.examples.notification.notifyManager"
FulfillOn="Deny">
<xacml3:AttributeAssignmentExpression AttributeId="com.axiomatics.examples.message" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">You cannot access anything outside office hours</xacml3:AttributeValue>
</xacml3:AttributeAssignmentExpression>
<xacml3:AttributeAssignmentExpression AttributeId="com.axiomatics.examples.user.manager.email" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
<xacml3:AttributeDesignator
AttributeId="com.axiomatics.examples.user.manager.email"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
</xacml3:AttributeAssignmentExpression>
</xacml3:ObligationExpression>
</xacml3:ObligationExpressions>
</xacml3:Rule>
</xacml3:Policy>