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