You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by mi...@apache.org on 2010/10/12 10:34:44 UTC

svn commit: r1021671 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access: SecuredMGraph.java SecuredTripleCollection.java

Author: mir
Date: Tue Oct 12 08:34:44 2010
New Revision: 1021671

URL: http://svn.apache.org/viewvc?rev=1021671&view=rev
Log:
CLEREZZA-316: now returns a read-only-mgraph if write right cannot be granted

Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java?rev=1021671&r1=1021670&r2=1021671&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java Tue Oct 12 08:34:44 2010
@@ -18,11 +18,13 @@
  */
 package org.apache.clerezza.rdf.core.access;
 
+import java.security.AccessControlException;
 import java.util.concurrent.locks.ReadWriteLock;
 import org.apache.clerezza.rdf.core.Graph;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.security.TcAccessController;
 import org.apache.clerezza.rdf.core.impl.SimpleGraph;
+import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
 
 /**
  * A SecuredMGraph is a LockableMGraph that wraps a LockableMGraph checking each
@@ -52,14 +54,23 @@ public class SecuredMGraph extends Secur
 	}
 
 	/**
-	 * Returns the wrapped LockableMGraph if the caller has all access rights,
-	 * otherwise an AccessControlException is thrown.
+	 * Returns the wrapped LockableMGraph if the caller has all access rights.
+	 * If the caller has only the read access right, then a write-blocked
+	 * LockableMGraph is returned. If the caller has neither the read nor the write
+	 * access right then an AccessControlException is thrown.
 	 *
-	 * @return the wrapped LockableMGraph.
+	 * @return the wrapped LockableMGraph or a write-block LockableMGraph depending
+	 *		on the access rights of the caller.
 	 */
 	public LockableMGraph getUnsecuredMGraph() {
-		checkWrite();
-		return wrapped;
+		try {
+			checkWrite();
+			return wrapped;
+		} catch (AccessControlException ex) {
+			checkRead();
+			return new WriteBlockedMGraph(wrapped);
+		}
+		
 	}
 
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java?rev=1021671&r1=1021670&r2=1021671&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java Tue Oct 12 08:34:44 2010
@@ -162,7 +162,7 @@ public class SecuredTripleCollection imp
 		}
 	}
 
-	private void checkRead() {
+	void checkRead() {
 		tcAccessController.checkReadPermission(name);
 	}