use of org.apache.jena.permissions.model.SecuredAlt 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.model.SecuredAlt in project jena by apache.
the class SecuredSeqTest method testGetAlt.
@Test
public void testGetAlt() {
try {
final Alt a = getSecuredSeq().getAlt(1);
Assert.assertTrue("Should be a secured Alt", a instanceof SecuredAlt);
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