You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/07/17 14:04:33 UTC

svn commit: r965059 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core: ./ src/main/java/org/apache/clerezza/rdf/core/access/ src/main/java/org/apache/clerezza/rdf/core/access/security/ src/test/java/org/apache/clere...

Author: reto
Date: Sat Jul 17 12:04:33 2010
New Revision: 965059

URL: http://svn.apache.org/viewvc?rev=965059&view=rev
Log:
CLEREZZA-253: merged into trunk

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
      - copied unchanged from r964941, incubator/clerezza/issues/CLEREZZA-253/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/   (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java
    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
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jul 17 12:04:33 2010
@@ -1,4 +1,5 @@
 /incubator/clerezza/issues/CLEREZZA-15/org.apache.clerezza.rdf.core:890278-890753
+/incubator/clerezza/issues/CLEREZZA-253/org.apache.clerezza.rdf.core:960983-964941
 /incubator/clerezza/issues/CLEREZZA-33/org.apache.clerezza.rdf.core:890770-890809
 /incubator/clerezza/issues/CLEREZZA-35/org.apache.clerezza.rdf.core:890756-891714
 /incubator/clerezza/issues/CLEREZZA-67/org.apache.clerezza.rdf.core:897463-901252

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml?rev=965059&r1=965058&r2=965059&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml Sat Jul 17 12:04:33 2010
@@ -25,6 +25,10 @@
 			<artifactId>org.apache.felix.scr.annotations</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.utils</artifactId>
+		</dependency>
+		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<scope>test</scope>

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.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/GraphServiceFactory.java?rev=965059&r1=965058&r2=965059&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/GraphServiceFactory.java Sat Jul 17 12:04:33 2010
@@ -23,6 +23,7 @@ import org.osgi.framework.ServiceFactory
 import org.osgi.framework.ServiceRegistration;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
 import org.apache.clerezza.rdf.core.impl.SimpleGraph;
 
 /**
@@ -33,18 +34,22 @@ import org.apache.clerezza.rdf.core.impl
  */
 public class GraphServiceFactory implements ServiceFactory {
 	
-	private TcManager tcManager;
-	private UriRef name;
+	private final TcManager tcManager;
+	private final UriRef name;
+	private final TcAccessController tcAccessController;
 
-	GraphServiceFactory(TcManager tcManager, UriRef name) {
+	GraphServiceFactory(TcManager tcManager, UriRef name,
+			TcAccessController tcAccessController) {
 		this.tcManager = tcManager;
 		this.name = name;
+		this.tcAccessController = tcAccessController;
 	}
 
 	@Override
 	public Object getService(Bundle arg0, ServiceRegistration arg1) {
 		TripleCollection tc = 
-				new SecuredTripleCollection(tcManager.getGraph(name), name);
+				new SecuredTripleCollection(tcManager.getGraph(name), name,
+				tcAccessController);
 		return new SimpleGraph(tc);
 	}
 

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.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/MGraphServiceFactory.java?rev=965059&r1=965058&r2=965059&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java Sat Jul 17 12:04:33 2010
@@ -22,6 +22,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
 
 /**
  * @see <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/ServiceFactory.html">
@@ -33,15 +34,18 @@ public class MGraphServiceFactory implem
 	
 	private TcManager tcManager;
 	private UriRef name;
+	private final TcAccessController tcAccessController;
 
-	MGraphServiceFactory(TcManager tcManager, UriRef name) {
+	MGraphServiceFactory(TcManager tcManager, UriRef name,
+			TcAccessController tcAccessController) {
 		this.tcManager = tcManager;
 		this.name = name;
+		this.tcAccessController = tcAccessController;
 	}
 
 	@Override
 	public Object getService(Bundle arg0, ServiceRegistration arg1) {
-		return new SecuredMGraph(tcManager.getMGraph(name), name);
+		return new SecuredMGraph(tcManager.getMGraph(name), name, tcAccessController);
 	}
 
 	@Override

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=965059&r1=965058&r2=965059&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 Sat Jul 17 12:04:33 2010
@@ -21,6 +21,7 @@ package org.apache.clerezza.rdf.core.acc
 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;
 
 /**
@@ -34,8 +35,9 @@ public class SecuredMGraph extends Secur
 
 	private LockableMGraph wrapped;
 
-	public SecuredMGraph(LockableMGraph wrapped, UriRef name) {
-		super(wrapped, name);
+	public SecuredMGraph(LockableMGraph wrapped, UriRef name,
+			TcAccessController tcAccessController) {
+		super(wrapped, name,  tcAccessController);
 		this.wrapped = 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=965059&r1=965058&r2=965059&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 Sat Jul 17 12:04:33 2010
@@ -25,6 +25,7 @@ import org.apache.clerezza.rdf.core.Reso
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
 import org.apache.clerezza.rdf.core.access.security.TcPermission;
 import org.apache.clerezza.rdf.core.event.FilterTriple;
 import org.apache.clerezza.rdf.core.event.GraphListener;
@@ -38,12 +39,15 @@ import org.apache.clerezza.rdf.core.even
  */
 public class SecuredTripleCollection implements TripleCollection {
 
-	private TripleCollection wrapped;
-	private String name;
+	private final TripleCollection wrapped;
+	private final UriRef name;
+	private final TcAccessController tcAccessController;
 
-	public SecuredTripleCollection(TripleCollection wrapped, UriRef name) {
+	public SecuredTripleCollection(TripleCollection wrapped, UriRef name,
+			TcAccessController tcAccessController) {
 		this.wrapped = wrapped;
-		this.name = name.getUnicodeString();
+		this.name = name;
+		this.tcAccessController = tcAccessController;
 	}
 
 	@Override
@@ -160,19 +164,11 @@ public class SecuredTripleCollection imp
 	}
 
 	private void checkRead() {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name,
-					TcPermission.READ));
-		}
+		tcAccessController.checkReadPermission(name);
 	}
 
 	private void checkWrite() {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name, 
-					TcPermission.READWRITE));
-		}
+		tcAccessController.checkReadWritePermission(name);
 	}
 
 	@Override

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.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/TcManager.java?rev=965059&r1=965058&r2=965059&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java Sat Jul 17 12:04:33 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.clerezza.rdf.core.access;
 
-import org.apache.clerezza.rdf.core.access.security.TcPermission;
 import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
 import org.apache.clerezza.rdf.core.impl.WriteBlockedTripleCollection;
 
@@ -43,6 +42,8 @@ import org.apache.clerezza.rdf.core.Grap
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
+import org.apache.clerezza.rdf.core.access.security.TcAccessController;
 import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
 import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
 import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
@@ -51,6 +52,11 @@ import org.apache.clerezza.rdf.core.spar
 import org.apache.clerezza.rdf.core.sparql.QueryEngine;
 import org.apache.clerezza.rdf.core.sparql.ResultSet;
 import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
 
 /**
  * This class implements <code>TcManager</code>, delegating the actual
@@ -74,19 +80,20 @@ import org.apache.clerezza.rdf.core.spar
  *
  * @author reto, mir, hasan
  * 
- * @scr.component
- * @scr.service interface="org.apache.clerezza.rdf.core.access.TcManager"
- * @scr.reference name="weightedTcProvider" cardinality="1..n"
- *                policy="dynamic"
- *                interface="org.apache.clerezza.rdf.core.access.WeightedTcProvider"
- * 
  */
+@Component
+@Service(TcManager.class)
+@Reference(name="weightedTcProvider", policy=ReferencePolicy.DYNAMIC,
+		referenceInterface=WeightedTcProvider.class,
+		cardinality=ReferenceCardinality.MANDATORY_MULTIPLE)
 public class TcManager implements TcProvider {
 
 	private SortedSet<WeightedTcProvider> providerList = new TreeSet<WeightedTcProvider>(
 			new WeightedProviderComparator());
 	private static volatile TcManager instance;
 
+	private TcAccessController tcAccessController = new TcAccessController(this);
+
 	/**
 	 * Mapping to LockableMGraph's and ServiceRegistration using their URI's as key.
 	 * Makes sure that per URI only one instance of the LockableMGraph is used,
@@ -271,10 +278,10 @@ public class TcManager implements TcProv
 				MGraph.class.getName(),
 				LockableMGraph.class.getName()
 			};
-			service = new MGraphServiceFactory(this, name);
+			service = new MGraphServiceFactory(this, name, tcAccessController);
 		} else if (triples instanceof Graph) {
 			interfaceNames = new String[]{Graph.class.getName()};
-			service = new GraphServiceFactory(this, name);
+			service = new GraphServiceFactory(this, name, tcAccessController);
 		} else {
 			return null;
 		}
@@ -326,11 +333,7 @@ public class TcManager implements TcProv
 
 	@Override
 	public Graph getGraph(UriRef name) throws NoSuchEntityException {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name.getUnicodeString(),
-					"read"));
-		}
+		tcAccessController.checkReadPermission(name);
 		for (TcProvider provider : providerList) {
 			try {
 				return provider.getGraph(name);
@@ -345,16 +348,11 @@ public class TcManager implements TcProv
 
 	@Override
 	public LockableMGraph getMGraph(UriRef name) {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			try {
-				security.checkPermission(new TcPermission(name
-						.getUnicodeString(), "readwrite"));
-			} catch (AccessControlException e) {
-				security.checkPermission(new TcPermission(name
-						.getUnicodeString(), "read"));
-				return new WriteBlockedMGraph(getUnsecuredMGraph(name));
-			}
+		try {
+			tcAccessController.checkReadWritePermission(name);
+		} catch (AccessControlException e) {
+			tcAccessController.checkReadPermission(name);
+			return new WriteBlockedMGraph(getUnsecuredMGraph(name));
 		}
 		return getUnsecuredMGraph(name);
 	}
@@ -412,17 +410,12 @@ public class TcManager implements TcProv
 
 	@Override
 	public TripleCollection getTriples(UriRef name) {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			try {
-				security.checkPermission(new TcPermission(name
-						.getUnicodeString(), "readwrite"));
-			} catch (AccessControlException e) {
-				security.checkPermission(new TcPermission(name
-						.getUnicodeString(), "read"));
-				return new WriteBlockedTripleCollection(
-						getUnsecuredTriples(name));
-			}
+		try {
+			tcAccessController.checkReadWritePermission(name);
+		} catch (AccessControlException e) {
+			tcAccessController.checkReadPermission(name);
+			return new WriteBlockedTripleCollection(
+					getUnsecuredTriples(name));
 		}
 		return getUnsecuredTriples(name);
 	}
@@ -451,11 +444,7 @@ public class TcManager implements TcProv
 	@Override
 	public LockableMGraph createMGraph(UriRef name)
 			throws UnsupportedOperationException {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name.getUnicodeString(),
-					"readwrite"));
-		}
+		tcAccessController.checkReadWritePermission(name);
 		for (WeightedTcProvider provider : providerList) {
 			try {
 				MGraph providedMGraph = provider.createMGraph(name);
@@ -486,11 +475,7 @@ public class TcManager implements TcProv
 
 	@Override
 	public Graph createGraph(UriRef name, TripleCollection triples) {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name.getUnicodeString(),
-					"readwrite"));
-		}
+		tcAccessController.checkReadWritePermission(name);
 		for (WeightedTcProvider provider : providerList) {
 			try {
 				Graph result = provider.createGraph(name, triples);
@@ -515,11 +500,7 @@ public class TcManager implements TcProv
 
 	@Override
 	public void deleteTripleCollection(UriRef name) {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			security.checkPermission(new TcPermission(name.getUnicodeString(),
-					"readwrite"));
-		}
+		tcAccessController.checkReadWritePermission(name);
 		for (TcProvider provider : providerList) {
 			try {
 				provider.deleteTripleCollection(name);
@@ -591,8 +572,7 @@ public class TcManager implements TcProv
 		Set<UriRef> result = new HashSet<UriRef>();
 		for (UriRef name : tcNames) {
 			try {
-				security.checkPermission(new TcPermission(name
-						.getUnicodeString(), "read"));
+				tcAccessController.checkReadPermission(name);
 			} catch (AccessControlException e) {
 				continue;
 			}
@@ -720,6 +700,14 @@ public class TcManager implements TcProv
 	}
 
 	/**
+	 * @return the TcAccessController that can be used to set the permissions
+	 * needed to access a Triple Collection
+	 */
+	public TcAccessController getTcAccessController() {
+		return tcAccessController;
+	}
+
+	/**
 	 * Contains an unsecured LockableMGraph, a ServiceRegistration and
 	 * the WeightedTcProvider that generated the graph
 	 */

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java?rev=965059&r1=965058&r2=965059&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java Sat Jul 17 12:04:33 2010
@@ -26,6 +26,7 @@ import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.Permissions;
 import java.security.Policy;
+import java.util.Collections;
 import java.util.PropertyPermission;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -34,6 +35,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.providers.WeightedA;
 import org.apache.clerezza.rdf.core.access.providers.WeightedDummy;
@@ -75,10 +77,12 @@ public class SecurityTest {
 				result.add(new TcPermission("http://example.org/graph/alreadyexists", "readwrite"));
 				result.add(new TcPermission("http://example.org/read/graph", "read"));
 				result.add(new TcPermission("http://example.org/area/allowed/*", "readwrite"));
+				result.add(new TcPermission("http://zz.localhost/graph-access.graph", "readwrite"));
 				//result.add(new AllPermission());
 				result.add(new RuntimePermission("*"));
 				result.add(new ReflectPermission("suppressAccessChecks"));
-				result.add(new PropertyPermission("user.timezone", "read"));
+				result.add(new PropertyPermission("*", "read"));
+				//(java.util.PropertyPermission line.separator read)
 				result.add(new FilePermission("/-", "read,write"));
 				return result;
 			}
@@ -125,6 +129,39 @@ public class SecurityTest {
 	public void testAcessForbiddenGraph() {
 		TcManager.getInstance().getGraph(new UriRef("http://example.org/forbidden"));
 	}
+
+	@Test(expected=NoSuchEntityException.class)
+	public void testCustomPermissions() {
+		UriRef graphUri = new UriRef("http://example.org/custom");
+		TcManager.getInstance().getTcAccessController().setRequiredReadPermissions(graphUri,
+				Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
+		//new FilePermission("/etc", "write").toString()));
+		TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("http://zz.localhost/graph-access.graph"));
+		System.out.print(ag.toString());
+		TcManager.getInstance().getMGraph(graphUri);
+	}
+
+	@Test(expected=AccessControlException.class)
+	public void testCustomPermissionsIncorrect() {
+		UriRef graphUri = new UriRef("http://example.org/custom");
+		TcManager.getInstance().getTcAccessController().setRequiredReadPermissions(graphUri,
+				Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
+		//new FilePermission("/etc", "write").toString()));
+		TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("http://zz.localhost/graph-access.graph"));
+		System.out.print(ag.toString());
+		TcManager.getInstance().createMGraph(graphUri);
+	}
+
+	@Test
+	public void testCustomReadWritePermissions() {
+		UriRef graphUri = new UriRef("http://example.org/read-write-custom");
+		TcManager.getInstance().getTcAccessController().setRequiredReadWritePermissions(graphUri,
+				Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
+		//new FilePermission("/etc", "write").toString()));
+		TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("http://zz.localhost/graph-access.graph"));
+		System.out.print(ag.toString());
+		TcManager.getInstance().createMGraph(graphUri);
+	}
 	
 	@Test(expected=EntityAlreadyExistsException.class)
 	public void testCreateMGraph() {