Search in sources :

Example 1 with ItemHolder

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

the class SecuredRDFListImpl method getInstance.

/**
	 * Get an instance of SecuredProperty
	 * 
	 * @param securedModel
	 *            the Secured Model to use.
	 * @param rdfList
	 *            The rdfList to secure
	 * @return The SecuredProperty
	 */
public static <T extends RDFList> SecuredRDFList getInstance(final SecuredModel securedModel, final T rdfList) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (rdfList == null) {
        throw new IllegalArgumentException("RDFList may not be null");
    }
    // check that property has a securedModel.
    RDFList goodList = rdfList;
    if (goodList.getModel() == null) {
        goodList = securedModel.createList(rdfList.asJavaList().iterator());
    }
    final ItemHolder<RDFList, SecuredRDFList> holder = new ItemHolder<>(goodList);
    final SecuredRDFListImpl checker = new SecuredRDFListImpl(securedModel, holder);
    // one.
    if (goodList instanceof SecuredRDFList) {
        if (checker.isEquivalent((SecuredRDFList) goodList)) {
            return (SecuredRDFList) goodList;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(rdfList.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredRDFList(org.apache.jena.permissions.model.SecuredRDFList) SecuredRDFList(org.apache.jena.permissions.model.SecuredRDFList)

Example 2 with ItemHolder

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

the class SecuredReifiedStatementImpl method getInstance.

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

Example 3 with ItemHolder

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

the class SecuredResourceImpl method getInstance.

/**
	 * Get a SecuredResource.
	 * 
	 * @param securedModel
	 *            the securedItem that provides the security context.
	 * @param resource
	 *            The resource to secure.
	 * @return The SecuredResource
	 */
public static SecuredResource getInstance(final SecuredModel securedModel, final Resource resource) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (resource == null) {
        throw new IllegalArgumentException("Resource may not be null");
    }
    if (resource.isLiteral()) {
        throw new IllegalArgumentException("Resource may not be a literal");
    }
    // check that resource has a securedModel.
    Resource goodResource = resource;
    if (goodResource.getModel() == null) {
        final Node n = resource.asNode();
        if (resource.isAnon()) {
            goodResource = securedModel.createResource(new AnonId(n.getBlankNodeId()));
        } else {
            goodResource = securedModel.createResource(n.getURI());
        }
    }
    final ItemHolder<Resource, SecuredResource> holder = new ItemHolder<>(goodResource);
    final SecuredResourceImpl checker = new SecuredResourceImpl(securedModel, holder);
    // one.
    if (goodResource instanceof SecuredResource) {
        if (checker.isEquivalent((SecuredResource) goodResource)) {
            return (SecuredResource) goodResource;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(resource.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) Node(org.apache.jena.graph.Node) SecuredResource(org.apache.jena.permissions.model.SecuredResource) SecuredResource(org.apache.jena.permissions.model.SecuredResource)

Example 4 with ItemHolder

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

the class SecuredModelImpl method getInstance.

/**
	 * Get an instance of SecuredModel
	 * 
	 * @param securityEvaluator
	 *            The security evaluator to use
	 * @param modelIRI
	 *            The IRI (graph IRI) to name this model.
	 * @param model
	 *            The Model to secure.
	 * @return the SecuredModel
	 */
public static SecuredModel getInstance(final SecurityEvaluator securityEvaluator, final String modelIRI, final Model model) {
    final ItemHolder<Model, SecuredModel> holder = new ItemHolder<>(model);
    final SecuredModelImpl checker = new SecuredModelImpl(securityEvaluator, modelIRI, holder);
    // one.
    if (model instanceof SecuredModel) {
        if (checker.isEquivalent((SecuredModel) model)) {
            return (SecuredModel) model;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(model.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker)

Example 5 with ItemHolder

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

the class Factory method getInstance.

/**
	 * Create an instance of SecuredPrefixMapping
	 * 
	 * @param graph
	 *            The SecuredGraph that contains the prefixmapping.
	 * @param prefixMapping
	 *            The prefixmapping returned from the base graph.
	 * @return The SecuredPrefixMapping.
	 */
static SecuredPrefixMapping getInstance(final SecuredGraphImpl graph, final PrefixMapping prefixMapping) {
    final ItemHolder<PrefixMapping, SecuredPrefixMapping> holder = new ItemHolder<>(prefixMapping);
    final SecuredPrefixMappingImpl checker = new SecuredPrefixMappingImpl(graph, holder);
    // if we are going to create a duplicate proxy just return this one.
    if (prefixMapping instanceof SecuredPrefixMapping) {
        if (checker.isEquivalent((SecuredPrefixMapping) prefixMapping)) {
            return (SecuredPrefixMapping) prefixMapping;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(prefixMapping.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredPrefixMapping(org.apache.jena.permissions.graph.SecuredPrefixMapping) PrefixMapping(org.apache.jena.shared.PrefixMapping) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredPrefixMapping(org.apache.jena.permissions.graph.SecuredPrefixMapping)

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