use of org.apache.jena.permissions.model.SecuredBag 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.model.SecuredBag in project jena by apache.
the class SecuredSeqTest method testGetBag.
@Test
public void testGetBag() {
try {
final Bag a = getSecuredSeq().getBag(1);
Assert.assertTrue("Should be a secured Bag", a instanceof SecuredBag);
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
}
Aggregations