简体   繁体   English

耶拿安全与修复

[英]Jena Security with Reification

Given this example RDF how could I use jena security to only retrieve values where user role matches ex:role? 给定此示例RDF,我如何使用耶拿安全性仅检索用户角色与ex:role匹配的值?

_:statement rdf:type rdf:Statement .
_:statement rdf:subject dbr:Ireland .
_:statement rdf:predicate dbo:capital .
_:statement rdf:object dbo:Dublin .
_:statement ex:role "ROLEA", "ROLEB", "ROLEC" .

_:statement rdf:type rdf:Statement .
_:statement rdf:subject dbr:Canada.
_:statement rdf:predicate dbo:capital .
_:statement rdf:object dbo:Ottawa .
_:statement ex:role "ROLEA" .

I am not sure how to accomplish this given jena Security (ie SecurityEvaluator). 在给定的耶拿安全性(即SecurityEvaluator)下,我不确定如何完成此操作。 Thanks. 谢谢。

There is minimal information provided in your question. 您的问题中提供的信息最少。 I will attempt to answer and will attempt to identify the assumptions I am making. 我将尝试回答并尝试确定我所做的假设。

I am using the term "base graph" to mean the graph that you are querying. 我使用术语“基础图”来表示您要查询的图。 This may be a combination of multiple physical graphs. 这可能是多个物理图的组合。 It is the graph that contains the data that will be queried and returned to the user. 该图包含将要查询并返回给用户的数据。

I am using the term "security graph" to mean a graph that stores data about security access. 我使用的术语“安全图”表示存储有关安全访问的数据的图。

First I assume that you have a mechanism to associate the logged in user with the roles the user has access to. 首先,我假设您具有一种将登录用户与该用户有权访问的角色相关联的机制。 This may be a list of roles for a user or a method that returns true if the user has a specific role. 这可以是用户角色的列表,也可以是如果用户具有特定角色则返回true的方法。 Implementation details aside, there is a method to determine that a user has a role. 除了实现细节之外,还有一种确定用户具有角色的方法。

Second I assume from your question that you want to check each triple in the base graph and that the reification of each triple is stored in the "security graph". 其次,我从您的问题中假设您要检查基本图中的每个三元组,并且每个三元组的形式化存储在“安全图”中。 This means that your security graph will be much larger than your data graph. 这意味着您的安全图将比数据图大得多。 If you are only interested restricting access to triples that have a predicate of dbo:capital it might be better to create a new type that has the dbr:country what groups have access to the country. 如果您只想限制访问以dbo:capital为谓词的三元组,则最好创建一个具有dbr:country的新类型,哪些组可以访问该国家。 But for now I will proceed on the assumption that you will create the reified statements with the role property and that you will do this for each triple that you are interested in restricting. 但是现在,我将继续假设您将创建具有角色属性的经过修饰的语句,并针对您希望限制的每个三元组执行此操作。

The "security graph" must be accessible from within the SecurityEvaluator (this is part of setting up the evaluator). 必须从SecurityEvaluator内部访问“安全图”(这是设置评估器的一部分)。

Third assumption the data graph is identified by the graph name "urn:graph-name:data-graph". 第三个假设数据图由图名称“ urn:graph-name:data-graph”标识。

When the triple <dbr:Ireland, dbo:capital, dbo:Dublin> is read from "urn:graph-name:data-graph" 从“ urn:graph-name:data-graph”读取三元组<dbr:Ireland,dbo:capital,dbo:Dublin>

The method SecurityEvaluator.evaluate( Acton.Read, "urn:graph-name:data-graph" ) will be called first. 首先将调用SecurityEvaluator.evaluate(Acton.Read,“ urn:graph-name:data-graph”)方法。 The Evaluator should return "true" to indicate that the user has read access to the graph. 评估者应返回“ true”,以指示用户具有对该图的读取权限。

Second the method SecurityEvaluator.evaluate( Action.Read, "urn:graph-name:data-graph", SecTriple.ANY ) will be called. 第二个方法将被调用SecurityEvaluator.evaluate(Action.Read,“ urn:graph-name:data-graph”,SecTriple.ANY)。 The SecurityEvaluator should return "false" to indicate that that there are restrictions on some triples in the data graph. SecurityEvaluator应该返回“ false”,以指示数据图中的某些三元组存在限制。 If you have a role that can read all the data elements you could return "true" here for users that have that role. 如果您具有可以读取所有数据元素的角色,则可以在此处为具有该角色的用户返回“ true”。

Finally the method SecurityEvaluator.evaluate( Action.Read, "urn:graph-name:data-graph", <dbr:Ireland, dbo:capital, dbo:Dublin> ) will be called. 最后,将调用方法SecurityEvaluator.evaluate(Action.Read,“ urn:graph-name:data-graph”,<dbr:Ireland,dbo:capital,dbo:Dublin>)。 The evaluator should then look up the rdf:Statement that covers the <dbr:Ireland, dbo:capital, dbo:Dublin> triple, retrieve the roles that have access, compare those with the roles that the user has and if there is an intersection return "true" otherwise return "false". 然后,评估者应查找覆盖<dbr:Ireland,dbo:capital,dbo:Dublin>三元组的rdf:Statement,检索具有访问权限的角色,将这些角色与用户拥有的角色进行比较,以及是否存在交集返回“ true”,否则返回“ false”。

A couple of things to consider: 需要考虑的几件事:

Often the security/permissions system is concerned with access to specific properties of objects, working out how to store those properties with roles will often reduce the size of the "security graph" and will make the system more efficient. 安全/权限系统通常与访问对象的特定属性有关,弄清楚如何使用角色存储这些属性通常会减小“安全图”的大小,并使系统更有效。

Using reification to identify triples that need to be filtered means that if someone adds a new triple say <dbr:Ireland, dbo:capital, "Dublin"> The triple will not be blocked. 使用验证来确定需要过滤的三元组意味着,如果有人添加了一个新的三元组,请说<dbr:Ireland,dbo:capital,“ Dublin”>该三元组不会被阻止。

If the triple <dbr:Ireland, dbo:capital, dbo:Dublin> exists in 2 graph that are combined to make one dataset and you only filter one graph the data will like. 如果在两个图形中存在三元组<dbr:Ireland,dbo:capital,dbo:Dublin>,它们组合在一起就构成一个数据集,而您只过滤了数据想要的一个图形。 This is intentional. 这是故意的。

In this discussion I used the term "security graph". 在此讨论中,我使用了“安全图”一词。 I did this because your example used reified triples to describe the data. 我这样做是因为您的示例使用了改进的三元组来描述数据。 There is no requirement to use a graph to store the security restrictions. 不需要使用图来存储安全性限制。 It is often easier to do so because the graph manipulation code is already at hand, but it is not required. 这样做通常更容易,因为图形操作代码已在手边,但不是必需的。 Any solution that will allow you to lookup the restricted components of the triples will work. 任何允许您查找三元组中受限制成分的解决方案都可以使用。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM