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