Search in sources :

Example 6 with SecurityEvaluator

use of org.apache.jena.permissions.SecurityEvaluator in project jena by apache.

the class SecuredAssemblerTest method testSecurityEvaluatorWithModelArgs.

@Test
public void testSecurityEvaluatorWithModelArgs() throws Exception {
    Resource r = model.createResource("http://apache.org/jena/permissions/test#secEvaluator2");
    Object o = assembler.open(r);
    Assert.assertTrue(o instanceof SecurityEvaluator);
    Assert.assertTrue(o instanceof ModelBasedSecurityEvaluator);
}
Also used : Resource(org.apache.jena.rdf.model.Resource) SecurityEvaluator(org.apache.jena.permissions.SecurityEvaluator) Test(org.junit.Test)

Example 7 with SecurityEvaluator

use of org.apache.jena.permissions.SecurityEvaluator in project jena by apache.

the class SecuredAssemblerTest method testSecurityEvaluatorWithStringArgs.

@Test
public void testSecurityEvaluatorWithStringArgs() throws Exception {
    Resource r = model.createResource("http://apache.org/jena/permissions/test#secEvaluator");
    Object o = assembler.open(r);
    Assert.assertTrue(o instanceof SecurityEvaluator);
    Assert.assertTrue(o instanceof StaticSecurityEvaluator);
}
Also used : Resource(org.apache.jena.rdf.model.Resource) SecurityEvaluator(org.apache.jena.permissions.SecurityEvaluator) Test(org.junit.Test)

Example 8 with SecurityEvaluator

use of org.apache.jena.permissions.SecurityEvaluator 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;
            }
        };
    }
}
Also used : Triple(org.apache.jena.graph.Triple) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph) Graph(org.apache.jena.graph.Graph) Node(org.apache.jena.graph.Node) SecurityEvaluator(org.apache.jena.permissions.SecurityEvaluator) Principal(java.security.Principal) SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph)

Aggregations

SecurityEvaluator (org.apache.jena.permissions.SecurityEvaluator)8 Test (org.junit.Test)7 Triple (org.apache.jena.graph.Triple)5 MockSecurityEvaluator (org.apache.jena.permissions.MockSecurityEvaluator)5 Node (org.apache.jena.graph.Node)3 SecuredModel (org.apache.jena.permissions.model.SecuredModel)3 QueryExecution (org.apache.jena.query.QueryExecution)3 ResultSet (org.apache.jena.query.ResultSet)3 OpRewriter (org.apache.jena.permissions.query.rewriter.OpRewriter)2 Resource (org.apache.jena.rdf.model.Resource)2 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)2 Principal (java.security.Principal)1 Graph (org.apache.jena.graph.Graph)1 SecuredGraph (org.apache.jena.permissions.graph.SecuredGraph)1 SecuredFunction (org.apache.jena.permissions.query.rewriter.SecuredFunction)1 ReadDeniedException (org.apache.jena.shared.ReadDeniedException)1 Op (org.apache.jena.sparql.algebra.Op)1 OpFilter (org.apache.jena.sparql.algebra.op.OpFilter)1 BasicPattern (org.apache.jena.sparql.core.BasicPattern)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1