use of org.apache.jena.permissions.graph.SecuredGraph in project jena by apache.
the class SecuredPrefixMappingTest method setup.
@Before
public void setup() {
final Graph g = GraphFactory.createDefaultGraph();
final SecuredGraph sg = Factory.getInstance(securityEvaluator, "http://example.com/testGraph", g);
this.securedMapping = sg.getPrefixMapping();
}
use of org.apache.jena.permissions.graph.SecuredGraph in project jena by apache.
the class Factory method getInstance.
/**
* Create an instance of the SecuredGraph
*
* @param securityEvaluator
* The security evaluator to use
* @param graphIRI
* The IRI for the graph.
* @param graph
* The graph that we are wrapping.
* @return the secured graph
*/
public static SecuredGraph getInstance(final SecurityEvaluator securityEvaluator, final String graphIRI, final Graph graph) {
final ItemHolder<Graph, SecuredGraphImpl> holder = new ItemHolder<>(graph);
final SecuredGraphImpl checker = new SecuredGraphImpl(securityEvaluator, graphIRI, holder) {
};
// If we going to create a duplicate proxy return this one.
if (graph instanceof SecuredGraphImpl) {
if (checker.isEquivalent((SecuredGraphImpl) graph)) {
return (SecuredGraph) graph;
}
}
return holder.setSecuredItem(new SecuredItemInvoker(graph.getClass(), checker));
}
use of org.apache.jena.permissions.graph.SecuredGraph in project jena by apache.
the class SecuredModelTest method testGetGraph.
@Test
public void testGetGraph() throws Exception {
final Graph g = securedModel.getGraph();
Assert.assertTrue(g instanceof SecuredGraph);
EqualityTester.testInequality("getGraph test", g, baseModel.getGraph());
}
use of org.apache.jena.permissions.graph.SecuredGraph in project jena by apache.
the class MemGraphTest method testInequality.
@Test
public void testInequality() {
EqualityTester.testInequality("proxy and base", securedGraph, baseGraph);
final Graph g2 = org.apache.jena.permissions.graph.impl.Factory.getInstance(securityEvaluator, "http://example.com/securedGraph", baseGraph);
EqualityTester.testEquality("proxy and proxy2", securedGraph, g2);
EqualityTester.testInequality("base and proxy2", baseGraph, g2);
}
use of org.apache.jena.permissions.graph.SecuredGraph in project jena by apache.
the class SecuredQueryEngine method setGraphIRI.
private void setGraphIRI(final DatasetGraph dataset) {
final Graph g = dataset.getDefaultGraph();
if (g instanceof SecuredGraph) {
final SecuredGraph sg = (SecuredGraph) g;
graphIRI = sg.getModelNode();
this.securityEvaluator = sg.getSecurityEvaluator();
} else {
graphIRI = NodeFactory.createURI("urn:x-arq:DefaultGraph");
this.securityEvaluator = new SecurityEvaluator() {
@Override
public boolean evaluate(final Object principal, final Action action, final Node graphIRI) {
return true;
}
@Override
public boolean evaluate(final Object principal, final Action action, final Node graphIRI, final Triple triple) {
return true;
}
@Override
public boolean evaluate(final Object principal, final Set<Action> action, final Node graphIRI) {
return true;
}
@Override
public boolean evaluate(final Object principal, final Set<Action> action, final Node graphIRI, final Triple triple) {
return true;
}
@Override
public boolean evaluateAny(final Object principal, final Set<Action> action, final Node graphIRI) {
return true;
}
@Override
public boolean evaluateAny(final Object principal, final Set<Action> action, final Node graphIRI, final Triple triple) {
return true;
}
@Override
public boolean evaluateUpdate(final Object principal, final Node graphIRI, final Triple from, final Triple to) {
return true;
}
@Override
public Principal getPrincipal() {
return null;
}
@Override
public boolean isPrincipalAuthenticated(Object principal) {
return true;
}
};
}
}
Aggregations