[Mulgara-svn] r1031 - trunk/src/jar/resolver/java/org/mulgara/resolver
alexhall at mulgara.org
alexhall at mulgara.org
Fri Jun 27 20:23:37 UTC 2008
Author: alexhall
Date: 2008-06-27 13:23:34 -0700 (Fri, 27 Jun 2008)
New Revision: 1031
Modified:
trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswerUnitTest.java
Log:
Apply security checks to backup and export operations.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java 2008-06-27 17:20:26 UTC (rev 1030)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java 2008-06-27 20:23:34 UTC (rev 1031)
@@ -37,7 +37,9 @@
import java.util.zip.GZIPOutputStream;
import org.mulgara.query.ConstraintImpl;
+import org.mulgara.query.QueryException;
import org.mulgara.resolver.spi.DatabaseMetadata;
+import org.mulgara.resolver.spi.SecurityAdapter;
import org.mulgara.resolver.spi.SystemResolver;
import org.mulgara.store.statement.StatementStore;
import org.mulgara.store.stringpool.SPObject;
@@ -85,6 +87,14 @@
public void execute(OperationContext operationContext,
SystemResolver systemResolver,
DatabaseMetadata metadata) throws Exception {
+
+ // Make sure security adapters are satisfied before proceeding.
+ for (SecurityAdapter securityAdapter : operationContext.getSecurityAdapterList()) {
+ if (!securityAdapter.canBackup()) {
+ throw new QueryException("You do not have permission to back up the database.");
+ }
+ }
+
OutputStream os = getOutputStream();;
Writer writer = null;
try {
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java 2008-06-27 17:20:26 UTC (rev 1030)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java 2008-06-27 20:23:34 UTC (rev 1031)
@@ -23,13 +23,12 @@
import org.mulgara.query.Variable;
import org.mulgara.query.rdf.URIReferenceImpl;
import org.mulgara.resolver.spi.DatabaseMetadata;
-import org.mulgara.resolver.spi.Resolution;
-import org.mulgara.resolver.spi.Resolver;
import org.mulgara.resolver.spi.ResolverFactory;
import org.mulgara.resolver.spi.Statements;
import org.mulgara.resolver.spi.SystemResolver;
import org.mulgara.resolver.spi.TuplesWrapperStatements;
import org.mulgara.store.statement.StatementStore;
+import org.mulgara.store.tuples.Tuples;
/**
* An {@link Operation} that serializes the contents of an RDF graph to either
@@ -92,12 +91,8 @@
};
Constraint constraint = new ConstraintImpl(vars[0], vars[1], vars[2], new LocalNode(graph));
- // Use to operation context to enlist a new resolver in this transaction.
- // Can't use the SystemResolver because it only resolves internal graphs.
- Resolver resolver = operationContext.obtainResolver(resolverFactory);
-
- // Get all statements from the graph.
- Resolution resolution = resolver.resolve(constraint);
+ // Get all statements from the graph. Delegate to the operation context to do the security check.
+ Tuples resolution = operationContext.resolve(constraint);
Statements graphStatements = new TuplesWrapperStatements(resolution, vars[0], vars[1], vars[2]);
// Do the writing.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java 2008-06-27 17:20:26 UTC (rev 1030)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java 2008-06-27 20:23:34 UTC (rev 1031)
@@ -31,14 +31,15 @@
import java.net.URI;
import java.util.List;
-// Local packages
import org.mulgara.query.Answer;
+import org.mulgara.query.Constraint;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
import org.mulgara.resolver.spi.Resolver;
import org.mulgara.resolver.spi.ResolverFactory;
import org.mulgara.resolver.spi.SecurityAdapter;
import org.mulgara.resolver.spi.SystemResolver;
+import org.mulgara.store.tuples.Tuples;
/**
* Services provided to invocations of the {@link Operation#execute} method.
@@ -113,6 +114,19 @@
* @return The new model node, or the current model if it is already canonical or unknown.
*/
public long getCanonicalModel(long model);
+
+ /**
+ * Convenience method for evaluating a constraint in the context of a transactional
+ * operation. This method may be used to evaluate constraints against both internal and
+ * external graphs; the context will find and use the appropriate Resolver. The method will
+ * also perform security checks on the graph specified by the constraint before resolving it.
+ *
+ * @param constraint The constraint to resolve.
+ * @return The constraint resolution.
+ * @throws QueryException if there was an error obtaining the resolver, or resolving the consraint,
+ * or if security permissions were not satisfied.
+ */
+ public Tuples resolve(Constraint constraint) throws QueryException;
/**
* Here for the moment while we fix transactions.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswerUnitTest.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswerUnitTest.java 2008-06-27 17:20:26 UTC (rev 1030)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswerUnitTest.java 2008-06-27 20:23:34 UTC (rev 1031)
@@ -193,5 +193,7 @@
throws Exception { return null; }
public SystemResolver getSystemResolver() { return null; } // FIXME: Scaffolding for transactions.
+
+ public Tuples resolve(Constraint constraint) throws QueryException { return null; }
}
}
More information about the Mulgara-svn
mailing list