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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations