Search in sources :

Example 6 with SecuredItemInvoker

use of org.apache.jena.permissions.impl.SecuredItemInvoker in project jena by apache.

the class SecuredContainerImpl method getInstance.

/**
	 * Constructor
	 * 
	 * @param securedModel
	 *            the Secured Model to use.
	 * @param container
	 *            The container to secure.
	 * @return The SecuredResource
	 */
public static SecuredContainer getInstance(final SecuredModel securedModel, final Container container) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (container == null) {
        throw new IllegalArgumentException("Container may not be null");
    }
    // check that resource has a securedModel.
    Container goodContainer = container;
    if (goodContainer.getModel() == null) {
        container.asNode();
        goodContainer = securedModel.createBag();
    }
    final ItemHolder<Container, SecuredContainer> holder = new ItemHolder<>(goodContainer);
    final SecuredContainerImpl checker = new SecuredContainerImpl(securedModel, holder);
    // one.
    if (goodContainer instanceof SecuredContainer) {
        if (checker.isEquivalent((SecuredContainer) goodContainer)) {
            return (SecuredContainer) goodContainer;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(container.getClass(), checker));
}
Also used : SecuredContainer(org.apache.jena.permissions.model.SecuredContainer) ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredContainer(org.apache.jena.permissions.model.SecuredContainer)

Example 7 with SecuredItemInvoker

use of org.apache.jena.permissions.impl.SecuredItemInvoker 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));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph) Graph(org.apache.jena.graph.Graph) SecuredGraph(org.apache.jena.permissions.graph.SecuredGraph)

Example 8 with SecuredItemInvoker

use of org.apache.jena.permissions.impl.SecuredItemInvoker in project jena by apache.

the class SecuredAltImpl method getInstance.

/**
	 * Get an instance of SecuredAlt.
	 * 
	 * @param securedModel
	 *            the Secured Model to use.
	 * @param alt
	 *            The Alt to be secured.
	 * @return The secured Alt instance.
	 */
public static SecuredAlt getInstance(final SecuredModel securedModel, final Alt alt) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (alt == null) {
        throw new IllegalArgumentException("Alt may not be null");
    }
    final ItemHolder<Alt, SecuredAlt> holder = new ItemHolder<>(alt);
    final SecuredAltImpl checker = new SecuredAltImpl(securedModel, holder);
    // one.
    if (alt instanceof SecuredAlt) {
        if (checker.isEquivalent((SecuredAlt) alt)) {
            return (SecuredAlt) alt;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(alt.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredAlt(org.apache.jena.permissions.model.SecuredAlt) SecuredAlt(org.apache.jena.permissions.model.SecuredAlt)

Example 9 with SecuredItemInvoker

use of org.apache.jena.permissions.impl.SecuredItemInvoker in project jena by apache.

the class SecuredBagImpl method getInstance.

/**
	 * Get an instance of SecuredBag
	 * 
	 * @param securedModel
	 *            The Secured Model to use.
	 * @param bag
	 *            The bag to secure
	 * @return The SecuredBag
	 */
public static SecuredBag getInstance(final SecuredModel securedModel, final Bag bag) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (bag == null) {
        throw new IllegalArgumentException("Bag may not be null");
    }
    final ItemHolder<Bag, SecuredBag> holder = new ItemHolder<>(bag);
    final SecuredBagImpl checker = new SecuredBagImpl(securedModel, holder);
    // one.
    if (bag instanceof SecuredBag) {
        if (checker.isEquivalent((SecuredBag) bag)) {
            return (SecuredBag) bag;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(bag.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredBag(org.apache.jena.permissions.model.SecuredBag) SecuredBag(org.apache.jena.permissions.model.SecuredBag) Bag(org.apache.jena.rdf.model.Bag)

Example 10 with SecuredItemInvoker

use of org.apache.jena.permissions.impl.SecuredItemInvoker in project jena by apache.

the class SecuredLiteralImpl method getInstance.

/**
	 * Get an instance of SecuredLiteral
	 * 
	 * @param securedModel
	 *            the item providing the security context.
	 * @param literal
	 *            the literal to secure
	 * @return SecuredLiteral
	 */
public static SecuredLiteral getInstance(final SecuredModel securedModel, final Literal literal) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (literal == null) {
        throw new IllegalArgumentException("literal may not be null");
    }
    // check that literal has a securedModel.
    Literal goodLiteral = literal;
    if (goodLiteral.getModel() == null) {
        goodLiteral = securedModel.createTypedLiteral(literal.getLexicalForm(), literal.getDatatype());
    }
    final ItemHolder<Literal, SecuredLiteral> holder = new ItemHolder<>(goodLiteral);
    final SecuredLiteralImpl checker = new SecuredLiteralImpl(securedModel, holder);
    // one.
    if (goodLiteral instanceof SecuredLiteral) {
        if (checker.isEquivalent((SecuredLiteral) goodLiteral)) {
            return (SecuredLiteral) goodLiteral;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(literal.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredLiteral(org.apache.jena.permissions.model.SecuredLiteral) Literal(org.apache.jena.rdf.model.Literal) SecuredLiteral(org.apache.jena.permissions.model.SecuredLiteral)

Aggregations

ItemHolder (org.apache.jena.permissions.impl.ItemHolder)13 SecuredItemInvoker (org.apache.jena.permissions.impl.SecuredItemInvoker)13 Node (org.apache.jena.graph.Node)2 Graph (org.apache.jena.graph.Graph)1 SecuredGraph (org.apache.jena.permissions.graph.SecuredGraph)1 SecuredPrefixMapping (org.apache.jena.permissions.graph.SecuredPrefixMapping)1 SecuredAlt (org.apache.jena.permissions.model.SecuredAlt)1 SecuredBag (org.apache.jena.permissions.model.SecuredBag)1 SecuredContainer (org.apache.jena.permissions.model.SecuredContainer)1 SecuredLiteral (org.apache.jena.permissions.model.SecuredLiteral)1 SecuredProperty (org.apache.jena.permissions.model.SecuredProperty)1 SecuredRDFList (org.apache.jena.permissions.model.SecuredRDFList)1 SecuredReifiedStatement (org.apache.jena.permissions.model.SecuredReifiedStatement)1 SecuredResource (org.apache.jena.permissions.model.SecuredResource)1 Bag (org.apache.jena.rdf.model.Bag)1 Literal (org.apache.jena.rdf.model.Literal)1 Property (org.apache.jena.rdf.model.Property)1 ReifiedStatement (org.apache.jena.rdf.model.ReifiedStatement)1 PrefixMapping (org.apache.jena.shared.PrefixMapping)1