use of org.apache.jena.permissions.impl.ItemHolder 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));
}
use of org.apache.jena.permissions.impl.ItemHolder 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));
}
use of org.apache.jena.permissions.impl.ItemHolder 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));
}
Aggregations