Search in sources :

Example 11 with SecuredItemInvoker

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

the class SecuredSeqImpl method getInstance.

/**
	 * get a SecuredSeq.
	 * 
	 * @param securedModel
	 *            The secured model that provides the security context
	 * @param seq
	 *            The Seq to secure.
	 * @return the SecuredSeq
	 */
public static SecuredSeq getInstance(final SecuredModel securedModel, final Seq seq) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (seq == null) {
        throw new IllegalArgumentException("Seq may not be null");
    }
    final ItemHolder<Seq, SecuredSeq> holder = new ItemHolder<>(seq);
    final SecuredSeqImpl checker = new SecuredSeqImpl(securedModel, holder);
    // one.
    if (seq instanceof SecuredSeq) {
        if (checker.isEquivalent((SecuredSeq) seq)) {
            return (SecuredSeq) seq;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(seq.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker)

Example 12 with SecuredItemInvoker

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

the class SecuredPropertyImpl method getInstance.

/**
	 * Get an instance of SecuredProperty
	 * 
	 * @param securedModel
	 *            the Secured Model to use.
	 * @param property
	 *            The property to secure
	 * @return The SecuredProperty
	 */
public static SecuredProperty getInstance(final SecuredModel securedModel, final Property property) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (property == null) {
        throw new IllegalArgumentException("Property may not be null");
    }
    // check that property has a securedModel.
    Property goodProp = property;
    if (goodProp.getModel() == null) {
        final Node n = property.asNode();
        if (property.isAnon()) {
            goodProp = securedModel.createProperty(n.getBlankNodeId().getLabelString());
        } else {
            goodProp = securedModel.createProperty(property.asNode().getURI());
        }
    }
    final ItemHolder<Property, SecuredProperty> holder = new ItemHolder<>(goodProp);
    final SecuredPropertyImpl checker = new SecuredPropertyImpl(securedModel, holder);
    // one.
    if (goodProp instanceof SecuredProperty) {
        if (checker.isEquivalent((SecuredProperty) goodProp)) {
            return (SecuredProperty) goodProp;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(property.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredProperty(org.apache.jena.permissions.model.SecuredProperty) Node(org.apache.jena.graph.Node) SecuredProperty(org.apache.jena.permissions.model.SecuredProperty) Property(org.apache.jena.rdf.model.Property)

Example 13 with SecuredItemInvoker

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

the class SecuredStatementImpl method getInstance.

/**
	 * get a SecuredStatement
	 * 
	 * @param securedModel
	 *            The secured model that provides the security context
	 * @param stmt
	 *            The statement to secure.
	 * @return the SecuredStatement
	 */
public static SecuredStatement getInstance(final SecuredModel securedModel, final Statement 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<Statement, SecuredStatement> holder = new ItemHolder<>(stmt);
    final SecuredStatementImpl checker = new SecuredStatementImpl(securedModel, holder);
    // one.
    if (stmt instanceof SecuredStatement) {
        if (checker.isEquivalent((SecuredStatement) stmt)) {
            return (SecuredStatement) stmt;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(holder.getBaseItem().getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker)

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