You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2015/08/07 20:56:21 UTC
[10/13] jena git commit: Added throw exception documentation
http://git-wip-us.apache.org/repos/asf/jena/blob/2c0454c6/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
index 3816dd6..3a717e7 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItemImpl.java
@@ -30,130 +30,110 @@ import org.apache.jena.permissions.SecuredItem;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.AuthenticationRequiredException;
import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.shared.ReadDeniedException;
import org.apache.jena.shared.UpdateDeniedException;
import org.apache.jena.sparql.expr.Expr;
import org.apache.jena.sparql.util.NodeUtils;
-import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.vocabulary.RDF ;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.vocabulary.RDF;
/**
* An abstract implementation of SecuredItem that caches security checks.
* <p>
- * Security checks are performed at multiple locations. This implementation ensures that
- * during a single operation the specific check is only evaluated once by caching the result.
+ * Security checks are performed at multiple locations. This implementation
+ * ensures that during a single operation the specific check is only evaluated
+ * once by caching the result.
* </p>
*
*/
-public abstract class SecuredItemImpl implements SecuredItem
-{
+public abstract class SecuredItemImpl implements SecuredItem {
// a key for the secured item.
- private class CacheKey implements Comparable<CacheKey>
- {
+ private class CacheKey implements Comparable<CacheKey> {
private final Action action;
private final Node modelNode;
private final Triple from;
private final Triple to;
private Integer hashCode;
- public CacheKey( final Action action, final Node modelNode )
- {
+ public CacheKey(final Action action, final Node modelNode) {
this(action, modelNode, null, null);
}
- public CacheKey( final Action action, final Node modelNode,
- final Triple to )
- {
+ public CacheKey(final Action action, final Node modelNode,
+ final Triple to) {
this(action, modelNode, to, null);
}
- public CacheKey( final Action action, final Node modelNode,
- final Triple to, final Triple from )
- {
+ public CacheKey(final Action action, final Node modelNode,
+ final Triple to, final Triple from) {
this.action = action;
this.modelNode = modelNode;
this.to = to;
this.from = from;
}
-
- private int compare(Node n1, Node n2)
- {
- if (Node.ANY.equals( n1 ))
- {
- if (Node.ANY.equals(n2))
- {
+
+ private int compare(Node n1, Node n2) {
+ if (Node.ANY.equals(n1)) {
+ if (Node.ANY.equals(n2)) {
return Expr.CMP_EQUAL;
}
return Expr.CMP_LESS;
}
- if (Node.ANY.equals( n2 ))
- {
+ if (Node.ANY.equals(n2)) {
return Expr.CMP_GREATER;
}
- return NodeUtils.compareRDFTerms( n1, n2 );
+ return NodeUtils.compareRDFTerms(n1, n2);
}
- private int compare(Triple t1, Triple t2)
- {
- if (t1 == null)
- {
- if (t2 == null)
- {
+ private int compare(Triple t1, Triple t2) {
+ if (t1 == null) {
+ if (t2 == null) {
return Expr.CMP_EQUAL;
}
return Expr.CMP_LESS;
}
- if (t2 == null)
- {
+ if (t2 == null) {
return Expr.CMP_GREATER;
}
int retval = compare(t1.getSubject(), t2.getSubject());
- if (retval == Expr.CMP_EQUAL)
- {
+ if (retval == Expr.CMP_EQUAL) {
retval = compare(t1.getPredicate(), t2.getPredicate());
}
- if (retval == Expr.CMP_EQUAL)
- {
+ if (retval == Expr.CMP_EQUAL) {
retval = compare(t1.getObject(), t2.getObject());
}
return retval;
}
-
+
@Override
- public int compareTo( final CacheKey other )
- {
+ public int compareTo(final CacheKey other) {
int retval = this.action.compareTo(other.action);
- if (retval == Expr.CMP_EQUAL)
- {
- retval = NodeUtils.compareRDFTerms(this.modelNode,other.modelNode);
+ if (retval == Expr.CMP_EQUAL) {
+ retval = NodeUtils.compareRDFTerms(this.modelNode,
+ other.modelNode);
}
- if (retval == Expr.CMP_EQUAL)
- {
- retval =compare(this.to, other.to);
+ if (retval == Expr.CMP_EQUAL) {
+ retval = compare(this.to, other.to);
}
- if (retval == Expr.CMP_EQUAL)
- {
+ if (retval == Expr.CMP_EQUAL) {
retval = compare(this.from, other.from);
}
return retval;
}
@Override
- public boolean equals( final Object o )
- {
- if (o instanceof CacheKey)
- {
+ public boolean equals(final Object o) {
+ if (o instanceof CacheKey) {
return this.compareTo((CacheKey) o) == 0;
}
return false;
}
@Override
- public int hashCode()
- {
- if (hashCode == null)
- {
+ public int hashCode() {
+ if (hashCode == null) {
hashCode = new HashCodeBuilder().append(action)
.append(modelNode).append(from).append(to).toHashCode();
}
@@ -164,20 +144,21 @@ public abstract class SecuredItemImpl implements SecuredItem
// the maximum size of the cache
public static int MAX_CACHE = 100;
// the cache for this thread.
- public static final ThreadLocal<LRUMap<CacheKey,Boolean>> CACHE = new ThreadLocal<LRUMap<CacheKey,Boolean>>();
+ public static final ThreadLocal<LRUMap<CacheKey, Boolean>> CACHE = new ThreadLocal<LRUMap<CacheKey, Boolean>>();
// the number of times this thread has recursively called the constructor.
public static final ThreadLocal<Integer> COUNT = new ThreadLocal<Integer>();
-
+
/**
- * May Convert a Jena Node object into the SecurityEvaluator.VARIABLE instance.
- * @param jenaNode The Jena node to convert.
+ * May Convert a Jena Node object into the SecurityEvaluator.VARIABLE
+ * instance.
+ *
+ * @param jenaNode
+ * The Jena node to convert.
* @return The Node that represents the jenaNode.
*/
- private static Node convert( final Node jenaNode )
- {
-
- if (jenaNode.isVariable())
- {
+ private static Node convert(final Node jenaNode) {
+
+ if (jenaNode.isVariable()) {
return SecurityEvaluator.VARIABLE;
}
return jenaNode;
@@ -185,17 +166,18 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* Convert a Jena Triple into a SecTriple.
- * @param jenaTriple The Jena Triple to convert.
+ *
+ * @param jenaTriple
+ * The Jena Triple to convert.
* @return The SecTriple that represents the jenaTriple.
*/
- private static Triple convert(
- final Triple jenaTriple )
- {
- if (jenaTriple.getSubject().isVariable() || jenaTriple.getPredicate().isVariable() || jenaTriple.getObject().isVariable())
- {
- return new Triple(SecuredItemImpl.convert(jenaTriple.getSubject()),
- SecuredItemImpl.convert(jenaTriple.getPredicate()),
- SecuredItemImpl.convert(jenaTriple.getObject()));
+ private static Triple convert(final Triple jenaTriple) {
+ if (jenaTriple.getSubject().isVariable()
+ || jenaTriple.getPredicate().isVariable()
+ || jenaTriple.getObject().isVariable()) {
+ return new Triple(SecuredItemImpl.convert(jenaTriple.getSubject()),
+ SecuredItemImpl.convert(jenaTriple.getPredicate()),
+ SecuredItemImpl.convert(jenaTriple.getObject()));
}
return jenaTriple;
}
@@ -203,47 +185,37 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* Decrement the number of instances of SecuredItem.
*/
- public static void decrementUse()
- {
+ public static void decrementUse() {
final Integer i = SecuredItemImpl.COUNT.get();
- if (i == null)
- {
+ if (i == null) {
throw new IllegalStateException("No count on exit");
}
- if (i < 1)
- {
+ if (i < 1) {
throw new IllegalStateException("No count less than 1");
}
- if (i == 1)
- {
+ if (i == 1) {
SecuredItemImpl.CACHE.remove();
SecuredItemImpl.COUNT.remove();
- }
- else
- {
- SecuredItemImpl.COUNT.set( i - 1 );
+ } else {
+ SecuredItemImpl.COUNT.set(i - 1);
}
}
/**
* Increment the number of instances of SecuredItem.
*/
- public static void incrementUse()
- {
+ public static void incrementUse() {
final Integer i = SecuredItemImpl.COUNT.get();
- if (i == null)
- {
- SecuredItemImpl.CACHE.set(new LRUMap<CacheKey,Boolean>(Math.max(
+ if (i == null) {
+ SecuredItemImpl.CACHE.set(new LRUMap<CacheKey, Boolean>(Math.max(
SecuredItemImpl.MAX_CACHE, 100)));
- SecuredItemImpl.COUNT.set( 1 );
- }
- else
- {
- SecuredItemImpl.COUNT.set( i + 1 );
+ SecuredItemImpl.COUNT.set(1);
+ } else {
+ SecuredItemImpl.COUNT.set(i + 1);
}
}
- // the evaluator we are using
+ // the evaluator we are using
private final SecurityEvaluator securityEvaluator;
// the secured node for that names the graph.
@@ -254,55 +226,56 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* Create the SecuredItemImpl.
- * @param securedItem The securedItem.
- * @param holder The Item holder for the securedItem.
- * @throws IllegalArgumentException if securedItem is null or securedItem.getSecurityEvaluator()
- * returns null, or the holder is null.
+ *
+ * @param securedItem
+ * The securedItem.
+ * @param holder
+ * The Item holder for the securedItem.
+ * @throws IllegalArgumentException
+ * if securedItem is null or securedItem.getSecurityEvaluator()
+ * returns null, or the holder is null.
*/
- protected SecuredItemImpl( final SecuredItem securedItem,
- final ItemHolder<?, ?> holder )
- {
- if (securedItem == null)
- {
+ protected SecuredItemImpl(final SecuredItem securedItem,
+ final ItemHolder<?, ?> holder) {
+ if (securedItem == null) {
throw new IllegalArgumentException("Secured item may not be null");
}
- if (securedItem.getSecurityEvaluator() == null)
- {
+ if (securedItem.getSecurityEvaluator() == null) {
throw new IllegalArgumentException(
"Security evaluator in secured item may not be null");
}
- if (holder == null)
- {
+ if (holder == null) {
throw new IllegalArgumentException("ItemHolder may not be null");
}
this.securityEvaluator = securedItem.getSecurityEvaluator();
- this.modelNode = securedItem.getModelNode();
+ this.modelNode = securedItem.getModelNode();
this.itemHolder = holder;
}
/**
* Create the SecuredItemImpl.
- * @param securityEvaluator the secured evaluator to use.
- * @param modelURI the URI for the model.
- * @param holder The holder to use.
- * @throws IllegalArgumentException if security evaluator is null, modelURI is null or empty,
- * or holder is null.
+ *
+ * @param securityEvaluator
+ * the secured evaluator to use.
+ * @param modelURI
+ * the URI for the model.
+ * @param holder
+ * The holder to use.
+ * @throws IllegalArgumentException
+ * if security evaluator is null, modelURI is null or empty, or
+ * holder is null.
*/
- protected SecuredItemImpl( final SecurityEvaluator securityEvaluator,
- final String modelURI, final ItemHolder<?, ?> holder )
- {
- if (securityEvaluator == null)
- {
+ protected SecuredItemImpl(final SecurityEvaluator securityEvaluator,
+ final String modelURI, final ItemHolder<?, ?> holder) {
+ if (securityEvaluator == null) {
throw new IllegalArgumentException(
"Security evaluator may not be null");
}
- if (StringUtils.isEmpty(modelURI))
- {
+ if (StringUtils.isEmpty(modelURI)) {
throw new IllegalArgumentException(
"ModelURI may not be empty or null");
}
- if (holder == null)
- {
+ if (holder == null) {
throw new IllegalArgumentException("ItemHolder may not be null");
}
this.securityEvaluator = securityEvaluator;
@@ -311,191 +284,171 @@ public abstract class SecuredItemImpl implements SecuredItem
}
@Override
- public String toString() {
- if (canRead())
- {
+ public String toString() throws AuthenticationRequiredException {
+ if (canRead()) {
return itemHolder.getBaseItem().toString();
}
return super.toString();
}
-
+
/**
* get the cached value.
- * @param key The key to look for.
- * @return the value of the security check or <code>null</code> if the value has not been cached.
+ *
+ * @param key
+ * The key to look for.
+ * @return the value of the security check or <code>null</code> if the value
+ * has not been cached.
*/
- private Boolean cacheGet( final CacheKey key )
- {
- final LRUMap<CacheKey,Boolean> cache = SecuredItemImpl.CACHE.get();
+ private Boolean cacheGet(final CacheKey key) {
+ final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get();
return (cache == null) ? null : (Boolean) cache.get(key);
}
/**
* set the cache value.
- * @param key The key to set the value for.
- * @param value The value to set.
+ *
+ * @param key
+ * The key to set the value for.
+ * @param value
+ * The value to set.
*/
- private void cachePut( final CacheKey key, final boolean value )
- {
- final LRUMap<CacheKey,Boolean> cache = SecuredItemImpl.CACHE.get();
- if (cache != null)
- {
+ private void cachePut(final CacheKey key, final boolean value) {
+ final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get();
+ if (cache != null) {
cache.put(key, value);
SecuredItemImpl.CACHE.set(cache);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#canCreate()
- */
@Override
- public boolean canCreate()
- {
+ public boolean canCreate() throws AuthenticationRequiredException {
final CacheKey key = new CacheKey(Action.Create, modelNode);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Create, modelNode);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Create, modelNode);
cachePut(key, retval);
}
return retval;
}
-
@Override
- public boolean canCreate( final Triple triple )
- {
+ public boolean canCreate(final Triple triple)
+ throws AuthenticationRequiredException {
Triple t = convert(triple);
final CacheKey key = new CacheKey(Action.Create, modelNode, t);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Create, modelNode, t);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Create, modelNode,
+ t);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canCreate( final FrontsTriple frontsTriple )
- {
+ public boolean canCreate(final FrontsTriple frontsTriple)
+ throws AuthenticationRequiredException {
return canCreate(frontsTriple.asTriple());
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#canDelete()
- */
@Override
- public boolean canDelete()
- {
+ public boolean canDelete() throws AuthenticationRequiredException {
final CacheKey key = new CacheKey(Action.Delete, modelNode);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Delete, modelNode);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Delete, modelNode);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canDelete( final Triple triple )
- {
+ public boolean canDelete(final Triple triple)
+ throws AuthenticationRequiredException {
Triple t = convert(triple);
final CacheKey key = new CacheKey(Action.Delete, modelNode, t);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Delete, modelNode, t);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Delete, modelNode,
+ t);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canDelete( final FrontsTriple frontsTriple )
- {
+ public boolean canDelete(final FrontsTriple frontsTriple)
+ throws AuthenticationRequiredException {
return canDelete(frontsTriple.asTriple());
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#canRead()
- */
@Override
- public boolean canRead()
- {
+ public boolean canRead() throws AuthenticationRequiredException {
final CacheKey key = new CacheKey(Action.Read, modelNode);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Read, modelNode);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Read, modelNode);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canRead( final Triple triple )
- {
+ public boolean canRead(final Triple triple)
+ throws AuthenticationRequiredException {
Triple t = convert(triple);
final CacheKey key = new CacheKey(Action.Read, modelNode, t);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Read, modelNode, t);
+ if (retval == null) {
+ retval = securityEvaluator
+ .evaluate(securityEvaluator.getPrincipal(), Action.Read,
+ modelNode, t);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canRead( final FrontsTriple frontsTriple )
- {
+ public boolean canRead(final FrontsTriple frontsTriple)
+ throws AuthenticationRequiredException {
return canRead(frontsTriple.asTriple());
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#canUpdate()
- */
@Override
- public boolean canUpdate()
- {
+ public boolean canUpdate() throws AuthenticationRequiredException {
final CacheKey key = new CacheKey(Action.Update, modelNode);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluate(securityEvaluator.getPrincipal(),Action.Update, modelNode);
+ if (retval == null) {
+ retval = securityEvaluator.evaluate(
+ securityEvaluator.getPrincipal(), Action.Update, modelNode);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canUpdate( final Triple f, final Triple t )
- {
+ public boolean canUpdate(final Triple f, final Triple t)
+ throws AuthenticationRequiredException {
Triple from = convert(f);
Triple to = convert(t);
final CacheKey key = new CacheKey(Action.Update, modelNode, from, to);
Boolean retval = cacheGet(key);
- if (retval == null)
- {
- retval = securityEvaluator.evaluateUpdate(securityEvaluator.getPrincipal(),modelNode, from, to);
+ if (retval == null) {
+ retval = securityEvaluator.evaluateUpdate(
+ securityEvaluator.getPrincipal(), modelNode, from, to);
cachePut(key, retval);
}
return retval;
}
@Override
- public boolean canUpdate( final FrontsTriple from, final FrontsTriple to )
- {
+ public boolean canUpdate(final FrontsTriple from, final FrontsTriple to)
+ throws AuthenticationRequiredException {
return canUpdate(from.asTriple(), to.asTriple());
}
@@ -504,12 +457,14 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @throws AddDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkCreate() throws AddDeniedException
- {
- if (!canCreate())
- {
- throw new AddDeniedException( SecuredItem.Util.modelPermissionMsg(modelNode));
+ protected void checkCreate() throws AddDeniedException,
+ AuthenticationRequiredException {
+ if (!canCreate()) {
+ throw new AddDeniedException(
+ SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
@@ -518,74 +473,100 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @throws AddDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkCreate( final Triple t ) throws AddDeniedException
- {
- if (!canCreate(t))
- {
- throw new AddDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t );
+ protected void checkCreate(final Triple t) throws AddDeniedException,
+ AuthenticationRequiredException {
+ if (!canCreate(t)) {
+ throw new AddDeniedException(
+ SecuredItem.Util.triplePermissionMsg(modelNode), t);
}
}
/**
* check that the statement can be created.
- * @param s The statement.
- * @throws AddDeniedException on failure
+ *
+ * @param s
+ * The statement.
+ * @throws AddDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkCreate( final FrontsTriple frontsTriple ) throws AddDeniedException
- {
+ protected void checkCreate(final FrontsTriple frontsTriple)
+ throws AddDeniedException, AuthenticationRequiredException {
checkCreate(frontsTriple.asTriple());
}
/**
* Check that a triple can be reified.
- * @param uri The URI for the reification subject. May be null.
- * @param front the frontstriple that is to be reified.
- * @throws AddDeniedException on failure to add triple
- * @throws UpdateDenied if the updates of the graph are not allowed.
+ *
+ * @param uri
+ * The URI for the reification subject. May be null.
+ * @param front
+ * the frontstriple that is to be reified.
+ * @throws AddDeniedException
+ * on failure to add triple
+ * @throws UpdateDeniedException
+ * if the updates of the graph are not allowed.
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkCreateReified( final String uri, final FrontsTriple front ) throws AddDeniedException, UpdateDeniedException
- {
+ protected void checkCreateReified(final String uri, final FrontsTriple front)
+ throws AddDeniedException, UpdateDeniedException,
+ AuthenticationRequiredException {
checkUpdate();
Triple t = front.asTriple();
- final Node n = uri == null ? SecurityEvaluator.FUTURE : NodeFactory.createURI(uri);
+ final Node n = uri == null ? SecurityEvaluator.FUTURE : NodeFactory
+ .createURI(uri);
checkCreate(new Triple(n, RDF.subject.asNode(), t.getSubject()));
checkCreate(new Triple(n, RDF.predicate.asNode(), t.getPredicate()));
checkCreate(new Triple(n, RDF.object.asNode(), t.getObject()));
}
- protected void checkCreateFrontsTriples( final ExtendedIterator<? extends FrontsTriple> stmts ) throws AddDeniedException
- {
- if (!canCreate(Triple.ANY))
- {
- try
- {
- while (stmts.hasNext())
- {
- checkCreate(stmts.next());
+ /**
+ * Check that all the triples can be created.
+ *
+ * @param FrontsTripleIter
+ * an iterator of FrontsTriple objects.
+ * @throws AddDeniedException
+ * if a triple can not be added.
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkCreateFrontsTriples(
+ final ExtendedIterator<? extends FrontsTriple> FrontsTripleIter)
+ throws AddDeniedException, AuthenticationRequiredException {
+ if (!canCreate(Triple.ANY)) {
+ try {
+ while (FrontsTripleIter.hasNext()) {
+ checkCreate(FrontsTripleIter.next());
}
- }
- finally
- {
- stmts.close();
+ } finally {
+ FrontsTripleIter.close();
}
}
}
- protected void checkCreateTriples(
- final ExtendedIterator<Triple> triples ) throws AddDeniedException
- {
- if (!canCreate(Triple.ANY))
- {
- try
- {
- while (triples.hasNext())
- {
+ /**
+ * Check that all the triples can be created.
+ *
+ * @param triples
+ * an iterator of triples.
+ * @throws AddDeniedException
+ * if a triple can not be added.
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkCreateTriples(final ExtendedIterator<Triple> triples)
+ throws AddDeniedException, AuthenticationRequiredException {
+ if (!canCreate(Triple.ANY)) {
+ try {
+ while (triples.hasNext()) {
checkCreate(triples.next());
}
- }
- finally
- {
+ } finally {
triples.close();
}
}
@@ -596,67 +577,92 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @throws DeleteDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkDelete() throws DeleteDeniedException
- {
- if (!canDelete())
- {
- throw new DeleteDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
+ protected void checkDelete() throws DeleteDeniedException,
+ AuthenticationRequiredException {
+ if (!canDelete()) {
+ throw new DeleteDeniedException(
+ SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
/**
* check that the triple can be deleted in the securedModel.,
*
+ * @param triple
+ * The triple to check.
* @throws DeleteDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkDelete( final Triple t )
- {
- if (!canDelete(t))
- {
- throw new DeleteDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t);
+ protected void checkDelete(final Triple triple)
+ throws DeleteDeniedException, AuthenticationRequiredException {
+ if (!canDelete(triple)) {
+ throw new DeleteDeniedException(
+ SecuredItem.Util.triplePermissionMsg(modelNode), triple);
}
}
- protected void checkDelete( final FrontsTriple frontsTriple )
- {
+ /**
+ * check that the triple can be deleted in the securedModel.,
+ *
+ * @param frontsTriple
+ * An object fronting the triple to check.
+ * @throws DeleteDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkDelete(final FrontsTriple frontsTriple)
+ throws DeleteDeniedException, AuthenticationRequiredException {
checkDelete(frontsTriple.asTriple());
}
+ /**
+ * check that the triples can be deleted in the securedModel.,
+ *
+ * @param frontsTripleIter
+ * An iterator of objects fronting triples to check.
+ * @throws DeleteDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
protected void checkDeleteFrontsTriples(
- final ExtendedIterator<? extends FrontsTriple> stmts )
- {
- if (!canDelete(Triple.ANY))
- {
- try
- {
- while (stmts.hasNext())
- {
- checkDelete(stmts.next());
+ final ExtendedIterator<? extends FrontsTriple> frontsTriplesIter)
+ throws DeleteDeniedException, AuthenticationRequiredException {
+ if (!canDelete(Triple.ANY)) {
+ try {
+ while (frontsTriplesIter.hasNext()) {
+ checkDelete(frontsTriplesIter.next());
}
- }
- finally
- {
- stmts.close();
+ } finally {
+ frontsTriplesIter.close();
}
}
}
- protected void checkDeleteTriples(
- final ExtendedIterator<Triple> triples )
- {
- if (!canDelete(Triple.ANY))
- {
- try
- {
- while (triples.hasNext())
- {
+ /**
+ * check that the triples can be deleted in the securedModel.,
+ *
+ * @param triples
+ * An iterator of triples to check.
+ * @throws DeleteDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkDeleteTriples(final ExtendedIterator<Triple> triples)
+ throws DeleteDeniedException, AuthenticationRequiredException {
+ if (!canDelete(Triple.ANY)) {
+ try {
+ while (triples.hasNext()) {
checkDelete(triples.next());
}
- }
- finally
- {
+ } finally {
triples.close();
}
}
@@ -667,61 +673,89 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @throws ReadDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkRead() throws ReadDeniedException
- {
- if (!canRead())
- {
- throw new ReadDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
+ protected void checkRead() throws ReadDeniedException,
+ AuthenticationRequiredException {
+ if (!canRead()) {
+ throw new ReadDeniedException(
+ SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
/**
* check that the triple can be read in the securedModel.,
*
+ * @param triple
+ * The triple to check.
* @throws ReadDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkRead( final Triple t ) throws ReadDeniedException
- {
- if (!canRead(t))
- {
- throw new ReadDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t);
+ protected void checkRead(final Triple triple) throws ReadDeniedException,
+ AuthenticationRequiredException {
+ if (!canRead(triple)) {
+ throw new ReadDeniedException(
+ SecuredItem.Util.triplePermissionMsg(modelNode), triple);
}
}
- protected void checkRead( final FrontsTriple frontsTriple ) throws ReadDeniedException
- {
+ /**
+ * check that the triple can be read in the securedModel.,
+ *
+ * @param frontsTriple
+ * The object fronting the triple to check.
+ * @throws ReadDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkRead(final FrontsTriple frontsTriple)
+ throws ReadDeniedException, AuthenticationRequiredException {
checkRead(frontsTriple.asTriple());
}
- protected void checkReadFrontsTriples( final ExtendedIterator<FrontsTriple> stmts ) throws ReadDeniedException
- {
- try
- {
- while (stmts.hasNext())
- {
- checkRead(stmts.next());
+ /**
+ * check that the triple can be read in the securedModel.,
+ *
+ * @param frontsTripleIter
+ * The iterator of fronts triple objects to check.
+ * @throws ReadDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkReadFrontsTriples(
+ final ExtendedIterator<FrontsTriple> frontsTripleIter)
+ throws ReadDeniedException, AuthenticationRequiredException {
+ try {
+ while (frontsTripleIter.hasNext()) {
+ checkRead(frontsTripleIter.next());
}
- }
- finally
- {
- stmts.close();
+ } finally {
+ frontsTripleIter.close();
}
}
- protected void checkReadTriples(
- final ExtendedIterator<Triple> triples ) throws ReadDeniedException
- {
- try
- {
- while (triples.hasNext())
- {
+ /**
+ * check that the triple can be read in the securedModel.,
+ *
+ * @param triples
+ * The iterator of triples to check.
+ * @throws ReadDeniedException
+ * on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
+ */
+ protected void checkReadTriples(final ExtendedIterator<Triple> triples)
+ throws ReadDeniedException, AuthenticationRequiredException {
+ try {
+ while (triples.hasNext()) {
checkRead(triples.next());
}
- }
- finally
- {
+ } finally {
triples.close();
}
}
@@ -731,78 +765,62 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @throws UpdateDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkUpdate() throws UpdateDeniedException
- {
- if (!canUpdate())
- {
- throw new UpdateDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
+ protected void checkUpdate() throws UpdateDeniedException,
+ AuthenticationRequiredException {
+ if (!canUpdate()) {
+ throw new UpdateDeniedException(
+ SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
/**
* check that the triple can be updated in the securedModel.,
*
- * @param from the starting triple
- * @param to the final triple.
+ * @param from
+ * the starting triple
+ * @param to
+ * the final triple.
* @throws UpdateDeniedException
* on failure
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- protected void checkUpdate( final Triple from, final Triple to ) throws UpdateDeniedException
- {
- if (!canUpdate(from, to))
- {
- throw new UpdateDeniedException( String.format(
- "%s: %s to %s", SecuredItem.Util.modelPermissionMsg(modelNode), from, to));
+ protected void checkUpdate(final Triple from, final Triple to)
+ throws UpdateDeniedException, AuthenticationRequiredException {
+ if (!canUpdate(from, to)) {
+ throw new UpdateDeniedException(String.format("%s: %s to %s",
+ SecuredItem.Util.modelPermissionMsg(modelNode), from, to));
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#equals(java.lang.Object)
- */
@Override
- public boolean equals( final Object o )
- {
- if (Proxy.isProxyClass(o.getClass()))
- {
+ public boolean equals(final Object o) {
+ if (Proxy.isProxyClass(o.getClass())) {
return o.equals(itemHolder.getSecuredItem());
- }
- else
- {
- if (o instanceof SecuredItemImpl)
- {
- return itemHolder.getBaseItem().equals( ((SecuredItemImpl)o).getBaseItem());
+ } else {
+ if (o instanceof SecuredItemImpl) {
+ return itemHolder.getBaseItem().equals(
+ ((SecuredItemImpl) o).getBaseItem());
}
return false;
}
}
@Override
- public int hashCode()
- {
+ public int hashCode() {
return itemHolder.getBaseItem().hashCode();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#getBaseItem()
- */
+
@Override
- public Object getBaseItem()
- {
+ public Object getBaseItem() {
return itemHolder.getBaseItem();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#getModelIRI()
- */
@Override
- public String getModelIRI()
- {
+ public String getModelIRI() {
return modelNode.getURI();
}
@@ -810,30 +828,17 @@ public abstract class SecuredItemImpl implements SecuredItem
* get the name of the model.
*/
@Override
- public Node getModelNode()
- {
+ public Node getModelNode() {
return modelNode;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.SecuredItem#getSecurityEvaluator()
- */
@Override
- public SecurityEvaluator getSecurityEvaluator()
- {
+ public SecurityEvaluator getSecurityEvaluator() {
return securityEvaluator;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jena.security.isEquivalent()
- */
@Override
- public boolean isEquivalent( final SecuredItem securedItem )
- {
+ public boolean isEquivalent(final SecuredItem securedItem) {
return SecuredItem.Util.isEquivalent(this, securedItem);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/2c0454c6/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredAlt.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredAlt.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredAlt.java
index fb640e8..2ee8281 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredAlt.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredAlt.java
@@ -17,10 +17,11 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.rdf.model.Alt ;
-import org.apache.jena.rdf.model.RDFNode ;
-import org.apache.jena.rdf.model.ResourceF ;
+import org.apache.jena.rdf.model.Alt;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.ResourceF;
import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.AuthenticationRequiredException;
import org.apache.jena.shared.ReadDeniedException;
import org.apache.jena.shared.UpdateDeniedException;
@@ -30,246 +31,320 @@ import org.apache.jena.shared.UpdateDeniedException;
* Use the SecuredAlt.Factory to create instances
*/
@SuppressWarnings("deprecation")
-public interface SecuredAlt extends Alt, SecuredContainer
-{
+public interface SecuredAlt extends Alt, SecuredContainer {
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredRDFNode getDefault() throws ReadDeniedException;
+ public SecuredRDFNode getDefault() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt getDefaultAlt() throws ReadDeniedException;
+ public SecuredAlt getDefaultAlt() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredBag getDefaultBag() throws ReadDeniedException;
+ public SecuredBag getDefaultBag() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean getDefaultBoolean() throws ReadDeniedException;
+ public boolean getDefaultBoolean() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public byte getDefaultByte() throws ReadDeniedException;
+ public byte getDefaultByte() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public char getDefaultChar() throws ReadDeniedException;
+ public char getDefaultChar() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public double getDefaultDouble() throws ReadDeniedException;
+ public double getDefaultDouble() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public float getDefaultFloat() throws ReadDeniedException;
+ public float getDefaultFloat() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public int getDefaultInt() throws ReadDeniedException;
+ public int getDefaultInt() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public String getDefaultLanguage() throws ReadDeniedException;
+ public String getDefaultLanguage() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredLiteral getDefaultLiteral() throws ReadDeniedException;
+ public SecuredLiteral getDefaultLiteral() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public long getDefaultLong() throws ReadDeniedException;
+ public long getDefaultLong() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredResource getDefaultResource() throws ReadDeniedException;
+ public SecuredResource getDefaultResource() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
@Deprecated
- public SecuredResource getDefaultResource( final ResourceF f )
- throws ReadDeniedException;
+ public SecuredResource getDefaultResource(final ResourceF f)
+ throws ReadDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredSeq getDefaultSeq() throws ReadDeniedException;
+ public SecuredSeq getDefaultSeq() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public short getDefaultShort() throws ReadDeniedException;
+ public short getDefaultShort() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public String getDefaultString() throws ReadDeniedException;
+ public String getDefaultString() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final boolean o )
- throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final boolean o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final char o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final char o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final double o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final double o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final float o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final float o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final long o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final long o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final Object o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final Object o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final RDFNode o )
- throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final RDFNode o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final String o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final String o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
- * RDF.li(1), o )
+ * RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredAlt setDefault( final String o, final String l )
- throws UpdateDeniedException, AddDeniedException;
+ public SecuredAlt setDefault(final String o, final String l)
+ throws UpdateDeniedException, AddDeniedException,
+ AuthenticationRequiredException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/2c0454c6/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredContainer.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredContainer.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredContainer.java
index b8a624e..b2ddae8 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredContainer.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredContainer.java
@@ -21,10 +21,11 @@ import java.util.Set;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.impl.SecuredNodeIterator;
-import org.apache.jena.rdf.model.Container ;
-import org.apache.jena.rdf.model.RDFNode ;
-import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.rdf.model.Container;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Statement;
import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.AuthenticationRequiredException;
import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.shared.ReadDeniedException;
import org.apache.jena.shared.UpdateDeniedException;
@@ -35,197 +36,261 @@ import org.apache.jena.shared.UpdateDeniedException;
* Use one of the SecuredContainer derived class Factory methods to create
* instances
*/
-public interface SecuredContainer extends Container, SecuredResource
-{
+public interface SecuredContainer extends Container, SecuredResource {
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final boolean o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final boolean o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final char o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final char o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final double o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final double o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final float o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final float o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final long o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final long o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final Object o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final Object o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final RDFNode o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final RDFNode o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final String o ) throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final String o) throws UpdateDeniedException,
+ AddDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
* @throws UpdateDeniedException
* @throws AddDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer add( final String o, final String l )
- throws UpdateDeniedException, AddDeniedException;
+ public SecuredContainer add(final String o, final String l)
+ throws UpdateDeniedException, AddDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final boolean o ) throws ReadDeniedException;
+ public boolean contains(final boolean o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final char o ) throws ReadDeniedException;
+ public boolean contains(final char o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final double o ) throws ReadDeniedException;
+ public boolean contains(final double o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final float o ) throws ReadDeniedException;
+ public boolean contains(final float o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final long o ) throws ReadDeniedException;
+ public boolean contains(final long o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final Object o ) throws ReadDeniedException;
+ public boolean contains(final Object o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final RDFNode o ) throws ReadDeniedException;
+ public boolean contains(final RDFNode o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final String o ) throws ReadDeniedException;
+ public boolean contains(final String o) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean contains( final String o, final String l )
- throws ReadDeniedException;
+ public boolean contains(final String o, final String l)
+ throws ReadDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @sec.triple Read on each triple ( this, rdf:li_? node ) returned by
- * iterator;
+ * iterator;
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredNodeIterator<RDFNode> iterator() throws ReadDeniedException;
+ public SecuredNodeIterator<RDFNode> iterator() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
- * @param perms the Permissions required on each node returned
+ * @param perms
+ * the Permissions required on each node returned
* @sec.graph Read
* @sec.triple Read + perms on each triple ( this, rdf:li_? node ) returned
- * by iterator;
+ * by iterator;
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
- public SecuredNodeIterator<RDFNode> iterator( Set<Action> perms )
- throws ReadDeniedException;
+ public SecuredNodeIterator<RDFNode> iterator(Set<Action> perms)
+ throws ReadDeniedException, AuthenticationRequiredException;
/**
* @sec.graph Update
* @sec.triple Delete s as triple;
* @throws UpdateDeniedException
* @throws DeleteDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public SecuredContainer remove( final Statement s )
- throws UpdateDeniedException, DeleteDeniedException;
+ public SecuredContainer remove(final Statement s)
+ throws UpdateDeniedException, DeleteDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public int size() throws ReadDeniedException;
+ public int size() throws ReadDeniedException,
+ AuthenticationRequiredException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/2c0454c6/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredLiteral.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredLiteral.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredLiteral.java
index 05194a6..10d0215 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredLiteral.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredLiteral.java
@@ -17,10 +17,11 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.datatypes.DatatypeFormatException ;
-import org.apache.jena.datatypes.RDFDatatype ;
-import org.apache.jena.rdf.model.Literal ;
-import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.datatypes.DatatypeFormatException;
+import org.apache.jena.datatypes.RDFDatatype;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.shared.AuthenticationRequiredException;
import org.apache.jena.shared.ReadDeniedException;
/**
@@ -28,8 +29,7 @@ import org.apache.jena.shared.ReadDeniedException;
*
* Use the SecuredLiteral.Factory to create instances
*/
-public interface SecuredLiteral extends Literal, SecuredRDFNode
-{
+public interface SecuredLiteral extends Literal, SecuredRDFNode {
@Override
public SecuredLiteral asLiteral();
@@ -38,135 +38,180 @@ public interface SecuredLiteral extends Literal, SecuredRDFNode
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
public boolean getBoolean() throws ReadDeniedException,
- DatatypeFormatException;
+ DatatypeFormatException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public byte getByte() throws ReadDeniedException, DatatypeFormatException;
+ public byte getByte() throws ReadDeniedException, DatatypeFormatException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public char getChar() throws ReadDeniedException, DatatypeFormatException;
+ public char getChar() throws ReadDeniedException, DatatypeFormatException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public RDFDatatype getDatatype() throws ReadDeniedException;
+ public RDFDatatype getDatatype() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public String getDatatypeURI() throws ReadDeniedException;
+ public String getDatatypeURI() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
public double getDouble() throws ReadDeniedException,
- DatatypeFormatException;
+ DatatypeFormatException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
public float getFloat() throws ReadDeniedException,
- DatatypeFormatException;
+ DatatypeFormatException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
* @throws DatatypeFormatException
*/
@Override
- public int getInt() throws ReadDeniedException, DatatypeFormatException;
+ public int getInt() throws ReadDeniedException, DatatypeFormatException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public String getLanguage() throws ReadDeniedException;
+ public String getLanguage() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public String getLexicalForm() throws ReadDeniedException;
+ public String getLexicalForm() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public long getLong() throws ReadDeniedException, DatatypeFormatException;
+ public long getLong() throws ReadDeniedException, DatatypeFormatException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
public short getShort() throws ReadDeniedException,
- DatatypeFormatException;
+ DatatypeFormatException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
* @throws DatatypeFormatException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
public String getString() throws ReadDeniedException,
- DatatypeFormatException;
+ DatatypeFormatException, AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public Object getValue() throws ReadDeniedException;
+ public Object getValue() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public Literal inModel( final Model m ) throws ReadDeniedException;
+ public Literal inModel(final Model m) throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean isWellFormedXML() throws ReadDeniedException;
+ public boolean isWellFormedXML() throws ReadDeniedException,
+ AuthenticationRequiredException;
/**
* @sec.graph Read
* @throws ReadDeniedException
+ * @throws AuthenticationRequiredException
+ * if user is not authenticated and is required to be.
*/
@Override
- public boolean sameValueAs( final Literal other )
- throws ReadDeniedException;
+ public boolean sameValueAs(final Literal other) throws ReadDeniedException,
+ AuthenticationRequiredException;
}