use of org.apache.jena.permissions.model.SecuredStatement in project jena by apache.
the class SecuredResourceImpl method getRequiredProperty.
/**
* Get a property value of this resource.
*
* <p>
* The securedModel associated with the resource instance is searched for
* statements whose subject is this resource and whose predicate is p. If
* such a statement is found, it is returned. If several such statements are
* found, any one may be returned. If no such statements are found, an
* exception is thrown.
* </p>
*
* @param p
* The property sought.
* @return some (this, p, ?O) statement if one exists
* @throws PropertyNotFoundException
* if no such statement found
* @throws ReadDeniedException
* @throws AuthenticationRequiredException
*/
@Override
public SecuredStatement getRequiredProperty(final Property p) throws PropertyNotFoundException, ReadDeniedException, AuthenticationRequiredException {
checkRead();
final ExtendedIterator<Statement> iter = holder.getBaseItem().listProperties(p).filterKeep(new PermStatementFilter(Action.Read, this));
try {
if (iter.hasNext()) {
return org.apache.jena.permissions.model.impl.SecuredStatementImpl.getInstance(getModel(), iter.next());
} else {
throw new PropertyNotFoundException(p);
}
} finally {
iter.close();
}
}
use of org.apache.jena.permissions.model.SecuredStatement in project jena by apache.
the class SecuredResourceImpl method getProperty.
/**
* Answer some statement (this, p, O) in the associated securedModel. If
* there are several such statements, any one of them may be returned. If no
* such statements exist, null is returned - in this is differs from
* getRequiredProperty.
*
* @param p
* the property sought
* @return a statement (this, p, O), or null if no such statements exist
* here
* @throws ReadDeniedException
* @throws AuthenticationRequiredException
*/
@Override
public SecuredStatement getProperty(final Property p) throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
final ExtendedIterator<Statement> iter = holder.getBaseItem().listProperties(p).filterKeep(new PermStatementFilter(Action.Read, this));
try {
if (iter.hasNext()) {
return org.apache.jena.permissions.model.impl.SecuredStatementImpl.getInstance(getModel(), iter.next());
} else {
return null;
}
} finally {
iter.close();
}
}
use of org.apache.jena.permissions.model.SecuredStatement in project jena by apache.
the class SecuredResourceImpl method getProperty.
@Override
public SecuredStatement getProperty(Property p, String lang) throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
final ExtendedIterator<Statement> iter = holder.getBaseItem().listProperties(p, lang).filterKeep(new PermStatementFilter(Action.Read, this));
try {
if (iter.hasNext()) {
return org.apache.jena.permissions.model.impl.SecuredStatementImpl.getInstance(getModel(), iter.next());
} else {
return null;
}
} finally {
iter.close();
}
}
use of org.apache.jena.permissions.model.SecuredStatement in project jena by apache.
the class SecuredResourceImpl method getRequiredProperty.
@Override
public SecuredStatement getRequiredProperty(Property p, String lang) throws PropertyNotFoundException, ReadDeniedException, AuthenticationRequiredException {
checkRead();
final ExtendedIterator<Statement> iter = holder.getBaseItem().listProperties(p, lang).filterKeep(new PermStatementFilter(Action.Read, this));
try {
if (iter.hasNext()) {
return org.apache.jena.permissions.model.impl.SecuredStatementImpl.getInstance(getModel(), iter.next());
} else {
throw new PropertyNotFoundException(p);
}
} finally {
iter.close();
}
}
use of org.apache.jena.permissions.model.SecuredStatement in project jena by apache.
the class SecuredStatementImpl method getInstance.
/**
* get a SecuredStatement
*
* @param securedModel The secured model that provides the security context
* @param stmt The statement to secure.
* @return the SecuredStatement
*/
public static SecuredStatement getInstance(final SecuredModel securedModel, final Statement stmt) {
if (securedModel == null) {
throw new IllegalArgumentException("Secured securedModel may not be null");
}
if (stmt == null) {
throw new IllegalArgumentException("Statement may not be null");
}
final ItemHolder<Statement, SecuredStatement> holder = new ItemHolder<>(stmt);
final SecuredStatementImpl checker = new SecuredStatementImpl(securedModel, holder);
// one.
if (stmt instanceof SecuredStatement) {
if (checker.isEquivalent((SecuredStatement) stmt)) {
return (SecuredStatement) stmt;
}
}
return holder.setSecuredItem(new SecuredItemInvoker(holder.getBaseItem().getClass(), checker));
}
Aggregations