Search in sources :

Example 1 with SecuredContainer

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));
}
Also used : SecuredContainer(org.apache.jena.permissions.model.SecuredContainer) ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredContainer(org.apache.jena.permissions.model.SecuredContainer)

Aggregations

ItemHolder (org.apache.jena.permissions.impl.ItemHolder)1 SecuredItemInvoker (org.apache.jena.permissions.impl.SecuredItemInvoker)1 SecuredContainer (org.apache.jena.permissions.model.SecuredContainer)1