use of org.apache.jena.permissions.graph.SecuredPrefixMapping in project jena by apache.
the class SecuredPrefixMappingTest method runTests.
public static void runTests(final SecurityEvaluator securityEvaluator, final PrefixMapping prefixMapping) throws Exception {
final PrefixMapping pm = prefixMapping;
Assert.assertNotNull("PrefixMapping may not be null", pm);
Assert.assertTrue("PrefixMapping should be secured", pm instanceof SecuredPrefixMapping);
final SecuredPrefixMappingTest pmTest = new SecuredPrefixMappingTest(securityEvaluator) {
@Override
public void setup() {
this.securedMapping = (SecuredPrefixMapping) pm;
}
};
Method lockTest = null;
for (final Method m : pmTest.getClass().getMethods()) {
if (m.isAnnotationPresent(Test.class)) {
// lock test must come last
if (m.getName().equals("testLock")) {
lockTest = m;
} else {
pmTest.setup();
m.invoke(pmTest);
}
}
}
Assert.assertNotNull("Did not find 'testLock' method", lockTest);
pmTest.setup();
lockTest.invoke(pmTest);
}
use of org.apache.jena.permissions.graph.SecuredPrefixMapping in project jena by apache.
the class SecuredPrefixMappingImpl method withDefaultMappings.
@Override
public SecuredPrefixMapping withDefaultMappings(final PrefixMapping map) throws UpdateDeniedException, AuthenticationRequiredException {
// mapping only updates if there are map entries to add. Since this gets
// called
// when we are doing deep triple checks while writing we need to attempt
// the
// update only if there are new updates to add.
PrefixMapping m = holder.getBaseItem();
PrefixMappingImpl pm = new PrefixMappingImpl();
for (Entry<String, String> e : map.getNsPrefixMap().entrySet()) {
if (m.getNsPrefixURI(e.getKey()) == null && m.getNsURIPrefix(e.getValue()) == null) {
pm.setNsPrefix(e.getKey(), e.getValue());
}
}
if (!pm.getNsPrefixMap().isEmpty()) {
checkUpdate();
holder.getBaseItem().withDefaultMappings(pm);
}
return holder.getSecuredItem();
}
use of org.apache.jena.permissions.graph.SecuredPrefixMapping in project jena by apache.
the class Factory method getInstance.
/**
* Create an instance of SecuredPrefixMapping
*
* @param graph The SecuredGraph that contains the prefixmapping.
* @param prefixMapping The prefixmapping returned from the base graph.
* @return The SecuredPrefixMapping.
*/
static SecuredPrefixMapping getInstance(final SecuredGraphImpl graph, final PrefixMapping prefixMapping) {
final ItemHolder<PrefixMapping, SecuredPrefixMapping> holder = new ItemHolder<>(prefixMapping);
final SecuredPrefixMappingImpl checker = new SecuredPrefixMappingImpl(graph, holder);
// if we are going to create a duplicate proxy just return this one.
if (prefixMapping instanceof SecuredPrefixMapping) {
if (checker.isEquivalent((SecuredPrefixMapping) prefixMapping)) {
return (SecuredPrefixMapping) prefixMapping;
}
}
return holder.setSecuredItem(new SecuredItemInvoker(prefixMapping.getClass(), checker));
}
Aggregations