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/07/17 20:06:08 UTC
[01/10] jena git commit: Fixes for bug JENA-990
Repository: jena
Updated Branches:
refs/heads/master 8dab56070 -> 53878d492
Fixes for bug JENA-990
created OperationDeniedException
extended that with AccessDeniedExcetpion
extended that with AddDenied and DeleteDenied.
renamed permissions exception to avoid conflict
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/db5791df
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/db5791df
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/db5791df
Branch: refs/heads/master
Commit: db5791df2ad0611d8da88b0f4a6689f8b410228d
Parents: c25470d
Author: Claude Warren <cl...@apache.org>
Authored: Thu Jul 16 22:06:49 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Thu Jul 16 22:06:49 2015 +0100
----------------------------------------------------------------------
.../jena/shared/AccessDeniedException.java | 56 +++++++++++++++++
.../apache/jena/shared/AddDeniedException.java | 44 +++++++++----
.../jena/shared/DeleteDeniedException.java | 44 +++++++++----
.../jena/shared/OperationDeniedException.java | 31 +++++++++
.../jena/shared/UpdateDeniedException.java | 43 -------------
.../jena/permissions/AccessDeniedException.java | 66 --------------------
.../AccessDeniedRuntimeException.java | 66 ++++++++++++++++++++
7 files changed, 219 insertions(+), 131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-core/src/main/java/org/apache/jena/shared/AccessDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/AccessDeniedException.java b/jena-core/src/main/java/org/apache/jena/shared/AccessDeniedException.java
new file mode 100644
index 0000000..4882210
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/shared/AccessDeniedException.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.shared;
+
+import org.apache.jena.graph.Triple ;
+
+/**
+ Superclass of exceptions thrown when permissions do not allow an operation
+ on a graph.
+*/
+
+public class AccessDeniedException extends OperationDeniedException
+ {
+ private Triple triple;
+
+ public AccessDeniedException() { super(); }
+ public AccessDeniedException(String message) { super(message); }
+ public AccessDeniedException(Throwable cause) { super(cause) ; }
+ public AccessDeniedException(String message, Throwable cause) { super(message, cause) ; }
+
+
+ public AccessDeniedException( String message, Triple triple )
+ {
+ super( message + triple.toString() );
+ this.triple = triple;
+ }
+
+ public AccessDeniedException(Throwable cause, Triple triple)
+ {
+ super(cause) ;
+ this.triple = triple;
+ }
+ public AccessDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause) ;
+ this.triple = triple;
+ }
+
+ public Triple getTriple()
+ { return triple; }
+ }
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-core/src/main/java/org/apache/jena/shared/AddDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/AddDeniedException.java b/jena-core/src/main/java/org/apache/jena/shared/AddDeniedException.java
index 656762c..f148885 100644
--- a/jena-core/src/main/java/org/apache/jena/shared/AddDeniedException.java
+++ b/jena-core/src/main/java/org/apache/jena/shared/AddDeniedException.java
@@ -18,16 +18,38 @@
package org.apache.jena.shared;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.Triple;
/**
- Exception to throw for a denied add operation
-*/
-public class AddDeniedException extends UpdateDeniedException
- {
- public AddDeniedException(String message)
- { super( message ); }
-
- public AddDeniedException( String message, Triple triple )
- { super( message, triple ); }
- }
+ * Exception to throw for a denied add operation
+ */
+public class AddDeniedException extends AccessDeniedException {
+ public AddDeniedException() {
+ super();
+ }
+
+ public AddDeniedException(String message) {
+ super(message);
+ }
+
+ public AddDeniedException(String message, Triple triple) {
+ super(message, triple);
+ }
+
+ public AddDeniedException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public AddDeniedException(Throwable throwable, Triple triple) {
+ super(throwable, triple);
+ }
+
+ public AddDeniedException(String message, Throwable throwable, Triple triple) {
+ super(message, throwable, triple);
+ }
+
+ public AddDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-core/src/main/java/org/apache/jena/shared/DeleteDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/DeleteDeniedException.java b/jena-core/src/main/java/org/apache/jena/shared/DeleteDeniedException.java
index ab5a643..63a1226 100644
--- a/jena-core/src/main/java/org/apache/jena/shared/DeleteDeniedException.java
+++ b/jena-core/src/main/java/org/apache/jena/shared/DeleteDeniedException.java
@@ -18,16 +18,38 @@
package org.apache.jena.shared;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.Triple;
/**
- Exception to throw if a delete is denied.
-*/
-public class DeleteDeniedException extends UpdateDeniedException
- {
- public DeleteDeniedException( String message )
- { super( message ); }
-
- public DeleteDeniedException( String message, Triple triple )
- { super( message, triple ); }
- }
+ * Exception to throw if a delete is denied.
+ */
+public class DeleteDeniedException extends AccessDeniedException {
+ public DeleteDeniedException() {
+ super();
+ }
+
+ public DeleteDeniedException(String message) {
+ super(message);
+ }
+
+ public DeleteDeniedException(String message, Triple triple) {
+ super(message, triple);
+ }
+
+ public DeleteDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause, triple);
+ }
+
+ public DeleteDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DeleteDeniedException(Throwable cause, Triple triple) {
+ super(cause, triple);
+ }
+
+ public DeleteDeniedException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-core/src/main/java/org/apache/jena/shared/OperationDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/OperationDeniedException.java b/jena-core/src/main/java/org/apache/jena/shared/OperationDeniedException.java
new file mode 100644
index 0000000..7a4db03
--- /dev/null
+++ b/jena-core/src/main/java/org/apache/jena/shared/OperationDeniedException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.shared;
+
+/**
+ Superclass of exceptions of all refusals of operation on a graph.
+*/
+
+public class OperationDeniedException extends JenaException
+ {
+ public OperationDeniedException() { super(); }
+ public OperationDeniedException(String message) { super(message); }
+ public OperationDeniedException(Throwable cause) { super(cause) ; }
+ public OperationDeniedException(String message, Throwable cause) { super(message, cause) ; }
+ }
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-core/src/main/java/org/apache/jena/shared/UpdateDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/shared/UpdateDeniedException.java b/jena-core/src/main/java/org/apache/jena/shared/UpdateDeniedException.java
deleted file mode 100644
index a173b4a..0000000
--- a/jena-core/src/main/java/org/apache/jena/shared/UpdateDeniedException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.shared;
-
-import org.apache.jena.graph.* ;
-
-/**
- Superclass of exceptions thrown when attempting to add/delete on a
- readonly graph/model.
-*/
-
-public class UpdateDeniedException extends JenaException
- {
- private Triple triple;
-
- public UpdateDeniedException( String message )
- { super(message); }
-
- public UpdateDeniedException( String message, Triple triple )
- {
- super( message + triple.toString() );
- this.triple = triple;
- }
-
- public Triple getTriple()
- { return triple; }
- }
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedException.java b/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedException.java
deleted file mode 100644
index 84a263b..0000000
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedException.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.permissions;
-
-import org.apache.jena.permissions.SecurityEvaluator.Action;
-import org.apache.jena.permissions.SecurityEvaluator.SecNode;
-
-/**
- * Exception thrown by the security system when an action is not allowed.
- *
- * Contains the graphIRI and the action that was not allowed.
- */
-public class AccessDeniedException extends RuntimeException
-{
- private static final long serialVersionUID = 2789332975364811725L;
-
- private String triple;
-
- /**
- * Constructor.
- * @param uri The SecNode that identifies graph with the security.
- * @param action The action that was prohibited.
- */
- public AccessDeniedException( final SecNode uri, final Action action )
- {
- super(String.format("securedModel sec. %s: %s", uri, action));
- }
-
- /**
- * Constructor.
- * @param uri The SecNode that identifies graph with the security.
- * @param triple The triple The triple on which the action was prohibited.
- * @param action The action that was prohibited.
- */
- public AccessDeniedException( final SecNode uri, final String triple,
- final Action action )
- {
- super(String.format("triple sec. %s: %s", uri, action));
- this.triple = triple;
- }
-
- /**
- * @return The triple on which the action was prohibited. May be null.
- */
- public String getTriple()
- {
- return triple;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/db5791df/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java b/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
new file mode 100644
index 0000000..84a263b
--- /dev/null
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.permissions;
+
+import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.SecurityEvaluator.SecNode;
+
+/**
+ * Exception thrown by the security system when an action is not allowed.
+ *
+ * Contains the graphIRI and the action that was not allowed.
+ */
+public class AccessDeniedException extends RuntimeException
+{
+ private static final long serialVersionUID = 2789332975364811725L;
+
+ private String triple;
+
+ /**
+ * Constructor.
+ * @param uri The SecNode that identifies graph with the security.
+ * @param action The action that was prohibited.
+ */
+ public AccessDeniedException( final SecNode uri, final Action action )
+ {
+ super(String.format("securedModel sec. %s: %s", uri, action));
+ }
+
+ /**
+ * Constructor.
+ * @param uri The SecNode that identifies graph with the security.
+ * @param triple The triple The triple on which the action was prohibited.
+ * @param action The action that was prohibited.
+ */
+ public AccessDeniedException( final SecNode uri, final String triple,
+ final Action action )
+ {
+ super(String.format("triple sec. %s: %s", uri, action));
+ this.triple = triple;
+ }
+
+ /**
+ * @return The triple on which the action was prohibited. May be null.
+ */
+ public String getTriple()
+ {
+ return triple;
+ }
+
+}
[10/10] jena git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/jena
Posted by cl...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/jena
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/53878d49
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/53878d49
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/53878d49
Branch: refs/heads/master
Commit: 53878d49213d4e094a1f7d7f9a70f471a4f926c1
Parents: e48966c 8dab560
Author: Claude Warren <cl...@apache.org>
Authored: Fri Jul 17 18:59:11 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Fri Jul 17 18:59:11 2015 +0100
----------------------------------------------------------------------
.../apache/jena/sparql/core/DatasetChanges.java | 4 +
.../jena/sparql/core/DatasetChangesBatched.java | 76 ++++++-------
.../jena/sparql/core/DatasetChangesCapture.java | 108 +++++++++++--------
.../jena/sparql/core/DatasetChangesCounter.java | 1 +
.../spatial/SpatialDocProducerTriples.java | 3 +
.../jena/query/text/TextDocProducerTriples.java | 3 +
.../assembler/TestTextDatasetAssembler.java | 6 ++
7 files changed, 116 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
[08/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
Updates for JENA-990
Modified permissions to use new Exceptions.
Added ReadDeniedException
Added UpdateDeniedException
Modified unit tests to utilize new exception types.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/fcf71889
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/fcf71889
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/fcf71889
Branch: refs/heads/master
Commit: fcf718892a107a876a87640b8a4113ad02206b8d
Parents: db5791d
Author: Claude Warren <cl...@apache.org>
Authored: Thu Jul 16 22:10:06 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Thu Jul 16 22:10:06 2015 +0100
----------------------------------------------------------------------
.../AccessDeniedRuntimeException.java | 132 +-
.../jena/permissions/ReadDeniedException.java | 43 +
.../jena/permissions/SecurityEvaluator.java | 37 +-
.../jena/permissions/UpdateDeniedException.java | 43 +
.../jena/permissions/graph/SecuredGraph.java | 54 +-
.../permissions/graph/SecuredPrefixMapping.java | 55 +-
.../graph/impl/SecuredGraphImpl.java | 3 +-
.../jena/permissions/impl/SecuredItem.java | 12 +-
.../jena/permissions/impl/SecuredItemImpl.java | 94 +-
.../jena/permissions/model/SecuredAlt.java | 117 +-
.../permissions/model/SecuredContainer.java | 103 +-
.../jena/permissions/model/SecuredLiteral.java | 83 +-
.../jena/permissions/model/SecuredModel.java | 661 ++++---
.../jena/permissions/model/SecuredProperty.java | 6 +-
.../jena/permissions/model/SecuredRDFList.java | 144 +-
.../jena/permissions/model/SecuredRDFNode.java | 14 +-
.../model/SecuredReifiedStatement.java | 7 +-
.../jena/permissions/model/SecuredResource.java | 154 +-
.../jena/permissions/model/SecuredSeq.java | 152 +-
.../permissions/model/SecuredStatement.java | 126 +-
.../model/impl/SecuredModelImpl.java | 145 +-
.../model/impl/SecuredRDFListImpl.java | 7 +-
.../model/impl/SecuredResourceImpl.java | 10 +-
.../permissions/query/rewriter/OpRewriter.java | 5 +-
.../graph/CrossIDGraphEventManagerTest.java | 10 +-
.../graph/GraphEventManagerTest.java | 49 +-
.../jena/permissions/graph/MemGraphTest.java | 220 +--
.../graph/RecordingGraphListener.java | 55 +-
.../graph/SecuredPrefixMappingTest.java | 332 ++--
.../jena/permissions/graph/TDBGraphTest.java | 20 +-
.../jena/permissions/model/SecuredAltTest.java | 554 +++---
.../jena/permissions/model/SecuredBagTest.java | 13 +-
.../permissions/model/SecuredContainerTest.java | 392 ++--
.../permissions/model/SecuredLiteralTest.java | 405 ++--
.../model/SecuredModelDetailTest.java | 451 +++--
.../permissions/model/SecuredModelTest.java | 1739 +++++++-----------
.../permissions/model/SecuredPropertyTest.java | 40 +-
.../permissions/model/SecuredRDFListTest.java | 806 +++-----
.../permissions/model/SecuredRDFNodeTest.java | 112 +-
.../model/SecuredReifiedStatementTest.java | 40 +-
.../permissions/model/SecuredResourceTest.java | 718 +++-----
.../jena/permissions/model/SecuredSeqTest.java | 860 +++------
.../permissions/model/SecuredStatementTest.java | 547 ++----
.../jena/permissions/query/DataSetTest.java | 197 +-
.../jena/permissions/query/QueryEngineTest.java | 83 +-
.../query/rewriter/OpRewriterTest.java | 128 +-
46 files changed, 4164 insertions(+), 5814 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java b/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
index 84a263b..19bba34 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/AccessDeniedRuntimeException.java
@@ -1,66 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.permissions;
-
-import org.apache.jena.permissions.SecurityEvaluator.Action;
-import org.apache.jena.permissions.SecurityEvaluator.SecNode;
-
-/**
- * Exception thrown by the security system when an action is not allowed.
- *
- * Contains the graphIRI and the action that was not allowed.
- */
-public class AccessDeniedException extends RuntimeException
-{
- private static final long serialVersionUID = 2789332975364811725L;
-
- private String triple;
-
- /**
- * Constructor.
- * @param uri The SecNode that identifies graph with the security.
- * @param action The action that was prohibited.
- */
- public AccessDeniedException( final SecNode uri, final Action action )
- {
- super(String.format("securedModel sec. %s: %s", uri, action));
- }
-
- /**
- * Constructor.
- * @param uri The SecNode that identifies graph with the security.
- * @param triple The triple The triple on which the action was prohibited.
- * @param action The action that was prohibited.
- */
- public AccessDeniedException( final SecNode uri, final String triple,
- final Action action )
- {
- super(String.format("triple sec. %s: %s", uri, action));
- this.triple = triple;
- }
-
- /**
- * @return The triple on which the action was prohibited. May be null.
- */
- public String getTriple()
- {
- return triple;
- }
-
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements. See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership. The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package org.apache.jena.permissions;
+//
+//import org.apache.jena.permissions.SecurityEvaluator.Action;
+//import org.apache.jena.permissions.SecurityEvaluator.SecNode;
+//
+///**
+// * Exception thrown by the security system when an action is not allowed.
+// *
+// * Contains the graphIRI and the action that was not allowed.
+// */
+//public class AccessDeniedRuntimeException extends RuntimeException
+//{
+// private static final long serialVersionUID = 2789332975364811725L;
+//
+// private String triple;
+//
+// /**
+// * Constructor.
+// * @param uri The SecNode that identifies graph with the security.
+// * @param action The action that was prohibited.
+// */
+// public AccessDeniedRuntimeException( final SecNode uri, final Action action )
+// {
+// super(String.format("securedModel sec. %s: %s", uri, action));
+// }
+//
+// /**
+// * Constructor.
+// * @param uri The SecNode that identifies graph with the security.
+// * @param triple The triple The triple on which the action was prohibited.
+// * @param action The action that was prohibited.
+// */
+// public AccessDeniedRuntimeException( final SecNode uri, final String triple,
+// final Action action )
+// {
+// super(String.format("triple sec. %s: %s", uri, action));
+// this.triple = triple;
+// }
+//
+// /**
+// * @return The triple on which the action was prohibited. May be null.
+// */
+// public String getTriple()
+// {
+// return triple;
+// }
+//
+//}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java b/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
new file mode 100644
index 0000000..5e95725
--- /dev/null
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
@@ -0,0 +1,43 @@
+package org.apache.jena.permissions;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.AccessDeniedException;
+
+public class ReadDeniedException extends AccessDeniedException {
+
+ public ReadDeniedException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Triple triple) {
+ super(message, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(Throwable cause, Triple triple) {
+ super(cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java b/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
index 1e28084..9a2a396 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
@@ -23,6 +23,14 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.jena.graph.FrontsNode;
+import org.apache.jena.graph.FrontsTriple;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabel;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
+import org.apache.jena.rdf.model.AnonId;
/**
* SecurityEvaluator.
@@ -124,7 +132,7 @@ public interface SecurityEvaluator {
* An "Any" node type matches any node.
* </p>
*/
- public static class SecNode implements Comparable<SecNode> {
+ public static class SecNode implements Comparable<SecNode>, FrontsNode {
/**
* The types of nodes.
@@ -294,12 +302,31 @@ public interface SecurityEvaluator {
public String toString() {
return String.format("[%s:%s]", getType(), getValue());
}
+
+ @Override
+ public Node asNode() {
+ switch (type) {
+ case Anonymous:
+ AnonId id = AnonId.create(value);
+ return NodeFactory.createAnon( id );
+ case Any:
+ return Node.ANY;
+ case Literal:
+ LiteralLabel lit = LiteralLabelFactory.create(value, (String)null);
+ return NodeFactory.createLiteral(lit);
+ case URI:
+ return NodeFactory.createURI( value );
+
+ default :
+ return Node.ANY;
+ }
+ }
}
/**
* An immutable triple of SecNodes.
*/
- public static class SecTriple implements Comparable<SecTriple> {
+ public static class SecTriple implements Comparable<SecTriple>, FrontsTriple {
private final SecNode subject;
private final SecNode predicate;
private final SecNode object;
@@ -394,6 +421,11 @@ public interface SecurityEvaluator {
return String.format("( %s, %s, %s )", getSubject(),
getPredicate(), getObject());
}
+
+ @Override
+ public Triple asTriple() {
+ return new Triple( subject.asNode(), predicate.asNode(), object.asNode() );
+ }
}
/**
@@ -446,6 +478,7 @@ public interface SecurityEvaluator {
* @param graphIRI
* The IRI of the graph to check
* @return true if the action is allowed, false otherwise.
+ *
*/
public boolean evaluate(Object principal, Action action, SecNode graphIRI);
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java b/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
new file mode 100644
index 0000000..d1c6011
--- /dev/null
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
@@ -0,0 +1,43 @@
+package org.apache.jena.permissions;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.AccessDeniedException;
+
+public class UpdateDeniedException extends AccessDeniedException {
+
+ public UpdateDeniedException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Triple triple) {
+ super(message, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(Throwable cause, Triple triple) {
+ super(cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredGraph.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredGraph.java b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredGraph.java
index 037c06c..824dceb 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredGraph.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredGraph.java
@@ -21,7 +21,7 @@ import org.apache.jena.graph.Graph ;
import org.apache.jena.graph.GraphStatisticsHandler ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.SecNode;
import org.apache.jena.shared.AddDeniedException ;
@@ -39,64 +39,60 @@ public interface SecuredGraph extends Graph
/**
* @sec.graph Update
* @sec.triple Create
- * @throws AccessDeniedException
* @throws AddDeniedException
*/
@Override
- public void add( final Triple t ) throws AddDeniedException,
- AccessDeniedException;
+ public void add( final Triple t ) throws AddDeniedException;
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final Node s, final Node p, final Node o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final Triple t ) throws AccessDeniedException;
+ public boolean contains( final Triple t ) throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete
- * @throws AccessDeniedException
* @throws DeleteDeniedException
*/
@Override
- public void delete( final Triple t ) throws DeleteDeniedException,
- AccessDeniedException;
+ public void delete( final Triple t ) throws DeleteDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean dependsOn( final Graph other ) throws AccessDeniedException;
+ public boolean dependsOn( final Graph other ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read, otherwise filtered from iterator.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public ExtendedIterator<Triple> find( final Node s, final Node p,
- final Node o ) throws AccessDeniedException;
+ final Node o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read, otherwise filtered from iterator.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public ExtendedIterator<Triple> find( final Triple triple )
- throws AccessDeniedException;
+ throws ReadDeniedException;
@Override
public SecuredCapabilities getCapabilities();
@@ -113,50 +109,50 @@ public interface SecuredGraph extends Graph
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public GraphStatisticsHandler getStatisticsHandler()
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isEmpty() throws AccessDeniedException;
+ public boolean isEmpty() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean isIsomorphicWith( final Graph g )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public int size() throws AccessDeniedException;
+ public int size() throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete for every triple
- * @throws AccessDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public void clear();
+ public void clear() throws DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete (s, p, o )
- * @throws AccessDeniedException
+ *@throws DeleteDeniesException
*/
@Override
- public void remove( Node s, Node p, Node o );
+ public void remove( Node s, Node p, Node o ) throws DeleteDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredPrefixMapping.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredPrefixMapping.java b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredPrefixMapping.java
index f4007d8..899b80c 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredPrefixMapping.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/SecuredPrefixMapping.java
@@ -19,7 +19,8 @@ package org.apache.jena.permissions.graph;
import java.util.Map;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.shared.PrefixMapping ;
@@ -32,102 +33,102 @@ public interface SecuredPrefixMapping extends PrefixMapping, SecuredItem
{
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public String expandPrefix( final String prefixed )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Map<String, String> getNsPrefixMap() throws AccessDeniedException;
+ public Map<String, String> getNsPrefixMap() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public String getNsPrefixURI( final String prefix )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public String getNsURIPrefix( final String uri )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredPrefixMapping lock() throws AccessDeniedException;
+ public SecuredPrefixMapping lock() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String qnameFor( final String uri ) throws AccessDeniedException;
+ public String qnameFor( final String uri ) throws ReadDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredPrefixMapping removeNsPrefix( final String prefix )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean samePrefixMappingAs( final PrefixMapping other )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredPrefixMapping setNsPrefix( final String prefix,
- final String uri ) throws AccessDeniedException;
+ final String uri ) throws UpdateDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredPrefixMapping setNsPrefixes( final Map<String, String> map )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredPrefixMapping setNsPrefixes( final PrefixMapping other )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String shortForm( final String uri ) throws AccessDeniedException;
+ public String shortForm( final String uri ) throws ReadDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredPrefixMapping withDefaultMappings( final PrefixMapping map )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/graph/impl/SecuredGraphImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/impl/SecuredGraphImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/impl/SecuredGraphImpl.java
index cc0f283..9f2a881 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/graph/impl/SecuredGraphImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/graph/impl/SecuredGraphImpl.java
@@ -20,6 +20,7 @@ package org.apache.jena.permissions.graph.impl;
import org.apache.jena.graph.* ;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.graph.*;
import org.apache.jena.permissions.impl.ItemHolder;
import org.apache.jena.permissions.impl.SecuredItem;
@@ -72,7 +73,7 @@ public class SecuredGraphImpl extends SecuredItemImpl implements SecuredGraph
}
@Override
- public void add( final Triple t ) throws AddDeniedException
+ public void add( final Triple t ) throws AddDeniedException, UpdateDeniedException
{
checkUpdate();
checkCreate(t);
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItem.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItem.java b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItem.java
index bdec7c3..10f0d7c 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItem.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/impl/SecuredItem.java
@@ -28,7 +28,7 @@ import org.apache.jena.permissions.SecurityEvaluator.SecTriple;
*/
public interface SecuredItem
{
-
+
/**
* Utilities for SecuredItem implementations.
*/
@@ -51,6 +51,16 @@ public interface SecuredItem
.equals(si2.getSecurityEvaluator())
&& si1.getModelIRI().equals(si2.getModelIRI());
}
+
+ public static String modelPermissionMsg( final SecNode modelURI )
+ {
+ return String.format("Model permissions violation: %s", modelURI);
+ }
+
+ public static String triplePermissionMsg( final SecNode modelURI )
+ {
+ return String.format("Triple permissions violation: %s", modelURI);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/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 d2bca9a..1d535c2 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
@@ -22,13 +22,16 @@ import java.lang.reflect.Proxy;
import org.apache.commons.collections4.map.LRUMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.SecurityEvaluator.SecNode;
import org.apache.jena.permissions.SecurityEvaluator.SecTriple;
import org.apache.jena.permissions.SecurityEvaluator.SecNode.Type;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.util.iterator.ExtendedIterator ;
import org.apache.jena.vocabulary.RDF ;
@@ -490,18 +493,18 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that create on the securedModel is allowed,
*
- * @throws AccessDeniedException
+ * @throws AddDeniedException
* on failure
*/
- protected void checkCreate()
+ protected void checkCreate() throws AddDeniedException
{
if (!canCreate())
{
- throw new AccessDeniedException(modelNode, Action.Create);
+ throw new AddDeniedException( SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
- protected void checkCreate( final org.apache.jena.graph.Triple t )
+ protected void checkCreate( final org.apache.jena.graph.Triple t ) throws AddDeniedException
{
checkCreate(SecuredItemImpl.convert(t));
}
@@ -509,24 +512,35 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that the triple can be created in the securedModel.,
*
- * @throws AccessDeniedException
+ * @throws AddDeniedException
* on failure
*/
- protected void checkCreate( final SecTriple t )
+ protected void checkCreate( final SecTriple t ) throws AddDeniedException
{
if (!canCreate(t))
{
- throw new AccessDeniedException(modelNode, t.toString(),
- Action.Create);
+ throw new AddDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t.asTriple() );
}
}
- protected void checkCreate( final Statement s )
+ /**
+ * check that the statement can be created.
+ * @param s The statement.
+ * @throws AddDeniedException on failure
+ */
+ protected void checkCreate( final Statement s ) throws AddDeniedException
{
checkCreate(s.asTriple());
}
- protected void checkCreateReified( final String uri, final SecTriple t )
+ /**
+ * Check that a triple can be reified.
+ * @param uri The URI for the reification subject. May be null.
+ * @param t the triple that is to be reified.
+ * @throws AddDeniedException on failure to add triple
+ * @throws UpdateDenied if the updates of the graph are not allowed.
+ */
+ protected void checkCreateReified( final String uri, final SecTriple t ) throws AddDeniedException, UpdateDeniedException
{
checkUpdate();
final SecNode n = uri == null ? SecNode.FUTURE : new SecNode(Type.URI,
@@ -539,7 +553,7 @@ public abstract class SecuredItemImpl implements SecuredItem
.asNode()), t.getObject()));
}
- protected void checkCreateStatement( final ExtendedIterator<Statement> stmts )
+ protected void checkCreateStatement( final ExtendedIterator<Statement> stmts ) throws AddDeniedException
{
if (!canCreate(SecTriple.ANY))
{
@@ -558,7 +572,7 @@ public abstract class SecuredItemImpl implements SecuredItem
}
protected void checkCreateTriples(
- final ExtendedIterator<org.apache.jena.graph.Triple> triples )
+ final ExtendedIterator<org.apache.jena.graph.Triple> triples ) throws AddDeniedException
{
if (!canCreate(SecTriple.ANY))
{
@@ -579,14 +593,14 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that delete on the securedModel is allowed,
*
- * @throws AccessDeniedException
+ * @throws DeleteDeniedException
* on failure
*/
- protected void checkDelete()
+ protected void checkDelete() throws DeleteDeniedException
{
if (!canDelete())
{
- throw new AccessDeniedException(modelNode, Action.Delete);
+ throw new DeleteDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
@@ -598,15 +612,14 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that the triple can be deleted in the securedModel.,
*
- * @throws AccessDeniedException
+ * @throws DeleteDeniedException
* on failure
*/
protected void checkDelete( final SecTriple t )
{
if (!canDelete(t))
{
- throw new AccessDeniedException(modelNode, t.toString(),
- Action.Delete);
+ throw new DeleteDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t.asTriple());
}
}
@@ -656,18 +669,18 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that read on the securedModel is allowed,
*
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* on failure
*/
- protected void checkRead()
+ protected void checkRead() throws ReadDeniedException
{
if (!canRead())
{
- throw new AccessDeniedException(modelNode, Action.Read);
+ throw new ReadDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
- protected void checkRead( final org.apache.jena.graph.Triple t )
+ protected void checkRead( final org.apache.jena.graph.Triple t ) throws ReadDeniedException
{
checkRead(SecuredItemImpl.convert(t));
}
@@ -675,24 +688,23 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that the triple can be read in the securedModel.,
*
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* on failure
*/
- protected void checkRead( final SecTriple t )
+ protected void checkRead( final SecTriple t ) throws ReadDeniedException
{
if (!canRead(t))
{
- throw new AccessDeniedException(modelNode, t.toString(),
- Action.Read);
+ throw new ReadDeniedException(SecuredItem.Util.triplePermissionMsg(modelNode), t.asTriple());
}
}
- protected void checkRead( final Statement s )
+ protected void checkRead( final Statement s ) throws ReadDeniedException
{
checkRead(s.asTriple());
}
- protected void checkReadStatement( final ExtendedIterator<Statement> stmts )
+ protected void checkReadStatement( final ExtendedIterator<Statement> stmts ) throws ReadDeniedException
{
try
{
@@ -708,7 +720,7 @@ public abstract class SecuredItemImpl implements SecuredItem
}
protected void checkReadTriples(
- final ExtendedIterator<org.apache.jena.graph.Triple> triples )
+ final ExtendedIterator<org.apache.jena.graph.Triple> triples ) throws ReadDeniedException
{
try
{
@@ -726,19 +738,25 @@ public abstract class SecuredItemImpl implements SecuredItem
/**
* check that update on the securedModel is allowed,
*
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
* on failure
*/
- protected void checkUpdate()
+ protected void checkUpdate() throws UpdateDeniedException
{
if (!canUpdate())
{
- throw new AccessDeniedException(modelNode, Action.Update);
+ throw new UpdateDeniedException(SecuredItem.Util.modelPermissionMsg(modelNode));
}
}
+ /**
+ * Check that a triple can be changed from one value to another.
+ * @param from The original triple
+ * @param to The final triple
+ * @throws UpdateDeniedException
+ */
protected void checkUpdate( final org.apache.jena.graph.Triple from,
- final org.apache.jena.graph.Triple to )
+ final org.apache.jena.graph.Triple to ) throws UpdateDeniedException
{
checkUpdate(SecuredItemImpl.convert(from), SecuredItemImpl.convert(to));
}
@@ -748,15 +766,15 @@ public abstract class SecuredItemImpl implements SecuredItem
*
* @param from the starting triple
* @param to the final triple.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
* on failure
*/
- protected void checkUpdate( final SecTriple from, final SecTriple to )
+ protected void checkUpdate( final SecTriple from, final SecTriple to ) throws UpdateDeniedException
{
if (!canUpdate(from, to))
{
- throw new AccessDeniedException(modelNode, String.format(
- "%s to %s", from, to), Action.Update);
+ throw new UpdateDeniedException( String.format(
+ "%s: %s to %s", SecuredItem.Util.modelPermissionMsg(modelNode), from, to));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/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 7630b79..a1a3780 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,12 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
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;
/**
* The interface for secured Alt instances.
@@ -33,232 +35,241 @@ public interface SecuredAlt extends Alt, SecuredContainer
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredRDFNode getDefault() throws AccessDeniedException;
+ public SecuredRDFNode getDefault() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredAlt getDefaultAlt() throws AccessDeniedException;
+ public SecuredAlt getDefaultAlt() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredBag getDefaultBag() throws AccessDeniedException;
+ public SecuredBag getDefaultBag() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean getDefaultBoolean() throws AccessDeniedException;
+ public boolean getDefaultBoolean() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public byte getDefaultByte() throws AccessDeniedException;
+ public byte getDefaultByte() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public char getDefaultChar() throws AccessDeniedException;
+ public char getDefaultChar() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public double getDefaultDouble() throws AccessDeniedException;
+ public double getDefaultDouble() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public float getDefaultFloat() throws AccessDeniedException;
+ public float getDefaultFloat() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public int getDefaultInt() throws AccessDeniedException;
+ public int getDefaultInt() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getDefaultLanguage() throws AccessDeniedException;
+ public String getDefaultLanguage() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredLiteral getDefaultLiteral() throws AccessDeniedException;
+ public SecuredLiteral getDefaultLiteral() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public long getDefaultLong() throws AccessDeniedException;
+ public long getDefaultLong() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredResource getDefaultResource() throws AccessDeniedException;
+ public SecuredResource getDefaultResource() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
@Deprecated
public SecuredResource getDefaultResource( final ResourceF f )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredSeq getDefaultSeq() throws AccessDeniedException;
+ public SecuredSeq getDefaultSeq() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public short getDefaultShort() throws AccessDeniedException;
+ public short getDefaultShort() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getDefaultString() throws AccessDeniedException;
+ public String getDefaultString() throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredAlt setDefault( final boolean o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final char o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final char o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final double o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final double o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final float o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final float o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final long o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final long o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final Object o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final Object o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredAlt setDefault( final RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt setDefault( final String o ) throws AccessDeniedException;
+ public SecuredAlt setDefault( final String o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple(this, RDF.li(1), existing ), SecTriple(this,
* RDF.li(1), o )
* @sec.triple Create SecTriple(this, RDF.li(1), o ) if no current default
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredAlt setDefault( final String o, final String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/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 4fc9198..c108db4 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
@@ -19,12 +19,15 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
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.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
/**
* The interface for secured Container instances.
@@ -38,181 +41,191 @@ public interface SecuredContainer extends Container, SecuredResource
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final boolean o ) throws AccessDeniedException;
+ public SecuredContainer add( final boolean o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final char o ) throws AccessDeniedException;
+ public SecuredContainer add( final char o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final double o ) throws AccessDeniedException;
+ public SecuredContainer add( final double o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final float o ) throws AccessDeniedException;
+ public SecuredContainer add( final float o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final long o ) throws AccessDeniedException;
+ public SecuredContainer add( final long o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final Object o ) throws AccessDeniedException;
+ public SecuredContainer add( final Object o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final RDFNode o ) throws AccessDeniedException;
+ public SecuredContainer add( final RDFNode o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredContainer add( final String o ) throws AccessDeniedException;
+ public SecuredContainer add( final String o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredContainer add( final String o, final String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final boolean o ) throws AccessDeniedException;
+ public boolean contains( final boolean o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final char o ) throws AccessDeniedException;
+ public boolean contains( final char o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final double o ) throws AccessDeniedException;
+ public boolean contains( final double o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final float o ) throws AccessDeniedException;
+ public boolean contains( final float o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final long o ) throws AccessDeniedException;
+ public boolean contains( final long o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final Object o ) throws AccessDeniedException;
+ public boolean contains( final Object o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final RDFNode o ) throws AccessDeniedException;
+ public boolean contains( final RDFNode o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final String o ) throws AccessDeniedException;
+ public boolean contains( final String o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final String o, final String l )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read on each triple ( this, rdf:li_? node ) returned by
* iterator;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredNodeIterator<RDFNode> iterator() throws AccessDeniedException;
+ public SecuredNodeIterator<RDFNode> iterator() throws ReadDeniedException;
/**
* @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;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
public SecuredNodeIterator<RDFNode> iterator( Set<Action> perms )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete s as triple;
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredContainer remove( final Statement s )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public int size() throws AccessDeniedException;
+ public int size() throws ReadDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/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 259430c..d1610d3 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
@@ -19,7 +19,7 @@ package org.apache.jena.permissions.model;
import org.apache.jena.datatypes.DatatypeFormatException ;
import org.apache.jena.datatypes.RDFDatatype ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.rdf.model.Literal ;
import org.apache.jena.rdf.model.Model ;
@@ -34,132 +34,139 @@ public interface SecuredLiteral extends Literal, SecuredRDFNode
@Override
public SecuredLiteral asLiteral();
- // @Override
- // public SecuredResource asResource();
-
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public boolean getBoolean() throws AccessDeniedException,
+ public boolean getBoolean() throws ReadDeniedException,
DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public byte getByte() throws AccessDeniedException, DatatypeFormatException;
+ public byte getByte() throws ReadDeniedException, DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public char getChar() throws AccessDeniedException, DatatypeFormatException;
+ public char getChar() throws ReadDeniedException, DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public RDFDatatype getDatatype() throws AccessDeniedException;
+ public RDFDatatype getDatatype() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getDatatypeURI() throws AccessDeniedException;
+ public String getDatatypeURI() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public double getDouble() throws AccessDeniedException,
+ public double getDouble() throws ReadDeniedException,
DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public float getFloat() throws AccessDeniedException,
+ public float getFloat() throws ReadDeniedException,
DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public int getInt() throws AccessDeniedException, DatatypeFormatException;
+ public int getInt() throws ReadDeniedException, DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getLanguage() throws AccessDeniedException;
+ public String getLanguage() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public String getLexicalForm() throws AccessDeniedException;
+ public String getLexicalForm() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public long getLong() throws AccessDeniedException, DatatypeFormatException;
+ public long getLong() throws ReadDeniedException, DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public short getShort() throws AccessDeniedException,
+ public short getShort() throws ReadDeniedException,
DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws DatatypeFormatException
*/
@Override
- public String getString() throws AccessDeniedException,
+ public String getString() throws ReadDeniedException,
DatatypeFormatException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Object getValue() throws AccessDeniedException;
+ public Object getValue() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Literal inModel( final Model m ) throws AccessDeniedException;
+ public Literal inModel( final Model m ) throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isWellFormedXML() throws AccessDeniedException;
+ public boolean isWellFormedXML() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean sameValueAs( final Literal other )
- throws AccessDeniedException;
+ throws ReadDeniedException;
}
[02/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredSeqTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredSeqTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredSeqTest.java
index 54c365a..66c1468 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredSeqTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredSeqTest.java
@@ -19,44 +19,42 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.model.SecuredAlt;
import org.apache.jena.permissions.model.SecuredBag;
import org.apache.jena.permissions.model.SecuredSeq;
import org.apache.jena.permissions.model.impl.SecuredSeqImpl;
-import org.apache.jena.rdf.model.Alt ;
-import org.apache.jena.rdf.model.Bag ;
-import org.apache.jena.rdf.model.ResourceFactory ;
-import org.apache.jena.rdf.model.Seq ;
+import org.apache.jena.rdf.model.Alt;
+import org.apache.jena.rdf.model.Bag;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.Seq;
+import org.apache.jena.shared.AccessDeniedException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredSeqTest extends SecuredContainerTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredSeqTest extends SecuredContainerTest {
private Seq seq;
- public SecuredSeqTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredSeqTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
// TODO Auto-generated constructor stub
}
- private SecuredSeq getSecuredSeq()
- {
+ private SecuredSeq getSecuredSeq() {
return (SecuredSeq) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
seq = baseModel.getSeq("http://example.com/testContainer");
setSecuredRDFNode(SecuredSeqImpl.getInstance(securedModel, seq), seq);
@@ -64,217 +62,159 @@ public class SecuredSeqTest extends SecuredContainerTest
@Override
@Test
- public void testAdd()
- {
+ public void testAdd() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredSeq().add(2, true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, 'c');
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, 3.14d);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, 3.14F);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, 3L);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
final Object o = Integer.MAX_VALUE;
getSecuredSeq().add(2, o);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, ResourceFactory.createResource());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, "Waa hoo");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().add(2, "dos", "es");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetAlt()
- {
- try
- {
+ public void testGetAlt() {
+ try {
final Alt a = getSecuredSeq().getAlt(1);
Assert.assertTrue("Should be a secured Alt",
a instanceof SecuredAlt);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetBag()
- {
- try
- {
+ public void testGetBag() {
+ try {
final Bag a = getSecuredSeq().getBag(1);
Assert.assertTrue("Should be a secured Bag",
a instanceof SecuredBag);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -282,23 +222,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetBoolean()
- {
+ public void testGetBoolean() {
seq.add(2, true);
- try
- {
+ try {
getSecuredSeq().getBoolean(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -306,23 +240,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetByte()
- {
+ public void testGetByte() {
seq.add(2, Byte.MAX_VALUE);
- try
- {
+ try {
getSecuredSeq().getByte(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -330,23 +258,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetChar()
- {
+ public void testGetChar() {
seq.add(2, 'c');
- try
- {
+ try {
getSecuredSeq().getChar(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -354,23 +276,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetDouble()
- {
+ public void testGetDouble() {
seq.add(2, 3.14D);
- try
- {
+ try {
getSecuredSeq().getDouble(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -378,23 +294,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetFloat()
- {
+ public void testGetFloat() {
seq.add(2, 3.14F);
- try
- {
+ try {
getSecuredSeq().getFloat(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -402,23 +312,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetInt()
- {
+ public void testGetInt() {
seq.add(2, 2);
- try
- {
+ try {
getSecuredSeq().getInt(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -426,23 +330,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetLanguage()
- {
+ public void testGetLanguage() {
seq.add(2, "foo");
- try
- {
+ try {
getSecuredSeq().getLanguage(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -450,23 +348,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetLiteral()
- {
+ public void testGetLiteral() {
seq.add(2, "foo");
- try
- {
+ try {
getSecuredSeq().getLiteral(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -474,23 +366,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetLong()
- {
+ public void testGetLong() {
seq.add(2, 2L);
- try
- {
+ try {
getSecuredSeq().getLong(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -498,24 +384,18 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetObject()
- {
+ public void testGetObject() {
final Object o = Integer.MAX_VALUE;
seq.add(2, o);
- try
- {
+ try {
getSecuredSeq().getObject(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -523,73 +403,35 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetResource()
- {
+ public void testGetResource() {
seq.add(2, ResourceFactory.createResource());
- try
- {
+ try {
getSecuredSeq().getResource(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
- /*
- * @Test
- * public void testGetChar()
- * {
- * ResourceF f;
- * seq.add( 2, 'c' );
- * try
- * {
- * getSecuredSeq().getResource(2, f );
- * if (!securityEvaluator.evaluate(Action.Read))
- * {
- * Assert.fail("Should have thrown AccessDenied Exception");
- * }
- * }
- * catch (final AccessDeniedException e)
- * {
- * if (securityEvaluator.evaluate(Action.Read))
- * {
- * Assert.fail(String
- * .format("Should not have thrown AccessDenied Exception: %s - %s",
- * e, e.getTriple()));
- * }
- * }
- *
- * }
- */
@Test
- public void testGetSeq()
- {
+ public void testGetSeq() {
seq.add(2, 'c');
- try
- {
+ try {
getSecuredSeq().getSeq(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -597,23 +439,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetShort()
- {
+ public void testGetShort() {
seq.add(2, Short.MAX_VALUE);
- try
- {
+ try {
getSecuredSeq().getShort(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -621,23 +457,17 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testGetString()
- {
+ public void testGetString() {
seq.add(2, "Waaa hoo");
- try
- {
+ try {
getSecuredSeq().getString(2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -645,171 +475,125 @@ public class SecuredSeqTest extends SecuredContainerTest
}
@Test
- public void testIndexOf()
- {
- try
- {
+ public void testIndexOf() {
+ try {
getSecuredSeq().indexOf(true);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf('c');
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf(3.14D);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf(3.14F);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf(3L);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
final Object o = Integer.MAX_VALUE;
getSecuredSeq().indexOf(o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq()
.indexOf(
ResourceFactory
.createResource("http://example.com/exampleResource"));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf("waaa hooo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().indexOf("dos", "es");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -818,193 +602,141 @@ public class SecuredSeqTest extends SecuredContainerTest
@Override
@Test
- public void testRemove()
- {
+ public void testRemove() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
getSecuredSeq().remove(1);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSet()
- {
+ public void testSet() {
final Set<Action> perms = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update });
- try
- {
+ try {
getSecuredSeq().set(1, true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, 'c');
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, 3.14d);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, 3.14F);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, 3L);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
final Object o = Integer.MAX_VALUE;
getSecuredSeq().set(1, o);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, ResourceFactory.createResource());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, "Waa hoo");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredSeq().set(1, "dos", "es");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredStatementTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredStatementTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredStatementTest.java
index b6a7737..63622b1 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredStatementTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredStatementTest.java
@@ -19,25 +19,26 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.Factory;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.model.SecuredModel;
import org.apache.jena.permissions.model.SecuredStatement;
import org.apache.jena.permissions.model.impl.SecuredStatementImpl;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.shared.PropertyNotFoundException ;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.shared.AccessDeniedException;
+import org.apache.jena.shared.PropertyNotFoundException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredStatementTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredStatementTest {
private final MockSecurityEvaluator securityEvaluator;
private Statement baseStatement;
private SecuredStatement securedStatement;
@@ -45,19 +46,16 @@ public class SecuredStatementTest
private SecuredModel securedModel;
private Property property;
- public SecuredStatementTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredStatementTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
}
- protected Model createModel()
- {
+ protected Model createModel() {
return ModelFactory.createDefaultModel();
}
@Before
- public void setup()
- {
+ public void setup() {
baseModel = createModel();
property = ResourceFactory
.createProperty("http://example.com/property");
@@ -73,209 +71,153 @@ public class SecuredStatementTest
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws AccessDeniedRuntimeException
*/
@Test
- public void testChangeLiteralObject()
- {
+ public void testChangeLiteralObject() {
final Set<Action> perms = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update });
- try
- {
+ try {
securedStatement.changeLiteralObject(true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeLiteralObject('c');
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeLiteralObject(3.14d);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeLiteralObject(3.14F);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeLiteralObject(2);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeLiteralObject(2L);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeObject(ResourceFactory.createResource());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeObject("Waaa hooo");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
final Literal l = ResourceFactory
.createTypedLiteral(Integer.MAX_VALUE);
securedStatement.changeObject(l.getLexicalForm(), true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeObject("dos", "es");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.changeObject("dos", "es", false);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -283,303 +225,229 @@ public class SecuredStatementTest
}
@Test
- public void testCreateReifiedStatement()
- {
+ public void testCreateReifiedStatement() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
securedStatement.createReifiedStatement();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedStatement.createReifiedStatement("http://example.com/rsURI");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetProperty()
- {
+ public void testGetProperty() {
// get property of the object
baseModel.add(baseStatement.getObject().asResource(), property,
ResourceFactory.createResource());
- try
- {
+ try {
securedStatement.getProperty(property);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown PropertyNotFound Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown PropertyNotFoundException Exception");
}
- }
- catch (final PropertyNotFoundException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final PropertyNotFoundException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown PropertyNotFound Exception: %s - %s",
+ .format("Should not have thrown PropertyNotFoundException Exception: %s - %s",
e, securityEvaluator));
}
}
}
@Test
- public void testGets()
- {
+ public void testGets() {
final Set<Action> perms = SecurityEvaluator.Util
.asSet(new Action[] { Action.Read });
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(true));
- try
- {
+ try {
securedStatement.getBoolean();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(Byte.MAX_VALUE));
- try
- {
+ try {
securedStatement.getByte();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject('c'));
- try
- {
+ try {
securedStatement.getChar();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(3.14d));
- try
- {
+ try {
securedStatement.getDouble();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(3.14F));
- try
- {
+ try {
securedStatement.getFloat();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(2));
- try
- {
+ try {
securedStatement.getInt();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeObject("dos", "es"));
- try
- {
+ try {
securedStatement.getLanguage();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(2L));
- try
- {
+ try {
securedStatement.getLong();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeLiteralObject(Short.MAX_VALUE));
- try
- {
+ try {
securedStatement.getShort();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeObject("who hoo"));
- try
- {
+ try {
securedStatement.getString();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
securedStatement = SecuredStatementImpl.getInstance(securedModel,
baseStatement.changeObject("who hoo"));
- try
- {
+ try {
securedStatement.hasWellFormedXML();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetStatementProperty()
- {
+ public void testGetStatementProperty() {
// get property of the subject
final ReifiedStatement s = baseStatement.createReifiedStatement();
s.addLiteral(property, "yee haw");
@@ -588,109 +456,84 @@ public class SecuredStatementTest
}
@Test
- public void testIsReified()
- {
+ public void testIsReified() {
final Set<Action> perms = SecurityEvaluator.Util
.asSet(new Action[] { Action.Read });
- try
- {
+ try {
securedStatement.isReified();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testListReifiedStatements()
- {
+ public void testListReifiedStatements() {
final Set<Action> perms = SecurityEvaluator.Util
.asSet(new Action[] { Action.Read });
- try
- {
+ try {
securedStatement.listReifiedStatements();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemove()
- {
+ public void testRemove() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
securedStatement.remove();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemoveReification()
- {
+ public void testRemoveReification() {
baseStatement.createReifiedStatement();
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
securedStatement.removeReification();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testUnsecuredGets()
- {
+ public void testUnsecuredGets() {
securedStatement.getAlt();
securedStatement.getBag();
securedStatement.getSeq();
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/query/DataSetTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/query/DataSetTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/query/DataSetTest.java
index b179da4..ae9fcba 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/query/DataSetTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/query/DataSetTest.java
@@ -22,11 +22,11 @@ import org.apache.jena.permissions.MockSecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.SecNode.Type;
import org.apache.jena.permissions.model.SecuredModel;
import org.apache.jena.permissions.query.SecuredQueryEngineFactory;
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.tdb.TDB ;
-import org.apache.jena.tdb.TDBFactory ;
+import org.apache.jena.query.*;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.tdb.TDB;
+import org.apache.jena.tdb.TDBFactory;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -37,57 +37,48 @@ public class DataSetTest {
private Model baseModel;
private MockSecurityEvaluator eval;
private SecuredModel dftModel;
-
+
@BeforeClass
- public static void setupFactory()
- {
+ public static void setupFactory() {
SecuredQueryEngineFactory.register();
}
@AfterClass
- public static void teardownFactory()
- {
+ public static void teardownFactory() {
SecuredQueryEngineFactory.unregister();
}
-
-
+
public void setup() {
-
- DatasetGraph dsg = TDBFactory.createDatasetGraph() ;
-
-
- dsg.getContext().set(TDB.symUnionDefaultGraph, true) ;
- Dataset myDataset = DatasetFactory.create(dsg) ;
-
-// DatasetGraph dsg = DatasetGraphFactory.createMem() ;
-//
-// Dataset myDataset = TDBFactory.createDataset();
- baseModel = myDataset.getNamedModel( "http://example.com/baseModel");
- //baseModel = myDataset.getDefaultModel();
- baseModel = QueryEngineTest.populateModel( baseModel );
-
- dftModel = Factory.getInstance(eval,
- "http://example.com/securedModel", baseModel);
-
- dataset = DatasetFactory.createMem() ;
- dataset.setDefaultModel(dftModel) ;
-
-// // dataset.addNamedModel( dftModel.getModelIRI(), dftModel);
-
-
-
+
+ DatasetGraph dsg = TDBFactory.createDatasetGraph();
+
+ dsg.getContext().set(TDB.symUnionDefaultGraph, true);
+ Dataset myDataset = DatasetFactory.create(dsg);
+
+ // DatasetGraph dsg = DatasetGraphFactory.createMem() ;
+ //
+ // Dataset myDataset = TDBFactory.createDataset();
+ baseModel = myDataset.getNamedModel("http://example.com/baseModel");
+ // baseModel = myDataset.getDefaultModel();
+ baseModel = QueryEngineTest.populateModel(baseModel);
+
+ dftModel = Factory.getInstance(eval, "http://example.com/securedModel",
+ baseModel);
+
+ dataset = DatasetFactory.createMem();
+ dataset.setDefaultModel(dftModel);
+
+ // // dataset.addNamedModel( dftModel.getModelIRI(), dftModel);
+
}
-
+
@Test
- public void testOpenQueryType()
- {
- eval = new MockSecurityEvaluator(true, true,
- true, true, true, true);
-
+ public void testOpenQueryType() {
+ eval = new MockSecurityEvaluator(true, true, true, true, true, true);
+
setup();
-
- try
- {
+
+ try {
final String query = "prefix fn: <http://www.w3.org/2005/xpath-functions#> "
+ " SELECT ?foo ?bar WHERE "
+ " { ?foo a <http://example.com/class> ; "
@@ -95,51 +86,41 @@ public class DataSetTest {
+ " } ";
final QueryExecution qexec = QueryExecutionFactory.create(query,
dataset);
- try
- {
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
final QuerySolution soln = results.nextSolution();
}
Assert.assertEquals(8, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
- }
- finally
- {
+ } finally {
dataset.close();
}
}
@Test
- public void testRestrictedQueryType()
- {
- eval = new MockSecurityEvaluator(true, true,
- true, true, true, true) {
+ public void testRestrictedQueryType() {
+ eval = new MockSecurityEvaluator(true, true, true, true, true, true) {
@Override
- public boolean evaluate( final Object principal, final Action action,
- final SecNode graphIRI, final SecTriple triple )
- {
+ public boolean evaluate(final Object principal,
+ final Action action, final SecNode graphIRI,
+ final SecTriple triple) {
if (triple.getSubject().equals(
- new SecNode(Type.URI, "http://example.com/resource/1")))
- {
+ new SecNode(Type.URI, "http://example.com/resource/1"))) {
return false;
}
return super.evaluate(principal, action, graphIRI, triple);
}
};
-
+
setup();
-
- try
- {
+
+ try {
final String query = "prefix fn: <http://www.w3.org/2005/xpath-functions#> "
+ " SELECT ?foo ?bar WHERE "
+ " { ?foo a <http://example.com/class> ; "
@@ -147,98 +128,74 @@ public class DataSetTest {
+ " } ";
final QueryExecution qexec = QueryExecutionFactory.create(query,
dataset);
- try
- {
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
results.nextSolution();
}
Assert.assertEquals(4, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
- }
- finally
- {
+ } finally {
dataset.close();
}
}
-
+
@Test
- public void testSelectAllType()
- {
- eval = new MockSecurityEvaluator(true, true,
- true, true, true, true) {
+ public void testSelectAllType() {
+ eval = new MockSecurityEvaluator(true, true, true, true, true, true) {
@Override
- public boolean evaluate( final Object principal, final Action action,
- final SecNode graphIRI, final SecTriple triple )
- {
+ public boolean evaluate(final Object principal,
+ final Action action, final SecNode graphIRI,
+ final SecTriple triple) {
if (triple.getSubject().equals(
- new SecNode(Type.URI, "http://example.com/resource/1")))
- {
+ new SecNode(Type.URI, "http://example.com/resource/1"))) {
return false;
}
return super.evaluate(principal, action, graphIRI, triple);
}
};
-
+
setup();
-
- try
- {
- String query = "SELECT ?s ?p ?o WHERE "
- + " { ?s ?p ?o } ";
- QueryExecution qexec = QueryExecutionFactory.create(query,
- dataset);
- try
- {
+
+ try {
+ String query = "SELECT ?s ?p ?o WHERE " + " { ?s ?p ?o } ";
+ QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
final QuerySolution soln = results.nextSolution();
- //System.out.println( soln );
+ // System.out.println( soln );
}
// 2x 3 values + type triple
Assert.assertEquals(8, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
-
- query = "SELECT ?g ?s ?p ?o WHERE "
- + " { GRAPH ?g {?s ?p ?o } }";
- qexec = QueryExecutionFactory.create(query,
- dataset);
- try
- {
+
+ query = "SELECT ?g ?s ?p ?o WHERE " + " { GRAPH ?g {?s ?p ?o } }";
+ qexec = QueryExecutionFactory.create(query, dataset);
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
final QuerySolution soln = results.nextSolution();
- //System.out.println( soln );
+ // System.out.println( soln );
}
// 2x 3 values + type triple
// all are in the base graph so no named graphs
Assert.assertEquals(0, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
- }
- finally
- {
+ } finally {
dataset.close();
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/query/QueryEngineTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/query/QueryEngineTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/query/QueryEngineTest.java
index 11999a1..5d7172d 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/query/QueryEngineTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/query/QueryEngineTest.java
@@ -23,15 +23,15 @@ import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.SecNode.Type;
import org.apache.jena.permissions.model.SecuredModel;
import org.apache.jena.permissions.query.SecuredQueryEngineFactory;
-import org.apache.jena.query.QueryExecution ;
-import org.apache.jena.query.QueryExecutionFactory ;
-import org.apache.jena.query.QuerySolution ;
-import org.apache.jena.query.ResultSet ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.rdf.model.Resource ;
-import org.apache.jena.rdf.model.ResourceFactory ;
-import org.apache.jena.vocabulary.RDF ;
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.query.QueryExecutionFactory;
+import org.apache.jena.query.QuerySolution;
+import org.apache.jena.query.ResultSet;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -57,9 +57,7 @@ public class QueryEngineTest {
}
-
- public static Model populateModel(Model baseModel)
- {
+ public static Model populateModel(Model baseModel) {
Resource r = ResourceFactory
.createResource("http://example.com/resource/1");
@@ -101,11 +99,10 @@ public class QueryEngineTest {
ResourceFactory.createTypedLiteral(9.42));
return baseModel;
}
-
+
@Before
- public void setUp()
- {
- baseModel = populateModel( ModelFactory.createDefaultModel());
+ public void setUp() {
+ baseModel = populateModel(ModelFactory.createDefaultModel());
}
@After
@@ -186,18 +183,15 @@ public class QueryEngineTest {
}
@Test
- public void testSelectAllType()
- {
+ public void testSelectAllType() {
final SecurityEvaluator eval = new MockSecurityEvaluator(true, true,
true, true, true, true) {
@Override
public boolean evaluate(Object principal, final Action action,
- final SecNode graphIRI, final SecTriple triple )
- {
+ final SecNode graphIRI, final SecTriple triple) {
if (triple.getSubject().equals(
- new SecNode(Type.URI, "http://example.com/resource/1")))
- {
+ new SecNode(Type.URI, "http://example.com/resource/1"))) {
return false;
}
return super.evaluate(principal, action, graphIRI, triple);
@@ -205,55 +199,40 @@ public class QueryEngineTest {
};
final SecuredModel model = Factory.getInstance(eval,
"http://example.com/securedModel", baseModel);
- try
- {
- String query = "SELECT ?s ?p ?o WHERE "
- + " { ?s ?p ?o } ";
- QueryExecution qexec = QueryExecutionFactory.create(query,
- model);
- try
- {
+ try {
+ String query = "SELECT ?s ?p ?o WHERE " + " { ?s ?p ?o } ";
+ QueryExecution qexec = QueryExecutionFactory.create(query, model);
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
final QuerySolution soln = results.nextSolution();
- //System.out.println( soln );
+ // System.out.println( soln );
}
// 2x 3 values + type triple
Assert.assertEquals(8, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
-
- query = "SELECT ?s ?p ?o WHERE "
- + " { GRAPH ?g {?s ?p ?o } }";
- qexec = QueryExecutionFactory.create(query,
- model);
- try
- {
+
+ query = "SELECT ?s ?p ?o WHERE " + " { GRAPH ?g {?s ?p ?o } }";
+ qexec = QueryExecutionFactory.create(query, model);
+ try {
final ResultSet results = qexec.execSelect();
int count = 0;
- for (; results.hasNext();)
- {
+ for (; results.hasNext();) {
count++;
final QuerySolution soln = results.nextSolution();
- //System.out.println( soln );
+ // System.out.println( soln );
}
// 2x 3 values + type triple
// no named graphs so no results.
Assert.assertEquals(0, count);
- }
- finally
- {
+ } finally {
qexec.close();
}
- }
- finally
- {
+ } finally {
model.close();
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/query/rewriter/OpRewriterTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/query/rewriter/OpRewriterTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/query/rewriter/OpRewriterTest.java
index 3e5d0d4..f9b8326 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/query/rewriter/OpRewriterTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/query/rewriter/OpRewriterTest.java
@@ -19,92 +19,100 @@ package org.apache.jena.permissions.query.rewriter;
import java.util.Arrays;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.query.rewriter.OpRewriter;
import org.apache.jena.permissions.query.rewriter.SecuredFunction;
-import org.apache.jena.sparql.algebra.Op ;
-import org.apache.jena.sparql.algebra.op.OpBGP ;
-import org.apache.jena.sparql.algebra.op.OpFilter ;
-import org.apache.jena.sparql.core.BasicPattern ;
-import org.apache.jena.sparql.expr.ExprList ;
-import org.apache.jena.vocabulary.RDF ;
+import org.apache.jena.sparql.algebra.Op;
+import org.apache.jena.sparql.algebra.op.OpBGP;
+import org.apache.jena.sparql.algebra.op.OpFilter;
+import org.apache.jena.sparql.core.BasicPattern;
+import org.apache.jena.sparql.expr.ExprList;
+import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class OpRewriterTest
-{
+public class OpRewriterTest {
private OpRewriter rewriter;
private Triple[] triples;
-
- public OpRewriterTest()
- {
+
+ public OpRewriterTest() {
}
-
+
@Before
- public void setup()
- {
+ public void setup() {
triples = new Triple[] {
- new Triple( NodeFactory.createVariable("foo"), RDF.type.asNode(), NodeFactory.createURI( "http://example.com/class")),
- new Triple( NodeFactory.createVariable("foo"), NodeFactory.createAnon(), NodeFactory.createVariable("bar")),
- new Triple( NodeFactory.createVariable("bar"), NodeFactory.createAnon(), NodeFactory.createVariable("baz")),
- };
+ new Triple(NodeFactory.createVariable("foo"),
+ RDF.type.asNode(),
+ NodeFactory.createURI("http://example.com/class")),
+ new Triple(NodeFactory.createVariable("foo"),
+ NodeFactory.createAnon(),
+ NodeFactory.createVariable("bar")),
+ new Triple(NodeFactory.createVariable("bar"),
+ NodeFactory.createAnon(),
+ NodeFactory.createVariable("baz")), };
}
-
+
@Test
- public void testBGP()
- {
- SecurityEvaluator securityEvaluator = new MockSecurityEvaluator( true, true, true, true, true, true );
- rewriter = new OpRewriter( securityEvaluator, "http://example.com/dummy");
-
- rewriter.visit( new OpBGP( BasicPattern.wrap(Arrays.asList(triples))));
+ public void testBGP() {
+ SecurityEvaluator securityEvaluator = new MockSecurityEvaluator(true,
+ true, true, true, true, true);
+ rewriter = new OpRewriter(securityEvaluator, "http://example.com/dummy");
+
+ rewriter.visit(new OpBGP(BasicPattern.wrap(Arrays.asList(triples))));
Op op = rewriter.getResult();
- Assert.assertTrue( "Should have been an OpFilter", op instanceof OpFilter );
+ Assert.assertTrue("Should have been an OpFilter",
+ op instanceof OpFilter);
OpFilter filter = (OpFilter) op;
ExprList eLst = filter.getExprs();
- Assert.assertEquals( 1, eLst.size());
- Assert.assertTrue( "Should have been a SecuredFunction", eLst.get(0) instanceof SecuredFunction);
+ Assert.assertEquals(1, eLst.size());
+ Assert.assertTrue("Should have been a SecuredFunction",
+ eLst.get(0) instanceof SecuredFunction);
op = filter.getSubOp();
- Assert.assertTrue( "Should have been a OpBGP", op instanceof OpBGP);
- BasicPattern basicPattern = ((OpBGP)op).getPattern();
- Assert.assertEquals( 3, basicPattern.size() );
-
+ Assert.assertTrue("Should have been a OpBGP", op instanceof OpBGP);
+ BasicPattern basicPattern = ((OpBGP) op).getPattern();
+ Assert.assertEquals(3, basicPattern.size());
+
Triple t = basicPattern.get(0);
- Assert.assertEquals( NodeFactory.createVariable("foo"), t.getSubject());
- Assert.assertEquals( RDF.type.asNode(), t.getPredicate());
- Assert.assertEquals( NodeFactory.createURI( "http://example.com/class"), t.getObject());
-
+ Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
+ Assert.assertEquals(RDF.type.asNode(), t.getPredicate());
+ Assert.assertEquals(NodeFactory.createURI("http://example.com/class"),
+ t.getObject());
+
t = basicPattern.get(1);
- Assert.assertEquals( NodeFactory.createVariable("foo"), t.getSubject());
- Assert.assertTrue( "Should have been blank", t.getPredicate().isBlank());
- Assert.assertEquals( NodeFactory.createVariable("bar"), t.getObject());
-
+ Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
+ Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
+ Assert.assertEquals(NodeFactory.createVariable("bar"), t.getObject());
+
t = basicPattern.get(2);
- Assert.assertEquals( NodeFactory.createVariable("bar"), t.getSubject() );
- Assert.assertTrue( "Should have been blank", t.getPredicate().isBlank());
- Assert.assertEquals( NodeFactory.createVariable("baz"), t.getObject());
+ Assert.assertEquals(NodeFactory.createVariable("bar"), t.getSubject());
+ Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
+ Assert.assertEquals(NodeFactory.createVariable("baz"), t.getObject());
}
-
+
@Test
- public void testBGPNoReadAccess()
- {
- SecurityEvaluator securityEvaluator = new MockSecurityEvaluator( true, true, false, true, true, true );
- rewriter = new OpRewriter( securityEvaluator, "http://example.com/dummy");
+ public void testBGPNoReadAccess() {
+ SecurityEvaluator securityEvaluator = new MockSecurityEvaluator(true,
+ true, false, true, true, true);
+ rewriter = new OpRewriter(securityEvaluator, "http://example.com/dummy");
Triple[] triples = {
- new Triple( NodeFactory.createVariable("foo"), RDF.type.asNode(), NodeFactory.createURI( "http://example.com/class")),
- new Triple( NodeFactory.createVariable("foo"), NodeFactory.createAnon(), NodeFactory.createVariable("bar")),
- new Triple( NodeFactory.createVariable("bar"), NodeFactory.createAnon(), NodeFactory.createVariable("baz")),
- };
+ new Triple(NodeFactory.createVariable("foo"),
+ RDF.type.asNode(),
+ NodeFactory.createURI("http://example.com/class")),
+ new Triple(NodeFactory.createVariable("foo"),
+ NodeFactory.createAnon(),
+ NodeFactory.createVariable("bar")),
+ new Triple(NodeFactory.createVariable("bar"),
+ NodeFactory.createAnon(),
+ NodeFactory.createVariable("baz")), };
try {
- rewriter.visit( new OpBGP( BasicPattern.wrap(Arrays.asList(triples))));
- Assert.fail( "Should have thrown AccessDeniedException");
- }
- catch (AccessDeniedException e)
- {
+ rewriter.visit(new OpBGP(BasicPattern.wrap(Arrays.asList(triples))));
+ Assert.fail("Should have thrown AccessDeniedException");
+ } catch (ReadDeniedException e) {
// expected
}
}
[06/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
index 7ce88b4..329e511 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
@@ -17,10 +17,13 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
+
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.rdf.model.RDFNode ;
import org.apache.jena.rdf.model.ResourceF ;
import org.apache.jena.rdf.model.Seq ;
+import org.apache.jena.shared.DeleteDeniedException;
/**
* The interface for secured Seq instances.
@@ -33,353 +36,408 @@ import org.apache.jena.rdf.model.Seq ;
*/
public interface SecuredSeq extends Seq, SecuredContainer
{
- /**
+ /** *
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final boolean o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final char o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final double o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final float o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final long o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final Object o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final String o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final String o, final String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public SecuredAlt getAlt( final int index ) throws AccessDeniedException;
+ public SecuredAlt getAlt( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public SecuredBag getBag( final int index ) throws AccessDeniedException;
+ public SecuredBag getBag( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public boolean getBoolean( final int index ) throws AccessDeniedException;
+ public boolean getBoolean( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public byte getByte( final int index ) throws AccessDeniedException;
+ public byte getByte( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public char getChar( final int index ) throws AccessDeniedException;
+ public char getChar( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public double getDouble( final int index ) throws AccessDeniedException;
+ public double getDouble( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public float getFloat( final int index ) throws AccessDeniedException;
+ public float getFloat( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int getInt( final int index ) throws AccessDeniedException;
+ public int getInt( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public String getLanguage( final int index ) throws AccessDeniedException;
+ public String getLanguage( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
public SecuredLiteral getLiteral( final int index )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public long getLong( final int index ) throws AccessDeniedException;
+ public long getLong( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
public SecuredRDFNode getObject( final int index )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
public SecuredResource getResource( final int index )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
@Deprecated
public SecuredResource getResource( final int index, final ResourceF f )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public SecuredSeq getSeq( final int index ) throws AccessDeniedException;
+ public SecuredSeq getSeq( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public short getShort( final int index ) throws AccessDeniedException;
+ public short getShort( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public String getString( final int index ) throws AccessDeniedException;
+ public String getString( final int index ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final boolean o ) throws AccessDeniedException;
+ public int indexOf( final boolean o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final char o ) throws AccessDeniedException;
+ public int indexOf( final char o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final double o ) throws AccessDeniedException;
+ public int indexOf( final double o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final float o ) throws AccessDeniedException;
+ public int indexOf( final float o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final long o ) throws AccessDeniedException;
+ public int indexOf( final long o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final Object o ) throws AccessDeniedException;
+ public int indexOf( final Object o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final RDFNode o ) throws AccessDeniedException;
+ public int indexOf( final RDFNode o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
- public int indexOf( final String o ) throws AccessDeniedException;
+ public int indexOf( final String o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( this, RDF.li(1), o )
+ * @throws ReadDeniedException
*/
@Override
public int indexOf( final String o, final String l )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete SecTriple( this, RDF.li(1), o )
* @sec.triple Update Triples after index
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredSeq remove( final int index ) throws AccessDeniedException;
+ public SecuredSeq remove( final int index ) throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final boolean o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final char o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final double o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final float o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final long o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final Object o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final String o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update SecTriple( this, RDF.li(index), old ) SecTriple( this,
* RDF.li(index), o )
+ * @throws UpdateDeniedException
*/
@Override
public SecuredSeq set( final int index, final String o, final String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredStatement.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredStatement.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredStatement.java
index c10a9a2..ba610be 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredStatement.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredStatement.java
@@ -17,9 +17,13 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
+
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.rdf.model.* ;
+import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
/**
* The interface for secured Statement instances.
@@ -31,119 +35,123 @@ public interface SecuredStatement extends Statement, SecuredItem
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( boolean o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( char o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( double o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( float o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( int o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeLiteralObject( long o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
- * @sec.triple update
- * @throws AccessDeniedException
+ * @sec.triple Update
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeObject( RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeObject( String o )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeObject( String o, boolean wellFormed )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeObject( String o, String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredStatement changeObject( String o, String l, boolean wellFormed )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Read, Update
* @sec.triple Create
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredReifiedStatement createReifiedStatement()
- throws AccessDeniedException;
+ throws ReadDeniedException, UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Read, Update
* @sec.triple Create
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredReifiedStatement createReifiedStatement( String uri )
- throws AccessDeniedException;
+ throws ReadDeniedException, UpdateDeniedException, AddDeniedException;
@Override
public SecuredAlt getAlt();
@@ -153,62 +161,62 @@ public interface SecuredStatement extends Statement, SecuredItem
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean getBoolean() throws AccessDeniedException;
+ public boolean getBoolean() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public byte getByte() throws AccessDeniedException;
+ public byte getByte() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public char getChar() throws AccessDeniedException;
+ public char getChar() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public double getDouble() throws AccessDeniedException;
+ public double getDouble() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public float getFloat() throws AccessDeniedException;
+ public float getFloat() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public int getInt() throws AccessDeniedException;
+ public int getInt() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getLanguage() throws AccessDeniedException;
+ public String getLanguage() throws ReadDeniedException;
@Override
public SecuredLiteral getLiteral();
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public long getLong() throws AccessDeniedException;
+ public long getLong() throws ReadDeniedException;
@Override
public SecuredModel getModel();
@@ -234,20 +242,20 @@ public interface SecuredStatement extends Statement, SecuredItem
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public short getShort() throws AccessDeniedException;
+ public short getShort() throws ReadDeniedException;
@Override
public SecuredStatement getStatementProperty( Property p );
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getString() throws AccessDeniedException;
+ public String getString() throws ReadDeniedException;
@Override
public SecuredResource getSubject();
@@ -255,41 +263,43 @@ public interface SecuredStatement extends Statement, SecuredItem
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean hasWellFormedXML() throws AccessDeniedException;
+ public boolean hasWellFormedXML() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isReified() throws AccessDeniedException;
+ public boolean isReified() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public RSIterator listReifiedStatements() throws AccessDeniedException;
+ public RSIterator listReifiedStatements() throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredStatement remove() throws AccessDeniedException;
+ public SecuredStatement remove() throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public void removeReification() throws AccessDeniedException;
+ public void removeReification() throws UpdateDeniedException, DeleteDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
index 37d856b..8810487 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
@@ -27,7 +27,6 @@ import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.graph.Triple ;
import org.apache.jena.graph.impl.CollectionGraph ;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.SecTriple;
import org.apache.jena.permissions.graph.SecuredGraph;
@@ -2073,20 +2072,20 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
public SecuredModel read( final InputStream in, final String base )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader().read(holder.getSecuredItem(), in, base);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
@@ -2094,40 +2093,40 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
final String lang )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader(lang).read(holder.getSecuredItem(), in, base);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
public SecuredModel read( final Reader reader, final String base )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader().read(holder.getSecuredItem(), reader, base);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
@@ -2135,61 +2134,61 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
final String lang )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader(lang).read(holder.getSecuredItem(), reader,
base);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
public SecuredModel read( final String url )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader().read(holder.getSecuredItem(), url);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
public SecuredModel read( final String url, final String lang )
{
checkUpdate();
- try
- {
+// try
+// {
SecuredModelImpl.readerFactory.getReader(lang).read(holder.getSecuredItem(), url);
return holder.getSecuredItem();
- }
- catch (final JenaException e)
- {
- if ((e.getCause() != null)
- && (e.getCause() instanceof AccessDeniedException))
- {
- throw (AccessDeniedException) e.getCause();
- }
- throw e;
- }
+// }
+// catch (final JenaException e)
+// {
+// if ((e.getCause() != null)
+// && (e.getCause() instanceof AccessDeniedRuntimeException))
+// {
+// throw (AccessDeniedRuntimeException) e.getCause();
+// }
+// throw e;
+// }
}
@Override
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRDFListImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRDFListImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRDFListImpl.java
index 8056c1e..7db89b5 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRDFListImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRDFListImpl.java
@@ -26,10 +26,10 @@ import java.util.function.Function;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.impl.ItemHolder;
+import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.permissions.impl.SecuredItemImpl;
import org.apache.jena.permissions.impl.SecuredItemInvoker;
import org.apache.jena.permissions.model.SecuredModel;
@@ -38,6 +38,7 @@ import org.apache.jena.permissions.model.SecuredRDFNode;
import org.apache.jena.permissions.utils.RDFListIterator;
import org.apache.jena.permissions.utils.RDFListSecFilter;
import org.apache.jena.rdf.model.* ;
+import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.util.iterator.ExtendedIterator ;
import org.apache.jena.util.iterator.WrappedIterator ;
import org.apache.jena.vocabulary.RDF ;
@@ -767,7 +768,7 @@ public class SecuredRDFListImpl extends SecuredResourceImpl implements
@Override
public Object reduce( final Set<Action> requiredActions, final ReduceFn fn,
- final Object initial ) throws AccessDeniedException,
+ final Object initial ) throws
EmptyListException, ListIndexException, InvalidListException
{
Object acc = initial;
@@ -815,7 +816,7 @@ public class SecuredRDFListImpl extends SecuredResourceImpl implements
}
if (denied)
{
- throw new AccessDeniedException(getModelNode(), Action.Delete);
+ throw new DeleteDeniedException(SecuredItem.Util.triplePermissionMsg(getModelNode()));
}
else
{
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
index 3a19867..7f6c511 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
@@ -21,9 +21,10 @@ import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.impl.ItemHolder;
+import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.permissions.impl.SecuredItemImpl;
import org.apache.jena.permissions.impl.SecuredItemInvoker;
import org.apache.jena.permissions.model.SecuredModel;
@@ -356,10 +357,9 @@ public class SecuredResourceImpl extends SecuredRDFNodeImpl implements
{
if (!canReadProperty(p))
{
- throw new AccessDeniedException(getModelNode(), SecuredItemImpl
- .convert(
- new Triple(holder.getBaseItem().asNode(), p,
- Node.ANY)).toString(), Action.Read);
+ throw new ReadDeniedException(SecuredItem.Util.triplePermissionMsg(getModelNode()),
+ new Triple(holder.getBaseItem().asNode(), p,
+ Node.ANY));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/query/rewriter/OpRewriter.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/query/rewriter/OpRewriter.java b/jena-permissions/src/main/java/org/apache/jena/permissions/query/rewriter/OpRewriter.java
index 925bc5b..2fea0ad 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/query/rewriter/OpRewriter.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/query/rewriter/OpRewriter.java
@@ -22,11 +22,12 @@ import java.util.List;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.SecurityEvaluator.SecNode;
import org.apache.jena.permissions.SecurityEvaluator.SecTriple;
+import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.permissions.impl.SecuredItemImpl;
import org.apache.jena.sparql.algebra.Op ;
import org.apache.jena.sparql.algebra.OpVisitor ;
@@ -217,7 +218,7 @@ public class OpRewriter implements OpVisitor
}
else
{
- throw new AccessDeniedException(graphIRI, Action.Read);
+ throw new ReadDeniedException(SecuredItem.Util.modelPermissionMsg(graphIRI));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
index e3544e0..e9af258 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
@@ -17,14 +17,14 @@
*/
package org.apache.jena.permissions.graph;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.GraphEventManager ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphEventManager;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
import org.apache.jena.permissions.Factory;
import org.apache.jena.permissions.StaticSecurityEvaluator;
import org.apache.jena.permissions.graph.SecuredGraph;
-import org.apache.jena.sparql.graph.GraphFactory ;
+import org.apache.jena.sparql.graph.GraphFactory;
import org.junit.Assert;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
index 4a99c5c..8e01cf9 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
@@ -17,21 +17,19 @@
*/
package org.apache.jena.permissions.graph;
-import java.util.Arrays;
import java.util.Set;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.GraphEventManager ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.graph.impl.CollectionGraph ;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphEventManager;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
import org.apache.jena.permissions.Factory;
import org.apache.jena.permissions.MockSecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.graph.SecuredGraph;
-import org.apache.jena.sparql.graph.GraphFactory ;
+import org.apache.jena.sparql.graph.GraphFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -41,9 +39,8 @@ import org.junit.runner.RunWith;
* Verifies that messages are properly filtered when sent to listeners.
*
*/
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class GraphEventManagerTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class GraphEventManagerTest {
private final GraphEventManager manager;
private final Graph g;
private final SecuredGraph sg;
@@ -52,8 +49,7 @@ public class GraphEventManagerTest
private final RecordingGraphListener listener;
- public GraphEventManagerTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public GraphEventManagerTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
g = GraphFactory.createDefaultGraph();
@@ -67,18 +63,14 @@ public class GraphEventManagerTest
@Test
@SuppressWarnings("deprecation")
- public void notifyAddTest()
- {
+ public void notifyAddTest() {
Object principal = securityEvaluator.getPrincipal();
final Set<Action> ADD = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Read });
g.add(tripleArray[0]);
- if (securityEvaluator.evaluateAny(principal, ADD, sg.getModelNode()))
- {
+ if (securityEvaluator.evaluateAny(principal, ADD, sg.getModelNode())) {
Assert.assertTrue("Should recorded add", listener.isAdd());
- }
- else
- {
+ } else {
Assert.assertFalse("Should not have recorded add", listener.isAdd());
}
g.delete(Triple.ANY);
@@ -87,32 +79,26 @@ public class GraphEventManagerTest
}
@SuppressWarnings("deprecation")
- @Test
- public void notifyDeleteTest()
- {
+ @Test
+ public void notifyDeleteTest() {
Object principal = securityEvaluator.getPrincipal();
final Set<Action> DELETE = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Read });
g.delete(tripleArray[0]);
- if (securityEvaluator.evaluateAny(principal, DELETE, sg.getModelNode()))
- {
+ if (securityEvaluator.evaluateAny(principal, DELETE, sg.getModelNode())) {
Assert.assertTrue("Should have recorded delete",
listener.isDelete());
- }
- else
- {
+ } else {
Assert.assertFalse("Should not have recorded delete",
listener.isDelete());
}
listener.reset();
-
}
@Test
- public void notifyEventTest()
- {
+ public void notifyEventTest() {
g.getEventManager().notifyEvent(g, "Foo");
Assert.assertTrue("Should recorded delete", listener.isEvent());
listener.reset();
@@ -127,8 +113,7 @@ public class GraphEventManagerTest
}
@Before
- public void setup()
- {
+ public void setup() {
tripleArray = new Triple[] {
new Triple(NodeFactory.createURI("http://example.com/1"),
NodeFactory.createURI("http://example.com/v"),
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
index bc086b4..fb1d862 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
@@ -17,26 +17,25 @@
*/
package org.apache.jena.permissions.graph;
-import java.lang.reflect.Method;
import java.util.Set;
-import org.apache.jena.graph.* ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.graph.*;
import org.apache.jena.permissions.EqualityTester;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.graph.SecuredGraph;
-import org.apache.jena.sparql.graph.GraphFactory ;
+import org.apache.jena.shared.AccessDeniedException;
+import org.apache.jena.sparql.graph.GraphFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class MemGraphTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class MemGraphTest {
private SecuredGraph securedGraph;
private final MockSecurityEvaluator securityEvaluator;
private Node s;
@@ -46,20 +45,17 @@ public class MemGraphTest
private Graph baseGraph;
- public MemGraphTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public MemGraphTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
}
- protected Graph createGraph() throws Exception
- {
+ protected Graph createGraph() throws Exception {
return GraphFactory.createDefaultGraph();
}
@SuppressWarnings("deprecation")
- @Before
- public void setUp() throws Exception
- {
+ @Before
+ public void setUp() throws Exception {
baseGraph = createGraph();
baseGraph.remove(Node.ANY, Node.ANY, Node.ANY);
securedGraph = org.apache.jena.permissions.Factory
@@ -73,44 +69,32 @@ public class MemGraphTest
}
@Test
- public void testContainsNodes() throws Exception
- {
- try
- {
+ public void testContainsNodes() throws Exception {
+ try {
Assert.assertTrue(securedGraph.contains(s, p, o));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testContainsTriple() throws Exception
- {
- try
- {
+ public void testContainsTriple() throws Exception {
+ try {
Assert.assertTrue(securedGraph.contains(t));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -118,25 +102,19 @@ public class MemGraphTest
}
@Test
- public void testDelete() throws Exception
- {
+ public void testDelete() throws Exception {
final Set<Action> UD = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
securedGraph.delete(t);
- if (!securityEvaluator.evaluate(UD))
- {
+ if (!securityEvaluator.evaluate(UD)) {
Assert.fail("Should have thrown AccessDenied Exception");
}
Assert.assertEquals(0, baseGraph.size());
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(UD))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(UD)) {
Assert.fail(String
.format("Should not have thrown AccessDenied Exception: %s - %s",
e, e.getTriple()));
@@ -145,101 +123,76 @@ public class MemGraphTest
}
@Test
- public void testDependsOn() throws Exception
- {
- try
- {
+ public void testDependsOn() throws Exception {
+ try {
Assert.assertFalse(securedGraph.dependsOn(GraphFactory
.createDefaultGraph()));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
Assert.assertTrue(securedGraph.dependsOn(baseGraph));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testFindNodes() throws Exception
- {
- try
- {
+ public void testFindNodes() throws Exception {
+ try {
Assert.assertFalse(securedGraph.find(Node.ANY, Node.ANY, Node.ANY)
.toList().isEmpty());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testFindTriple() throws Exception
- {
- try
- {
+ public void testFindTriple() throws Exception {
+ try {
Assert.assertFalse(securedGraph.find(t).toList().isEmpty());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetPrefixMapping() throws Exception
- {
+ public void testGetPrefixMapping() throws Exception {
SecuredPrefixMappingTest.runTests(securityEvaluator,
securedGraph.getPrefixMapping());
}
@Test
- public void testInequality()
- {
+ public void testInequality() {
EqualityTester
.testInequality("proxy and base", securedGraph, baseGraph);
final Graph g2 = org.apache.jena.permissions.graph.impl.Factory
@@ -250,62 +203,45 @@ public class MemGraphTest
}
@Test
- public void testIsIsomorphicWith() throws Exception
- {
- try
- {
+ public void testIsIsomorphicWith() throws Exception {
+ try {
Assert.assertFalse(securedGraph.isIsomorphicWith(GraphFactory
.createDefaultGraph()));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
Assert.assertTrue(securedGraph.isIsomorphicWith(baseGraph));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSize() throws Exception
- {
- try
- {
+ public void testSize() throws Exception {
+ try {
Assert.assertEquals(1, securedGraph.size());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
index 5a75461..0346aff 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
@@ -3,9 +3,9 @@ package org.apache.jena.permissions.graph;
import java.util.Iterator;
import java.util.List;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.GraphListener ;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphListener;
+import org.apache.jena.graph.Triple;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -25,97 +25,80 @@ import org.apache.jena.graph.Triple ;
* limitations under the License.
*/
-public class RecordingGraphListener implements GraphListener
-{
+public class RecordingGraphListener implements GraphListener {
private boolean add;
private boolean delete;
private boolean event;
- public boolean isAdd()
- {
+ public boolean isAdd() {
return add;
}
- public boolean isDelete()
- {
+ public boolean isDelete() {
return delete;
}
- public boolean isEvent()
- {
+ public boolean isEvent() {
return event;
}
@Override
- public void notifyAddArray( final Graph g, final Triple[] triples )
- {
+ public void notifyAddArray(final Graph g, final Triple[] triples) {
add = true;
}
@Override
- public void notifyAddGraph( final Graph g, final Graph added )
- {
+ public void notifyAddGraph(final Graph g, final Graph added) {
add = true;
}
@Override
- public void notifyAddIterator( final Graph g, final Iterator<Triple> it )
- {
+ public void notifyAddIterator(final Graph g, final Iterator<Triple> it) {
add = true;
}
@Override
- public void notifyAddList( final Graph g, final List<Triple> triples )
- {
+ public void notifyAddList(final Graph g, final List<Triple> triples) {
add = true;
}
@Override
- public void notifyAddTriple( final Graph g, final Triple t )
- {
+ public void notifyAddTriple(final Graph g, final Triple t) {
add = true;
}
@Override
- public void notifyDeleteArray( final Graph g, final Triple[] triples )
- {
+ public void notifyDeleteArray(final Graph g, final Triple[] triples) {
delete = true;
}
@Override
- public void notifyDeleteGraph( final Graph g, final Graph removed )
- {
+ public void notifyDeleteGraph(final Graph g, final Graph removed) {
delete = true;
}
@Override
- public void notifyDeleteIterator( final Graph g,
- final Iterator<Triple> it )
- {
+ public void notifyDeleteIterator(final Graph g, final Iterator<Triple> it) {
delete = true;
}
@Override
- public void notifyDeleteList( final Graph g, final List<Triple> L )
- {
+ public void notifyDeleteList(final Graph g, final List<Triple> L) {
delete = true;
}
@Override
- public void notifyDeleteTriple( final Graph g, final Triple t )
- {
+ public void notifyDeleteTriple(final Graph g, final Triple t) {
delete = true;
}
@Override
- public void notifyEvent( final Graph source, final Object value )
- {
+ public void notifyEvent(final Graph source, final Object value) {
event = true;
}
- public void reset()
- {
+ public void reset() {
add = false;
delete = false;
event = false;
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
index e4d55ba..52c1674 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
@@ -21,27 +21,26 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import org.junit.Assert;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.graph.Graph;
import org.apache.jena.permissions.Factory;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.graph.SecuredGraph;
import org.apache.jena.permissions.graph.SecuredPrefixMapping;
-import org.apache.jena.shared.PrefixMapping ;
-import org.apache.jena.shared.impl.PrefixMappingImpl ;
-import org.apache.jena.sparql.graph.GraphFactory ;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.shared.impl.PrefixMappingImpl;
+import org.apache.jena.sparql.graph.GraphFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredPrefixMappingTest
-{
- public static void runTests( final SecurityEvaluator securityEvaluator,
- final PrefixMapping prefixMapping ) throws Exception
- {
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredPrefixMappingTest {
+ public static void runTests(final SecurityEvaluator securityEvaluator,
+ final PrefixMapping prefixMapping) throws Exception {
final PrefixMapping pm = prefixMapping;
Assert.assertNotNull("PrefixMapping may not be null", pm);
Assert.assertTrue("PrefixMapping should be secured",
@@ -49,30 +48,24 @@ public class SecuredPrefixMappingTest
final SecuredPrefixMappingTest pmTest = new SecuredPrefixMappingTest(
securityEvaluator) {
@Override
- public void setup()
- {
+ public void setup() {
this.securedMapping = (SecuredPrefixMapping) pm;
}
};
Method lockTest = null;
- for (final Method m : pmTest.getClass().getMethods())
- {
- if (m.isAnnotationPresent(Test.class))
- {
+ for (final Method m : pmTest.getClass().getMethods()) {
+ if (m.isAnnotationPresent(Test.class)) {
// lock test must come last
- if (m.getName().equals("testLock"))
- {
+ if (m.getName().equals("testLock")) {
lockTest = m;
- }
- else
- {
+ } else {
pmTest.setup();
m.invoke(pmTest);
}
}
}
- Assert.assertNotNull( "Did not find 'testLock' method", lockTest );
+ Assert.assertNotNull("Did not find 'testLock' method", lockTest);
pmTest.setup();
lockTest.invoke(pmTest);
@@ -83,15 +76,13 @@ public class SecuredPrefixMappingTest
protected SecuredPrefixMapping securedMapping;
- public SecuredPrefixMappingTest( final SecurityEvaluator securityEvaluator )
- {
+ public SecuredPrefixMappingTest(final SecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
this.principal = securityEvaluator.getPrincipal();
}
@Before
- public void setup()
- {
+ public void setup() {
final Graph g = GraphFactory.createDefaultGraph();
final SecuredGraph sg = Factory.getInstance(securityEvaluator,
@@ -100,72 +91,54 @@ public class SecuredPrefixMappingTest
}
@Test
- public void testExpandPrefix()
- {
- try
- {
+ public void testExpandPrefix() {
+ try {
securedMapping.expandPrefix("foo");
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetNsPrefixMap()
- {
- try
- {
+ public void testGetNsPrefixMap() {
+ try {
securedMapping.getNsPrefixMap();
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetNsPrefixURI()
- {
- try
- {
+ public void testGetNsPrefixURI() {
+ try {
securedMapping.getNsPrefixURI("foo");
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -173,48 +146,36 @@ public class SecuredPrefixMappingTest
}
@Test
- public void testGetNsURIPrefix()
- {
- try
- {
+ public void testGetNsURIPrefix() {
+ try {
securedMapping.getNsURIPrefix("http://example.com/foo");
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testLock()
- {
- try
- {
+ public void testLock() {
+ try {
securedMapping.lock();
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -222,48 +183,36 @@ public class SecuredPrefixMappingTest
}
@Test
- public void testQnameFor()
- {
- try
- {
+ public void testQnameFor() {
+ try {
securedMapping.qnameFor("http://example.com/foo/bar");
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
- e, e.getTriple()));
+ securedMapping.getModelNode())) {
+ Assert.fail(String.format(
+ "Should not have thrown ReadDeniedException : %s - %s",
+ e, e.getTriple()));
}
}
}
@Test
- public void testRemoveNsPrefix()
- {
- try
- {
+ public void testRemoveNsPrefix() {
+ try {
securedMapping.removeNsPrefix("foo");
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown UpdateDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -271,168 +220,129 @@ public class SecuredPrefixMappingTest
}
@Test
- public void testSamePrefixMappingAs()
- {
- try
- {
+ public void testSamePrefixMappingAs() {
+ try {
securedMapping.samePrefixMappingAs(GraphFactory
.createDefaultGraph().getPrefixMapping());
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetNsPrefix()
- {
- try
- {
+ public void testSetNsPrefix() {
+ try {
securedMapping.setNsPrefix("foo", "http://example.com/foo");
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
- Assert.fail("Should have thrown AccessDenied Exception");
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedMapping.setNsPrefixes(GraphFactory.createDefaultGraph()
.getPrefixMapping());
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedMapping.setNsPrefixes(new HashMap<String, String>());
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testShortForm()
- {
- try
- {
+ public void testShortForm() {
+ try {
securedMapping.shortForm("http://example.com/foo/bar");
if (!securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown ReadDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Read,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testWithDefaultMappings()
- {
+ public void testWithDefaultMappings() {
PrefixMapping pm = new PrefixMappingImpl();
- pm.setNsPrefix( "example", "http://example.com");
- try
- {
+ pm.setNsPrefix("example", "http://example.com");
+ try {
// make sure that it must update
securedMapping.withDefaultMappings(pm);
if (!securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ securedMapping.getModelNode())) {
+ Assert.fail("Should have thrown UpdateDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
-
+
@Test
- public void testWithDefaultMappingsNoAdd()
- {
+ public void testWithDefaultMappingsNoAdd() {
PrefixMapping pm = new PrefixMappingImpl();
- try
- {
+ try {
// make sure that it must update
securedMapping.withDefaultMappings(pm);
-// if (!securityEvaluator.evaluate(Action.Update,
-// securedMapping.getModelNode()))
-// {
-// Assert.fail("Should have thrown AccessDenied Exception");
-// }
- }
- catch (final AccessDeniedException e)
- {
+ // if (!securityEvaluator.evaluate(Action.Update,
+ // securedMapping.getModelNode()))
+ // {
+ // Assert.fail("Should have thrown UpdateDeniedException Exception");
+ // }
+ } catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(principal, Action.Update,
- securedMapping.getModelNode()))
- {
+ securedMapping.getModelNode())) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
index 18be198..857784a 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
@@ -20,36 +20,32 @@ package org.apache.jena.permissions.graph;
import java.io.File;
import java.io.IOException;
-import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.Graph;
import org.apache.jena.permissions.MockSecurityEvaluator;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.tdb.TDB ;
-import org.apache.jena.tdb.TDBFactory ;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.tdb.TDB;
+import org.apache.jena.tdb.TDBFactory;
import org.junit.After;
-public class TDBGraphTest extends MemGraphTest
-{
+public class TDBGraphTest extends MemGraphTest {
private DatasetGraph dsGraph;
private File f;
- public TDBGraphTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public TDBGraphTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
@Override
- protected Graph createGraph() throws IOException
- {
+ protected Graph createGraph() throws IOException {
TDB.init();
dsGraph = TDBFactory.createDataset().asDatasetGraph();
return dsGraph.getDefaultGraph();
}
@After
- public void tearDown()
- {
+ public void tearDown() {
TDB.sync(dsGraph);
dsGraph.close();
TDB.closedown();
[03/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFListTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFListTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFListTest.java
index b83fd41..9ff79a6 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFListTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFListTest.java
@@ -22,61 +22,61 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.model.SecuredRDFList;
import org.apache.jena.permissions.model.impl.SecuredRDFListImpl;
import org.apache.jena.permissions.utils.RDFListIterator;
import org.apache.jena.permissions.utils.RDFListSecFilter;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.rdf.model.RDFList.ApplyFn ;
-import org.apache.jena.rdf.model.RDFList.ReduceFn ;
-import org.apache.jena.util.iterator.WrappedIterator ;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.rdf.model.RDFList.ApplyFn;
+import org.apache.jena.rdf.model.RDFList.ReduceFn;
+import org.apache.jena.shared.AccessDeniedException;
+import org.apache.jena.util.iterator.WrappedIterator;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredRDFListTest extends SecuredResourceTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredRDFListTest extends SecuredResourceTest {
private RDFList baseList;
-
- public SecuredRDFListTest( final MockSecurityEvaluator securityEvaluator )
- {
+
+ public SecuredRDFListTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private int count( final Action action )
- {
+ private int count(final Action action) {
final Iterator<RDFList> iter = new RDFListIterator(
(RDFList) getBaseRDFNode());
- return WrappedIterator.create(iter)
- .filterKeep(new RDFListSecFilter<RDFList>(getSecuredRDFList(), action))
- .toList().size();
+ return WrappedIterator
+ .create(iter)
+ .filterKeep(
+ new RDFListSecFilter<RDFList>(getSecuredRDFList(),
+ action)).toList().size();
}
- private int count( final Set<Action> action )
- {
+ private int count(final Set<Action> action) {
final Iterator<RDFList> iter = new RDFListIterator(
(RDFList) getBaseRDFNode());
- return WrappedIterator.create(iter)
- .filterKeep(new RDFListSecFilter<RDFList>(getSecuredRDFList(), action))
- .toList().size();
+ return WrappedIterator
+ .create(iter)
+ .filterKeep(
+ new RDFListSecFilter<RDFList>(getSecuredRDFList(),
+ action)).toList().size();
}
- private SecuredRDFList getSecuredRDFList()
- {
+ private SecuredRDFList getSecuredRDFList() {
return (SecuredRDFList) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final RDFNode[] listElements = {
ResourceFactory.createResource("http://example.com/ListNode1"),
@@ -84,28 +84,24 @@ public class SecuredRDFListTest extends SecuredResourceTest
ResourceFactory.createResource("http://example.com/ListNode3"),
ResourceFactory.createResource("http://example.com/ListNode4") };
baseList = baseModel.createList(listElements);
- setSecuredRDFNode(SecuredRDFListImpl.getInstance(securedModel, baseList), baseList);
+ setSecuredRDFNode(
+ SecuredRDFListImpl.getInstance(securedModel, baseList),
+ baseList);
}
@Test
- public void testAdd()
- {
+ public void testAdd() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().add(baseModel.createResource());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -113,127 +109,99 @@ public class SecuredRDFListTest extends SecuredResourceTest
}
@Test
- public void testAppendNodeIterator()
- {
+ public void testAppendNodeIterator() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().append(baseModel.listObjects());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
-
+
@Test
- public void testAppendRDFList()
- {
+ public void testAppendRDFList() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
try {
getSecuredRDFList().append(baseModel.createList());
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- if (!securityEvaluator.evaluate(Action.Create) && (baseList.size()>0 && securityEvaluator.evaluate(Action.Read) ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Create)
+ && (baseList.size() > 0 && securityEvaluator
+ .evaluate(Action.Read))) {
+ Assert.fail("Should have thrown AddDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testApply()
- {
+ public void testApply() {
final ApplyFn fn = new ApplyFn() {
@Override
- public void apply( final RDFNode node )
- {
+ public void apply(final RDFNode node) {
// do nothing
}
};
- try
- {
+ try {
getSecuredRDFList().apply(fn);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Read });
- try
- {
+ try {
getSecuredRDFList().apply(perms, fn);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testAsJaveList()
- {
- try
- {
+ public void testAsJaveList() {
+ try {
getSecuredRDFList().asJavaList();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -241,340 +209,241 @@ public class SecuredRDFListTest extends SecuredResourceTest
}
@Test
- public void testConcatenate()
- {
+ public void testConcatenate() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().concatenate(baseModel.listObjects());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
final List<Resource> lst = new ArrayList<Resource>();
lst.add(ResourceFactory
.createResource("http://example.com/dummyList"));
getSecuredRDFList().concatenate(
baseModel.createList(lst.iterator()));
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCons()
- {
+ public void testCons() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().cons(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testContains()
- {
- try
- {
+ public void testContains() {
+ try {
getSecuredRDFList().contains(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
-
+
@Test
- public void testCopy()
- {
+ public void testCopy() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Read, Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().copy();
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms) )
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGet()
- {
- try
- {
+ public void testGet() {
+ try {
getSecuredRDFList().get(0);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
- if (((RDFList) getBaseRDFNode()).size() < 0)
- {
+ } catch (final ListIndexException e) {
+ if (((RDFList) getBaseRDFNode()).size() < 0) {
// acceptable exception
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testGetHead()
- {
- try
- {
+ public void testGetHead() {
+ try {
getSecuredRDFList().getHead();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
- if (((RDFList) getBaseRDFNode()).size() == 0)
- {
+ } catch (final ListIndexException e) {
+ if (((RDFList) getBaseRDFNode()).size() == 0) {
// acceptable exception
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testGetTail()
- {
- try
- {
+ public void testGetTail() {
+ try {
getSecuredRDFList().getTail();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
- if (((RDFList) getBaseRDFNode()).size() == 0)
- {
+ } catch (final ListIndexException e) {
+ if (((RDFList) getBaseRDFNode()).size() == 0) {
// acceptable exception
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testGetValidityErrorMessage()
- {
- try
- {
+ public void testGetValidityErrorMessage() {
+ try {
getSecuredRDFList().getValidityErrorMessage();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIndexOf()
- {
- try
- {
+ public void testIndexOf() {
+ try {
getSecuredRDFList().indexOf(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
- if (((RDFList) getBaseRDFNode()).size() == 0)
- {
+ } catch (final ListIndexException e) {
+ if (((RDFList) getBaseRDFNode()).size() == 0) {
// acceptable exception
- }
- else
- {
+ } else {
throw e;
}
}
- try
- {
+ try {
getSecuredRDFList().indexOf(SecuredRDFNodeTest.s, 1);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
+ } catch (final ListIndexException e) {
if (((RDFList) getBaseRDFNode()).size() <= 0)
{
// acceptable exception
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testIsEmpty()
- {
- try
- {
+ public void testIsEmpty() {
+ try {
getSecuredRDFList().isEmpty();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIterator()
- {
- try
- {
+ public void testIterator() {
+ try {
getSecuredRDFList().iterator();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -582,51 +451,39 @@ public class SecuredRDFListTest extends SecuredResourceTest
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().iterator(perms);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testReduce()
- {
+ public void testReduce() {
final ReduceFn fn = new ReduceFn() {
@Override
- public Object reduce( final RDFNode node, final Object accumulator )
- {
+ public Object reduce(final RDFNode node, final Object accumulator) {
return accumulator;
}
};
- try
- {
+ try {
getSecuredRDFList().reduce(fn, "Hello");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -634,334 +491,243 @@ public class SecuredRDFListTest extends SecuredResourceTest
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().reduce(perms, fn, "Hello");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemove()
- {
+ public void testRemove() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
final int count = count(Action.Delete);
getSecuredRDFList().remove(SecuredRDFNodeTest.s);
if (!securityEvaluator.evaluate(Action.Update)
|| ((count > 0) && !securityEvaluator
- .evaluate(Action.Delete)))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ .evaluate(Action.Delete))) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@SuppressWarnings("deprecation")
- @Override
+ @Override
@Test
- public void testRemoveAll()
- {
+ public void testRemoveAll() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
final int count = count(SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Read }));
getSecuredRDFList().removeAll();
if (!securityEvaluator.evaluate(Action.Update)
|| ((count > 0) && !securityEvaluator
- .evaluate(Action.Delete)))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ .evaluate(Action.Delete))) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final EmptyListException e)
- {
- if (count(Action.Read) == 0)
- {
+ } catch (final EmptyListException e) {
+ if (count(Action.Read) == 0) {
// expected.
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testRemoveHead()
- {
+ public void testRemoveHead() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
getSecuredRDFList().removeHead();
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final EmptyListException e)
- {
- if (count(Action.Read) == 0)
- {
+ } catch (final EmptyListException e) {
+ if (count(Action.Read) == 0) {
// expected.
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testRemoveList()
- {
+ public void testRemoveList() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
- try
- {
+ try {
final int count = count(Action.Delete);
getSecuredRDFList().removeList();
if (!securityEvaluator.evaluate(Action.Update)
|| ((count > 0) && !securityEvaluator
- .evaluate(Action.Delete)))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ .evaluate(Action.Delete))) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testReplace()
- {
- try
- {
+ public void testReplace() {
+ try {
getSecuredRDFList().replace(1, SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final ListIndexException e)
- {
- if (count(Action.Read) == 0)
- {
+ } catch (final ListIndexException e) {
+ if (count(Action.Read) == 0) {
// expected.
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testSameListAs()
- {
- try
- {
+ public void testSameListAs() {
+ try {
getSecuredRDFList().sameListAs(baseModel.createList());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetHead()
- {
+ public void testSetHead() {
- try
- {
+ try {
getSecuredRDFList().setHead(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final EmptyListException e)
- {
- if (count(Action.Read) == 0)
- {
+ } catch (final EmptyListException e) {
+ if (count(Action.Read) == 0) {
// expected.
- }
- else
- {
+ } else {
throw e;
}
}
}
@Test
- public void testSetStrict()
- {
- try
- {
+ public void testSetStrict() {
+ try {
getSecuredRDFList().setStrict(true);
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSize()
- {
- try
- {
+ public void testSize() {
+ try {
getSecuredRDFList().size();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testValid()
- {
- try
- {
+ public void testValid() {
+ try {
getSecuredRDFList().isValid();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testWith()
- {
+ public void testWith() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredRDFList().with(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFNodeTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFNodeTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFNodeTest.java
index 3c1f3db..0f2893c 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFNodeTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredRDFNodeTest.java
@@ -17,24 +17,23 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.Factory;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredModel;
import org.apache.jena.permissions.model.SecuredRDFNode;
import org.apache.jena.permissions.model.impl.SecuredRDFNodeImpl;
-import org.apache.jena.rdf.model.* ;
+import org.apache.jena.rdf.model.*;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredRDFNodeTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredRDFNodeTest {
protected final MockSecurityEvaluator securityEvaluator;
protected Model baseModel;
protected SecuredModel securedModel;
@@ -50,36 +49,30 @@ public class SecuredRDFNodeTest
public static Resource o = ResourceFactory
.createResource("http://example.com/graph/o");
- public SecuredRDFNodeTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredRDFNodeTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
}
- protected Model createModel()
- {
+ protected Model createModel() {
return ModelFactory.createDefaultModel();
}
- protected RDFNode getBaseRDFNode()
- {
+ protected RDFNode getBaseRDFNode() {
return baseRDFNode;
}
- protected SecuredRDFNode getSecuredRDFNode()
- {
+ protected SecuredRDFNode getSecuredRDFNode() {
return securedRDFNode;
}
- protected void setSecuredRDFNode( final SecuredRDFNode securedRDFNode,
- final RDFNode baseRDFNode )
- {
+ protected void setSecuredRDFNode(final SecuredRDFNode securedRDFNode,
+ final RDFNode baseRDFNode) {
this.securedRDFNode = securedRDFNode;
this.baseRDFNode = baseRDFNode;
}
@Before
- public void setup()
- {
+ public void setup() {
baseModel = createModel();
baseModel.removeAll();
baseModel.add(SecuredRDFNodeTest.s, SecuredRDFNodeTest.p,
@@ -94,86 +87,66 @@ public class SecuredRDFNodeTest
}
@After
- public void teardown()
- {
+ public void teardown() {
securedModel.close();
securedModel = null;
}
@Test
- public void testAsNode()
- {
- try
- {
+ public void testAsNode() {
+ try {
securedRDFNode.asNode();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCanAs()
- {
- try
- {
+ public void testCanAs() {
+ try {
securedRDFNode.canAs(Resource.class);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetModel()
- {
+ public void testGetModel() {
final Model m2 = securedRDFNode.getModel();
Assert.assertTrue("Model should have been secured",
m2 instanceof SecuredModel);
}
@Test
- public void testInModel()
- {
+ public void testInModel() {
final Model m2 = ModelFactory.createDefaultModel();
- try
- {
+ try {
final RDFNode n2 = securedRDFNode.inModel(m2);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
Assert.assertFalse("RDFNode should not have been secured",
n2 instanceof SecuredRDFNode);
Assert.assertEquals("Wrong securedModel returned", n2.getModel(),
m2);
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -182,24 +155,19 @@ public class SecuredRDFNodeTest
final SecuredModel m3 = Factory.getInstance(securityEvaluator,
"http://example.com/securedGraph2", m2);
- try
- {
+ try {
final RDFNode n2 = securedRDFNode.inModel(m3);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
Assert.assertTrue("RDFNode should have been secured",
n2 instanceof SecuredRDFNode);
Assert.assertEquals("Wrong securedModel returned", n2.getModel(),
m3);
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredReifiedStatementTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredReifiedStatementTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredReifiedStatementTest.java
index 73055fe..697aecc 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredReifiedStatementTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredReifiedStatementTest.java
@@ -17,37 +17,33 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredReifiedStatement;
import org.apache.jena.permissions.model.impl.SecuredReifiedStatementImpl;
-import org.apache.jena.rdf.model.ReifiedStatement ;
+import org.apache.jena.rdf.model.ReifiedStatement;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredReifiedStatementTest extends SecuredResourceTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredReifiedStatementTest extends SecuredResourceTest {
public SecuredReifiedStatementTest(
- final MockSecurityEvaluator securityEvaluator )
- {
+ final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredReifiedStatement getSecuredReifiedStatement()
- {
+ private SecuredReifiedStatement getSecuredReifiedStatement() {
return (SecuredReifiedStatement) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final ReifiedStatement stmt = baseModel.listStatements().next()
.createReifiedStatement();
@@ -58,25 +54,19 @@ public class SecuredReifiedStatementTest extends SecuredResourceTest
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws AccessDeniedRuntimeException
*/
@Test
- public void testGetStatement()
- {
- try
- {
+ public void testGetStatement() {
+ try {
getSecuredReifiedStatement().getStatement();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredResourceTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredResourceTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredResourceTest.java
index c893f4e..4004ece 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredResourceTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredResourceTest.java
@@ -19,41 +19,38 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredResource;
import org.apache.jena.permissions.model.impl.SecuredResourceImpl;
-import org.apache.jena.rdf.model.Literal ;
-import org.apache.jena.rdf.model.RDFNode ;
-import org.apache.jena.rdf.model.ResourceFactory ;
-import org.apache.jena.rdf.model.StmtIterator ;
-import org.apache.jena.shared.PropertyNotFoundException ;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.StmtIterator;
+import org.apache.jena.shared.AccessDeniedException;
+import org.apache.jena.shared.PropertyNotFoundException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredResourceTest extends SecuredRDFNodeTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredResourceTest extends SecuredRDFNodeTest {
- public SecuredResourceTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredResourceTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredResource getSecuredResource()
- {
+ private SecuredResource getSecuredResource() {
return (SecuredResource) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
setSecuredRDFNode(SecuredResourceImpl.getInstance(securedModel,
SecuredRDFNodeTest.s), SecuredRDFNodeTest.s);
@@ -62,172 +59,130 @@ public class SecuredResourceTest extends SecuredRDFNodeTest
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws AccessDeniedRuntimeException
*/
@Test
- public void testAddLiteralBoolean()
- {
+ public void testAddLiteralBoolean() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
-
- public void testAddLiteralChar()
- {
+
+ public void testAddLiteralChar() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, 'c');
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
-}
-
- public void testAddLiteralDouble()
- {
+ }
+
+ public void testAddLiteralDouble() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
-
- try
- {
+
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, 3.14D);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
-}
-
- public void testAddLiteralFloat()
- {
+ }
+
+ public void testAddLiteralFloat() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
-
- try
- {
+
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, 3.14F);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
-}
-
- public void testAddLiteral()
- {
+ }
+
+ public void testAddLiteral() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
-
- try
- {
+
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p,
ResourceFactory.createTypedLiteral("Yee haw"));
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
-}
-
- public void testAddLiteralLong()
- {
+ }
+
+ public void testAddLiteralLong() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
-
- try
- {
+
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, 1L);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
-}
-
- public void testAddLiteralObject()
- {
+ }
+
+ public void testAddLiteralObject() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
-
+
final Object o = Integer.valueOf("1234");
- try
- {
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, o);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -235,591 +190,436 @@ public class SecuredResourceTest extends SecuredRDFNodeTest
}
@Test
- public void testAddProperty()
- {
+ public void testAddProperty() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
final RDFNode rdfNode = ResourceFactory
.createResource("http://example.com/newResource");
- try
- {
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, rdfNode);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().addLiteral(SecuredRDFNodeTest.p, "string");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- final Literal l = ResourceFactory.createTypedLiteral( 3.14F );
- try
- {
+ final Literal l = ResourceFactory.createTypedLiteral(3.14F);
+ try {
getSecuredResource().addProperty(SecuredRDFNodeTest.p,
l.getLexicalForm(), l.getDatatype());
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().addProperty(SecuredRDFNodeTest.p, "dos", "sp");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testAnonFuncs()
- {
+ public void testAnonFuncs() {
final SecuredResource anonResource = securedModel.createResource();
setSecuredRDFNode(anonResource, null);
- try
- {
+ try {
getSecuredResource().getId();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testAsResource()
- {
+ public void testAsResource() {
getSecuredResource().asResource();
}
@Test
- public void testEquals()
- {
- try
- {
+ public void testEquals() {
+ try {
getSecuredResource().equals(SecuredRDFNodeTest.s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
- public void testGetLocalName()
- {
- try
- {
+ public void testGetLocalName() {
+ try {
getSecuredResource().getLocalName();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
- public void testGetNameSpace()
- {
- try
- {
+ public void testGetNameSpace() {
+ try {
getSecuredResource().getNameSpace();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetProperty()
- {
- try
- {
+ public void testGetProperty() {
+ try {
getSecuredResource().getProperty(SecuredRDFNodeTest.p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().getPropertyResourceValue(SecuredRDFNodeTest.p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().getRequiredProperty(SecuredRDFNodeTest.p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final PropertyNotFoundException e)
- {
+ } catch (final PropertyNotFoundException e) {
// expected if (this, "p", ANY) is not in the base securedModel.
final StmtIterator iter = baseModel.listStatements(
getSecuredResource(), SecuredRDFNodeTest.p, (RDFNode) null);
- try
- {
- if (iter.hasNext())
- {
+ try {
+ if (iter.hasNext()) {
throw e;
}
- }
- finally
- {
+ } finally {
iter.close();
}
}
}
@Test
- public void testGetURI()
- {
- try
- {
+ public void testGetURI() {
+ try {
getSecuredResource().getURI();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testHasLiteral()
- {
- try
- {
+ public void testHasLiteral() {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, true);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, 'c');
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, 3.14d);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, 3.14f);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, 6l);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
final Object o = 6;
- try
- {
+ try {
getSecuredResource().hasLiteral(SecuredRDFNodeTest.p, o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testHasProperty()
- {
+ public void testHasProperty() {
- try
- {
+ try {
getSecuredResource().hasProperty(SecuredRDFNodeTest.p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasProperty(SecuredRDFNodeTest.p,
SecuredRDFNodeTest.o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasProperty(SecuredRDFNodeTest.p, "yeee haw");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().hasProperty(SecuredRDFNodeTest.p, "dos", "sp");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testHasURI()
- {
- try
- {
+ public void testHasURI() {
+ try {
getSecuredResource().hasURI("http://example.com/yeeHaw");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testListProperties()
- {
- try
- {
+ public void testListProperties() {
+ try {
getSecuredResource().listProperties();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredResource().listProperties(SecuredRDFNodeTest.p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemoveAll()
- {
+ public void testRemoveAll() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
final int count = baseModel
.listStatements(getBaseRDFNode().asResource(),
SecuredRDFNodeTest.p, (RDFNode) null).toSet().size();
- try
- {
+ try {
getSecuredResource().removeAll(SecuredRDFNodeTest.p);
// only throw on delete if count > 0
if (!securityEvaluator.evaluate(Action.Update)
|| ((count > 0) && !securityEvaluator
- .evaluate(Action.Delete)))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ .evaluate(Action.Delete))) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemoveProperties()
- {
+ public void testRemoveProperties() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
final int count = baseModel
.listStatements(getBaseRDFNode().asResource(),
SecuredRDFNodeTest.p, (RDFNode) null).toSet().size();
- try
- {
+ try {
getSecuredResource().removeProperties();
// only throw on delete if count > 0
if (!securityEvaluator.evaluate(Action.Update)
|| ((count > 0) && !securityEvaluator
- .evaluate(Action.Delete)))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ .evaluate(Action.Delete))) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
[09/10] jena git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/jena Fixed confilcts Conflicts:
jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
Posted by cl...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/jena
Fixed confilcts
Conflicts:
jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/e48966cd
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/e48966cd
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/e48966cd
Branch: refs/heads/master
Commit: e48966cd308bf417c14f52afa239218f2d262785
Parents: fcf7188 2ab1ca8
Author: Claude Warren <cl...@apache.org>
Authored: Fri Jul 17 07:47:26 2015 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Fri Jul 17 07:47:26 2015 +0100
----------------------------------------------------------------------
.../jena/riot/checker/CheckerVisitor.java | 3 +-
.../jena/riot/lang/BlankNodeAllocatorHash.java | 3 +-
.../jena/riot/lang/BlankNodeAllocatorLabel.java | 3 +-
.../lang/BlankNodeAllocatorLabelEncoded.java | 5 +-
.../lang/BlankNodeAllocatorTraditional.java | 2 +-
.../java/org/apache/jena/riot/lang/LangCSV.java | 2 +-
.../org/apache/jena/riot/lang/LangRDFXML.java | 2 +-
.../apache/jena/riot/lang/LangTurtleBase.java | 2 +-
.../org/apache/jena/riot/system/RiotLib.java | 3 +-
.../apache/jena/riot/thrift/ThriftConvert.java | 3 +-
.../java/org/apache/jena/riot/tokens/Token.java | 27 +-
.../apache/jena/sparql/algebra/OpAsQuery.java | 129 +++++--
.../engine/binding/BindingInputStream.java | 3 +-
.../org/apache/jena/sparql/expr/E_BNode.java | 2 +-
.../org/apache/jena/sparql/expr/NodeValue.java | 29 +-
.../apache/jena/sparql/modify/TemplateLib.java | 2 +-
.../sparql/resultset/JSONInputIterator.java | 28 +-
.../jena/sparql/resultset/XMLInputStAX.java | 3 +-
.../sparql/serializer/FormatterElement.java | 373 ++++++++-----------
.../jena/sparql/sse/lang/ParseHandlerPlain.java | 2 +-
.../apache/jena/sparql/syntax/ElementGroup.java | 5 +
.../ElementTransformCleanGroupsOfOne.java | 53 +--
.../apache/jena/sparql/util/LabelToNodeMap.java | 2 +-
.../jena/sparql/util/graph/GraphList.java | 4 +-
.../jena/atlas/data/TestDistinctDataBag.java | 6 +-
.../jena/atlas/data/TestDistinctDataNet.java | 6 +-
.../jena/atlas/data/TestSortedDataBag.java | 6 +-
.../jena/riot/lang/TestCollectorStream.java | 4 +-
.../apache/jena/riot/lang/TestNodeToLabel.java | 6 +-
.../jena/riot/lang/TestPipedRDFIterators.java | 4 +-
.../apache/jena/riot/thrift/TestThriftTerm.java | 5 +-
.../jena/riot/tokens/TestTokenForNode.java | 3 +-
.../apache/jena/riot/writer/TestRDFJSON.java | 2 +-
.../jena/sparql/algebra/TestOpAsQuery.java | 83 ++++-
.../sparql/core/AbstractDatasetGraphTests.java | 6 +-
.../engine/binding/TestBindingStreams.java | 3 +-
.../engine/iterator/TestQueryIterSort.java | 6 +-
.../jena/sparql/expr/TestExpressions.java | 2 +-
.../jena/sparql/expr/TestNodeFunctions.java | 6 +-
.../apache/jena/sparql/expr/TestOrdering.java | 2 +-
.../apache/jena/sparql/expr/TestXSDFuncOp.java | 8 +-
.../sparql/modify/AbstractTestUpdateGraph.java | 8 +-
.../apache/jena/sparql/util/TestFmtUtils.java | 8 +-
jena-arq/testing/ARQ/Serialization/func.sh | 1 -
jena-arq/testing/ARQ/Serialization/manifest.ttl | 24 ++
.../testing/ARQ/Serialization/syntax-path-01.rq | 5 +
.../testing/ARQ/Serialization/syntax-path-02.rq | 5 +
.../testing/ARQ/Serialization/syntax-path-03.rq | 6 +
.../testing/ARQ/Serialization/syntax-path-04.rq | 6 +
.../testing/ARQ/Serialization/syntax-path-05.rq | 7 +
.../testing/ARQ/Serialization/syntax-path-06.rq | 8 +
.../java/org/apache/jena/graph/BlankNodeId.java | 156 ++++++++
.../main/java/org/apache/jena/graph/Node.java | 34 +-
.../java/org/apache/jena/graph/NodeFactory.java | 49 ++-
.../java/org/apache/jena/graph/NodeVisitor.java | 5 +-
.../java/org/apache/jena/graph/Node_Blank.java | 12 +-
.../org/apache/jena/graph/Node_Literal.java | 5 +
.../java/org/apache/jena/graph/Node_URI.java | 5 +
.../org/apache/jena/graph/Node_Variable.java | 1 +
.../apache/jena/n3/turtle/LabelToNodeMap.java | 2 +-
.../org/apache/jena/n3/turtle/ParserBase.java | 3 +-
.../java/org/apache/jena/rdf/model/AnonId.java | 121 +++---
.../apache/jena/rdf/model/impl/ModelCom.java | 4 +-
.../apache/jena/rdf/model/impl/ReifierStd.java | 2 +-
.../jena/rdf/model/impl/ResourceImpl.java | 13 +-
.../apache/jena/rdfxml/xmlinput/JenaReader.java | 2 +-
.../jena/reasoner/rulesys/FBRuleInfGraph.java | 2 +-
.../org/apache/jena/reasoner/rulesys/Rule.java | 19 +-
.../org/apache/jena/reasoner/rulesys/Util.java | 2 +-
.../reasoner/rulesys/builtins/MakeSkolem.java | 10 +-
.../reasoner/rulesys/builtins/MakeTemp.java | 2 +-
.../reasoner/rulesys/impl/BindingStack.java | 6 +-
.../reasoner/rulesys/impl/BindingVector.java | 6 +-
.../rulesys/impl/LPBindingEnvironment.java | 6 +-
.../reasoner/rulesys/impl/TempNodeCache.java | 2 +-
.../apache/jena/enhanced/test/TestPackage.java | 2 +-
.../jena/graph/test/AbstractTestReifier.java | 2 +-
.../apache/jena/graph/test/NodeCreateUtils.java | 4 +-
.../org/apache/jena/graph/test/TestNode.java | 46 +--
.../org/apache/jena/graph/test/TestTriple.java | 7 +-
.../jena/rdfxml/xmloutput/TestXMLFeatures.java | 2 +-
.../jena/reasoner/rulesys/test/TestBugs.java | 4 +-
.../jena/reasoner/rulesys/test/TestFBRules.java | 2 +-
.../jena/testing_framework/NodeCreateUtils.java | 20 +-
.../jena/testing_framework/TestFileData.java | 36 +-
.../apache/jena/fuseki/mgt/ActionAsyncTask.java | 5 +-
.../apache/jena/fuseki/mgt/ActionBackup.java | 10 -
.../jena/fuseki/mgt/ActionBackupList.java | 94 +++++
.../jena/fuseki/mgt/ActionContainerItem.java | 26 +-
.../apache/jena/fuseki/mgt/ActionDatasets.java | 21 +-
.../org/apache/jena/fuseki/mgt/ActionSleep.java | 2 +-
.../org/apache/jena/fuseki/mgt/ActionStats.java | 7 -
.../java/org/apache/jena/fuseki/mgt/Async.java | 2 +-
.../org/apache/jena/fuseki/mgt/MgtConst.java | 11 +-
.../src/main/webapp/WEB-INF/web.xml | 12 +-
.../java/org/apache/jena/fuseki/TestAdmin.java | 12 +-
.../permissions/example/ExampleEvaluator.java | 22 +-
.../example/ShiroExampleEvaluator.java | 26 +-
.../jena/permissions/ReadDeniedException.java | 22 ++
.../jena/permissions/SecurityEvaluator.java | 4 +-
.../jena/permissions/UpdateDeniedException.java | 22 ++
.../jena/permissions/model/SecuredModel.java | 194 +++++-----
.../jena/permissions/model/SecuredSeq.java | 1 +
...SecuredUnsupportedPolymorphismException.java | 5 +
.../model/impl/SecuredModelImpl.java | 8 +-
.../model/impl/SecuredResourceImpl.java | 3 +-
.../jena/permissions/SecuredAssemblerTest.java | 1 -
.../model/SecuredModelDetailTest.java | 51 ++-
.../apache/jena/sdb/layout1/CodecSimple.java | 4 +-
.../org/apache/jena/sdb/layout2/SQLBridge2.java | 13 +-
.../jena/query/spatial/SpatialQueryFuncs.java | 3 +-
.../jena/tdb/store/nodetable/NodecLib.java | 3 +-
.../jena/tdb/store/nodetable/NodecSSE.java | 3 +-
.../jena/tdb/store/nodetable/TestCodec.java | 9 +-
.../apache/jena/query/text/TextQueryFuncs.java | 5 +-
.../org/apache/jena/query/text/TextQueryPF.java | 5 +-
116 files changed, 1216 insertions(+), 910 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
index 5e95725,0000000..f266dfc
mode 100644,000000..100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/ReadDeniedException.java
@@@ -1,43 -1,0 +1,65 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
+package org.apache.jena.permissions;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.AccessDeniedException;
+
+public class ReadDeniedException extends AccessDeniedException {
+
++ /**
++ *
++ */
++ private static final long serialVersionUID = 2241945715756635813L;
++
+ public ReadDeniedException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message, Triple triple) {
+ super(message, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(Throwable cause, Triple triple) {
+ super(cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ReadDeniedException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
index 9a2a396,1e28084..bf52c5b
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/SecurityEvaluator.java
@@@ -23,14 -23,6 +23,13 @@@ import java.util.LinkedHashSet
import java.util.Set;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.jena.graph.FrontsNode;
+import org.apache.jena.graph.FrontsTriple;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.graph.impl.LiteralLabel;
+import org.apache.jena.graph.impl.LiteralLabelFactory;
- import org.apache.jena.rdf.model.AnonId;
/**
* SecurityEvaluator.
@@@ -302,25 -294,6 +301,24 @@@ public interface SecurityEvaluator
public String toString() {
return String.format("[%s:%s]", getType(), getValue());
}
+
+ @Override
+ public Node asNode() {
+ switch (type) {
+ case Anonymous:
- AnonId id = AnonId.create(value);
- return NodeFactory.createAnon( id );
++ return NodeFactory.createBlankNode( value );
+ case Any:
+ return Node.ANY;
+ case Literal:
+ LiteralLabel lit = LiteralLabelFactory.create(value, (String)null);
+ return NodeFactory.createLiteral(lit);
+ case URI:
+ return NodeFactory.createURI( value );
+
+ default :
+ return Node.ANY;
+ }
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
index d1c6011,0000000..2138e8f
mode 100644,000000..100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/UpdateDeniedException.java
@@@ -1,43 -1,0 +1,65 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
+package org.apache.jena.permissions;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.shared.AccessDeniedException;
+
+public class UpdateDeniedException extends AccessDeniedException {
+
++ /**
++ *
++ */
++ private static final long serialVersionUID = -2200205468688578585L;
++
+ public UpdateDeniedException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Throwable cause, Triple triple) {
+ super(message, cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message, Triple triple) {
+ super(message, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(Throwable cause, Triple triple) {
+ super(cause, triple);
+ // TODO Auto-generated constructor stub
+ }
+
+ public UpdateDeniedException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
index a8b5530,f506308..d3575e8
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
@@@ -60,16 -56,15 +60,16 @@@ public interface SecuredModel extends M
*/
@Override
public SecuredModel add( final List<Statement> statements )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Create for each statement in the securedModel as a triple.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredModel add( final Model m ) throws UpdateDeniedException, AddDeniedException;
- public SecuredModel add( final Model m ) throws AccessDeniedException;
++ public SecuredModel add( final Model m ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -79,7 -73,7 +79,7 @@@
*/
@Override
public SecuredModel add( final Resource s, final Property p, final RDFNode o )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -89,7 -82,7 +89,7 @@@
*/
@Override
public SecuredModel add( final Resource s, final Property p, final String o )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -100,7 -92,7 +100,7 @@@
@Override
public SecuredModel add( final Resource s, final Property p,
final String o, final boolean wellFormed )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -111,7 -102,7 +111,7 @@@
@Override
public SecuredModel add( final Resource s, final Property p,
final String lex, final RDFDatatype datatype )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -121,16 -111,15 +121,16 @@@
*/
@Override
public SecuredModel add( final Resource s, final Property p,
- final String o, final String l ) throws UpdateDeniedException, AddDeniedException;
- final String o, final String l ) throws AccessDeniedException;
++ final String o, final String l ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the statement as a triple
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredModel add( final Statement s ) throws UpdateDeniedException, AddDeniedException;
- public SecuredModel add( final Statement s ) throws AccessDeniedException;
++ public SecuredModel add( final Statement s ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -140,7 -128,7 +140,7 @@@
*/
@Override
public SecuredModel add( final Statement[] statements )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -150,7 -137,7 +150,7 @@@
*/
@Override
public SecuredModel add( final StmtIterator iter )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -160,7 -146,7 +160,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final boolean o ) throws UpdateDeniedException, AddDeniedException;
- final boolean o ) throws AccessDeniedException;
++ final boolean o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -170,7 -155,7 +170,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final char o ) throws UpdateDeniedException, AddDeniedException;
- final char o ) throws AccessDeniedException;
++ final char o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -180,7 -164,7 +180,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final double o ) throws UpdateDeniedException, AddDeniedException;
- final double o ) throws AccessDeniedException;
++ final double o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -190,7 -173,7 +190,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final float o ) throws UpdateDeniedException, AddDeniedException;
- final float o ) throws AccessDeniedException;
++ final float o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -200,7 -182,7 +200,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final int o ) throws UpdateDeniedException, AddDeniedException;
- final int o ) throws AccessDeniedException;
++ final int o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -210,7 -191,7 +210,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final Literal o ) throws UpdateDeniedException, AddDeniedException;
- final Literal o ) throws AccessDeniedException;
++ final Literal o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -220,7 -200,7 +220,7 @@@
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final long o ) throws UpdateDeniedException, AddDeniedException;
- final long o ) throws AccessDeniedException;
++ final long o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -231,7 -210,7 +231,7 @@@
@Override
@Deprecated
public SecuredModel addLiteral( final Resource s, final Property p,
- final Object o ) throws UpdateDeniedException, AddDeniedException;
- final Object o ) throws AccessDeniedException;
++ final Object o ) throws AddDeniedException, UpdateDeniedException;
@Override
public SecuredRDFNode asRDFNode( final Node n );
@@@ -302,11 -279,11 +302,10 @@@
/**
* @sec.graph Read
* @sec.triple Read every statement in securedModel.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public boolean containsAll( final Model model )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public boolean containsAll( final Model model ) throws ReadDeniedException;
/**
* @sec.graph Read
@@@ -414,11 -391,10 +413,11 @@@
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.ANY, RDF.type, Rdf.Alt)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt createAlt() throws UpdateDeniedException, AddDeniedException;
- public SecuredAlt createAlt() throws AccessDeniedException;
++ public SecuredAlt createAlt() throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -428,16 -403,15 +427,16 @@@
*/
@Override
public SecuredAlt createAlt( final String uri )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.ANY, RDF.type, Rdf.Bag)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredBag createBag() throws UpdateDeniedException, AddDeniedException;
- public SecuredBag createBag() throws AccessDeniedException;
++ public SecuredBag createBag() throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -447,14 -420,14 +446,14 @@@
*/
@Override
public SecuredBag createBag( final String uri )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
- public SecuredRDFList createList() throws UpdateDeniedException, AddDeniedException;
- public SecuredRDFList createList() throws AccessDeniedException;
++ public SecuredRDFList createList() throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -468,7 -440,7 +467,7 @@@
*/
@Override
public SecuredRDFList createList( final Iterator<? extends RDFNode> members )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -482,7 -453,7 +481,7 @@@
*/
@Override
public SecuredRDFList createList( final RDFNode[] members )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -492,7 -462,7 +491,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final boolean o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final boolean o ) throws AccessDeniedException;
++ final Property p, final boolean o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -502,7 -471,7 +501,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final char o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final char o ) throws AccessDeniedException;
++ final Property p, final char o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -512,7 -480,7 +511,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final double o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final double o ) throws AccessDeniedException;
++ final Property p, final double o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -522,7 -489,7 +521,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final float o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final float o ) throws AccessDeniedException;
++ final Property p, final float o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -532,7 -498,7 +531,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final int o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final int o ) throws AccessDeniedException;
++ final Property p, final int o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -542,7 -507,7 +541,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final long o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final long o ) throws AccessDeniedException;
++ final Property p, final long o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -552,7 -516,7 +551,7 @@@
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final Object o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final Object o ) throws AccessDeniedException;
++ final Property p, final Object o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -562,7 -525,7 +561,7 @@@
*/
@Override
public Property createProperty( final String uri )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -572,7 -534,7 +571,7 @@@
*/
@Override
public Property createProperty( final String nameSpace,
- final String localName ) throws UpdateDeniedException, AddDeniedException;
- final String localName ) throws AccessDeniedException;
++ final String localName ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -588,7 -548,7 +587,7 @@@
*/
@Override
public ReifiedStatement createReifiedStatement( final Statement s )
- throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException, ReadDeniedException;
/**
* @sec.graph Update
@@@ -602,19 -560,17 +601,19 @@@
*/
@Override
public ReifiedStatement createReifiedStatement( final String uri,
- final Statement s ) throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
- final Statement s ) throws AccessDeniedException;
++ final Statement s ) throws AddDeniedException, UpdateDeniedException, ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Read s as a triple
- * @sec.triple create SecTriple( SecNode.FUTURE, SecNode.IGNORE,
+ * @sec.triple Create SecTriple( SecNode.FUTURE, SecNode.IGNORE,
* SecNode.IGNORE )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredResource createResource() throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
- public SecuredResource createResource() throws AccessDeniedException;
++ public SecuredResource createResource() throws AddDeniedException, UpdateDeniedException, ReadDeniedException;
/**
* @sec.graph Update
@@@ -627,7 -581,7 +626,7 @@@
*/
@Override
public SecuredResource createResource( final AnonId id )
- throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException, ReadDeniedException;
/**
* @sec.graph Update
@@@ -637,7 -590,7 +636,7 @@@
*/
@Override
public SecuredResource createResource( final Resource type )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
@Override
@Deprecated
@@@ -657,7 -608,7 +656,7 @@@
*/
@Override
public SecuredResource createResource( final String uri, final Resource type )
- throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException, ReadDeniedException;
@Override
@Deprecated
@@@ -666,11 -617,10 +665,11 @@@
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.type, RDF.Alt )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
- public SecuredSeq createSeq() throws UpdateDeniedException, AddDeniedException;
- public SecuredSeq createSeq() throws AccessDeniedException;
++ public SecuredSeq createSeq() throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -680,7 -629,7 +679,7 @@@
*/
@Override
public SecuredSeq createSeq( final String uri )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -690,7 -638,7 +689,7 @@@
*/
@Override
public SecuredStatement createStatement( final Resource s,
- final Property p, final RDFNode o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final RDFNode o ) throws AccessDeniedException;
++ final Property p, final RDFNode o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -700,7 -647,7 +699,7 @@@
*/
@Override
public SecuredStatement createStatement( final Resource s,
- final Property p, final String o ) throws UpdateDeniedException, AddDeniedException;
- final Property p, final String o ) throws AccessDeniedException;
++ final Property p, final String o ) throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -710,7 -657,7 +709,7 @@@
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final boolean wellFormed )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -721,7 -667,7 +720,7 @@@
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final String l )
- throws UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, UpdateDeniedException;
/**
* @sec.graph Update
@@@ -732,7 -677,7 +731,7 @@@
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final String l,
- final boolean wellFormed ) throws UpdateDeniedException, AddDeniedException;
- final boolean wellFormed ) throws AccessDeniedException;
++ final boolean wellFormed ) throws AddDeniedException, UpdateDeniedException;
@Override
public SecuredLiteral createTypedLiteral( final boolean v );
@@@ -788,20 -733,19 +787,18 @@@
/**
* @sec.graph Read if read lock is requested
* @sec.graph Update if write lock is requested
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public void enterCriticalSection( final boolean readLockRequested )
- throws ReadDeniedException, UpdateDeniedException;
- throws AccessDeniedException;
++ public void enterCriticalSection( final boolean readLockRequested ) throws ReadDeniedException, UpdateDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public String expandPrefix( final String prefixed )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public String expandPrefix( final String prefixed ) throws ReadDeniedException;
/**
* @sec.graph Read
@@@ -841,7 -783,7 +838,7 @@@
*/
@Override
public SecuredResource getAnyReifiedStatement( final Statement s )
- throws ReadDeniedException, UpdateDeniedException, AddDeniedException;
- throws AccessDeniedException;
++ throws AddDeniedException, ReadDeniedException, UpdateDeniedException;
/**
* @sec.graph Read
@@@ -865,27 -807,27 +862,24 @@@
/**
* @sec.graph Read
* @sec.triple Read on the returned statement.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredStatement getProperty( final Resource s, final Property p )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredStatement getProperty( final Resource s, final Property p ) throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public Property getProperty( final String uri )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public Property getProperty( final String uri ) throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public Property getProperty( final String nameSpace, final String localName )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public Property getProperty( final String nameSpace, final String localName ) throws ReadDeniedException;
/**
* @sec.graph Read if the node exists
@@@ -913,8 -855,8 +907,7 @@@
*/
@Override
public SecuredStatement getRequiredProperty( final Resource s,
-- final Property p ) throws PropertyNotFoundException,
- ReadDeniedException;
- AccessDeniedException;
++ final Property p ) throws PropertyNotFoundException, ReadDeniedException;
@Override
public SecuredResource getResource( final String uri );
@@@ -963,11 -905,11 +956,10 @@@
* @sec.graph Read
* @sec.triple Read all compared triples. Triples that can not be read will
* not be compared.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public boolean isIsomorphicWith( final Model g )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public boolean isIsomorphicWith( final Model g ) throws ReadDeniedException;
/**
*
@@@ -999,8 -941,8 +991,7 @@@
@Override
public SecuredStatementIterator listLiteralStatements(
-- final Resource subject, final Property predicate, final char object )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ final Resource subject, final Property predicate, final char object ) throws ReadDeniedException;
/**
*
@@@ -1018,12 -960,13 +1009,11 @@@
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
-
@Override
public SecuredStatementIterator listLiteralStatements(
-- final Resource subject, final Property predicate, final float object )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ final Resource subject, final Property predicate, final float object ) throws ReadDeniedException;
/**
*
@@@ -1034,8 -977,8 +1024,7 @@@
@Override
public SecuredStatementIterator listLiteralStatements(
-- final Resource subject, final Property predicate, final long object )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ final Resource subject, final Property predicate, final long object ) throws ReadDeniedException;
/**
*
@@@ -1058,11 -1001,11 +1047,10 @@@
*
* @sec.graph Read
* @sec.triple Read on each RDFNode returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredNodeIterator<RDFNode> listObjectsOfProperty( final Property p )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredNodeIterator<RDFNode> listObjectsOfProperty( final Property p ) throws ReadDeniedException;
/**
*
@@@ -1078,21 -1021,21 +1066,19 @@@
*
* @sec.graph Read
* @sec.triple Read on each Reified statement returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredRSIterator listReifiedStatements()
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredRSIterator listReifiedStatements() throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each Reified statement returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredRSIterator listReifiedStatements( final Statement st )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredRSIterator listReifiedStatements( final Statement st ) throws ReadDeniedException;
/**
*
@@@ -1100,11 -1043,11 +1086,10 @@@
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredResIterator listResourcesWithProperty( final Property p )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredResIterator listResourcesWithProperty( final Property p ) throws ReadDeniedException;
/**
*
@@@ -1194,11 -1139,11 +1179,10 @@@
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredStatementIterator listStatements()
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredStatementIterator listStatements() throws ReadDeniedException;
/**
*
@@@ -1218,8 -1163,8 +1202,7 @@@
*/
@Override
public SecuredStatementIterator listStatements( final Resource subject,
-- final Property predicate, final String object )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ final Property predicate, final String object ) throws ReadDeniedException;
/**
*
@@@ -1229,18 -1174,18 +1212,16 @@@
*/
@Override
public SecuredStatementIterator listStatements( final Resource subject,
-- final Property predicate, final String object, final String lang )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ final Property predicate, final String object, final String lang ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredStatementIterator listStatements( final Selector s )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredStatementIterator listStatements( final Selector s ) throws ReadDeniedException;
/**
*
@@@ -1259,11 -1204,11 +1240,10 @@@
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredResIterator listSubjectsWithProperty( final Property p )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredResIterator listSubjectsWithProperty( final Property p ) throws ReadDeniedException;
/**
*
@@@ -1331,11 -1276,11 +1311,10 @@@
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public SecuredModel read( final InputStream in, final String base )
- throws UpdateDeniedException;
- throws AccessDeniedException;
++ public SecuredModel read( final InputStream in, final String base ) throws UpdateDeniedException;
/**
*
@@@ -1349,11 -1294,11 +1328,10 @@@
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public SecuredModel read( final Reader reader, final String base )
- throws UpdateDeniedException;
- throws AccessDeniedException;
++ public SecuredModel read( final Reader reader, final String base ) throws UpdateDeniedException;
/**
*
@@@ -1375,11 -1320,11 +1353,10 @@@
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public SecuredModel read( final String url, final String lang )
- throws UpdateDeniedException;
- throws AccessDeniedException;
++ public SecuredModel read( final String url, final String lang ) throws UpdateDeniedException;
/**
*
@@@ -1395,11 -1340,11 +1372,10 @@@
* Listener will be filtered to only report events that the user can see.
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
-- public SecuredModel register( final ModelChangedListener listener )
- throws ReadDeniedException;
- throws AccessDeniedException;
++ public SecuredModel register( final ModelChangedListener listener ) throws ReadDeniedException;
/**
*
@@@ -1410,27 -1354,25 +1386,27 @@@
*/
@Override
public SecuredModel remove( final List<Statement> statements )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in baseModel.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel remove( final Model m ) throws UpdateDeniedException, DeleteDeniedException;
- public SecuredModel remove( final Model m ) throws AccessDeniedException;
++ public SecuredModel remove( final Model m ) throws DeleteDeniedException, UpdateDeniedException;;
/**
*
* @sec.graph Update
* @sec.triple Delete on SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel remove( final Resource s, final Property p, final RDFNode o ) throws UpdateDeniedException, DeleteDeniedException;
- public SecuredModel remove( final Resource s, final Property p, final RDFNode o ) throws AccessDeniedException;
++ public SecuredModel remove( final Resource s, final Property p, final RDFNode o ) throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1441,7 -1382,7 +1417,7 @@@
*/
@Override
public SecuredModel remove( final Statement s )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1452,7 -1392,7 +1428,7 @@@
*/
@Override
public SecuredModel remove( final Statement[] statements )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1463,17 -1402,16 +1439,17 @@@
*/
@Override
public SecuredModel remove( final StmtIterator iter )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in the securedModel
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel removeAll() throws UpdateDeniedException, DeleteDeniedException;
- public SecuredModel removeAll() throws AccessDeniedException;
++ public SecuredModel removeAll() throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1484,7 -1421,7 +1460,7 @@@
*/
@Override
public SecuredModel removeAll( final Resource s, final Property p,
- final RDFNode r ) throws UpdateDeniedException, DeleteDeniedException;
- final RDFNode r ) throws AccessDeniedException;
++ final RDFNode r ) throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1496,7 -1432,7 +1472,7 @@@
*/
@Override
public void removeAllReifications( final Statement s )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;;
/**
*
@@@ -1517,25 -1452,25 +1493,23 @@@
*/
@Override
public void removeReification( final ReifiedStatement rs )
- throws UpdateDeniedException, DeleteDeniedException;
- throws AccessDeniedException;
++ throws DeleteDeniedException, UpdateDeniedException;;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public String setReaderClassName( final String lang, final String className )
- throws UpdateDeniedException;
- throws AccessDeniedException;
++ public String setReaderClassName( final String lang, final String className ) throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
-- public String setWriterClassName( final String lang, final String className )
- throws UpdateDeniedException;
- throws AccessDeniedException;
++ public String setWriterClassName( final String lang, final String className ) throws UpdateDeniedException;
/**
*
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
index 329e511,7ce88b4..0fb6e2b
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredSeq.java
@@@ -34,13 -31,11 +34,14 @@@ import org.apache.jena.shared.DeleteDen
* http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#Containers
*
*/
++@SuppressWarnings("deprecation")
public interface SecuredSeq extends Seq, SecuredContainer
{
- /**
+ /** *
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li(1), o )
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredSeq add( final int index, final boolean o )
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredUnsupportedPolymorphismException.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredUnsupportedPolymorphismException.java
index 32a81be,32a81be..e5cef53
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredUnsupportedPolymorphismException.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredUnsupportedPolymorphismException.java
@@@ -28,6 -28,6 +28,11 @@@ public class SecuredUnsupportedPolymorp
UnsupportedPolymorphismException
{
++ /**
++ *
++ */
++ private static final long serialVersionUID = 4329005499222402816L;
++
public SecuredUnsupportedPolymorphismException(
final SecuredRDFNodeImpl node, final Class<?> type )
{
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
index 8810487,37d856b..52f413a
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
@@@ -347,7 -348,7 +347,7 @@@ public class SecuredModelImpl extends S
super(securityEvaluator, modelURI, holder);
this.graph = org.apache.jena.permissions.Factory.getInstance(securityEvaluator, modelURI, holder
.getBaseItem().getGraph());
-- this.holder = holder; // FIXME -- this should just access the super holder.
++ this.holder = holder;
}
private RDFNode asObject( Object o )
@@@ -1536,11 -1537,11 +1536,13 @@@
return holder.getBaseItem().getReader(lang);
}
++ @SuppressWarnings("deprecation")
@Override
public void resetRDFReaderF() {
holder.getBaseItem().resetRDFReaderF();
}
++ @SuppressWarnings("deprecation")
@Override
public String removeReader(String lang) throws IllegalArgumentException {
return holder.getBaseItem().removeReader(lang);
@@@ -1621,11 -1622,11 +1623,13 @@@
return holder.getBaseItem().getWriter(lang);
}
++ @SuppressWarnings("deprecation")
@Override
public void resetRDFWriterF() {
holder.getBaseItem().resetRDFWriterF();
}
++ @SuppressWarnings("deprecation")
@Override
public String removeWriter(String lang) throws IllegalArgumentException {
return holder.getBaseItem().removeWriter(lang);
@@@ -2485,6 -2486,6 +2489,7 @@@
return holder.getSecuredItem();
}
++ @SuppressWarnings("deprecation")
@Override
public String setReaderClassName( final String lang, final String className )
{
@@@ -2492,6 -2493,6 +2497,7 @@@
return holder.getBaseItem().setReaderClassName(lang, className);
}
++ @SuppressWarnings("deprecation")
@Override
public String setWriterClassName( final String lang, final String className )
{
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
index 7f6c511,156b5b9..d6be052
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredResourceImpl.java
@@@ -21,11 -21,10 +21,10 @@@ import org.apache.jena.datatypes.RDFDat
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.impl.ItemHolder;
-import org.apache.jena.permissions.impl.SecuredItemImpl;
+import org.apache.jena.permissions.impl.SecuredItem;
- import org.apache.jena.permissions.impl.SecuredItemImpl;
import org.apache.jena.permissions.impl.SecuredItemInvoker;
import org.apache.jena.permissions.model.SecuredModel;
import org.apache.jena.permissions.model.SecuredResource;
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
index db6b55d,db6b55d..ba19d2d
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
@@@ -44,7 -44,7 +44,6 @@@ public class SecuredAssemblerTes
model = ModelFactory.createDefaultModel();
URL url = SecuredAssemblerTest.class.getClassLoader().getResource( SecuredAssemblerTest.class.getName().replace(".", "/")+".ttl");
model.read( url.toURI().toString(), "TURTLE" );
-- //model.write( System.out, "TURTLE" );
}
@Test
http://git-wip-us.apache.org/repos/asf/jena/blob/e48966cd/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
----------------------------------------------------------------------
diff --cc jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
index edd51ba,f93d644..30f7533
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
@@@ -17,23 -17,22 +17,22 @@@
*/
package org.apache.jena.permissions.model;
- import java.net.URL;
- import java.security.Principal;
- import java.util.Set;
-
- import org.apache.http.auth.BasicUserPrincipal;
- import org.apache.jena.graph.NodeFactory;
- import org.apache.jena.permissions.Factory;
- import org.apache.jena.permissions.SecurityEvaluator;
- import org.apache.jena.permissions.model.SecuredModel;
- import org.apache.jena.rdf.model.*;
- import org.apache.jena.vocabulary.RDF;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
+ import java.net.URL ;
+ import java.security.Principal ;
+ import java.util.Set ;
+
+ import org.apache.http.auth.BasicUserPrincipal ;
+ import org.apache.jena.graph.NodeFactory ;
+ import org.apache.jena.permissions.Factory ;
+ import org.apache.jena.permissions.SecurityEvaluator ;
+ import org.apache.jena.rdf.model.* ;
+ import org.apache.jena.vocabulary.RDF ;
+ import org.junit.Assert ;
+ import org.junit.Before ;
+ import org.junit.Test ;
/**
- * Tests secured model functions against graph where only partial data is
+ * Tests secured model functions against graph where only partial data is
* available to the user.
*
*/
@@@ -296,30 -246,33 +295,30 @@@ public class SecuredModelDetailTest
return true;
}
- private boolean evaluate( Resource r )
- {
+ private boolean evaluate(Resource r) {
// a message is only available to sender or recipient
- if (r.hasProperty( RDF.type, msgType ))
- {
- return r.hasProperty( pTo, ((Principal)principal).getName() ) ||
- r.hasProperty( pFrom, ((Principal)principal).getName());
+ if (r.hasProperty(RDF.type, msgType)) {
+ return r.hasProperty(pTo, principal.getName())
+ || r.hasProperty(pFrom,
+ principal.getName());
}
- return true;
+ return true;
}
-
+
- private boolean evaluate(SecNode node) {
- if (node.equals(SecNode.ANY)) {
- return false; // all wild cards are false
+ private boolean evaluate( SecNode node )
+ {
+ if (node.equals( SecNode.ANY )) {
+ return false; // all wild cards are false
}
-
- if (node.getType().equals(SecNode.Type.URI)) {
- Resource r = model.createResource(node.getValue());
- return evaluate(r);
- } else if (node.getType().equals(SecNode.Type.Anonymous)) {
- Resource r = model.getRDFNode(
- NodeFactory.createAnon(new AnonId(node.getValue())))
- .asResource();
- return evaluate(r);
+
+ if (node.getType().equals( SecNode.Type.URI)) {
+ Resource r = model.createResource( node.getValue() );
+ return evaluate( r );
+ }
+ else if (node.getType().equals( SecNode.Type.Anonymous)) {
+ Resource r = model.getRDFNode( NodeFactory.createBlankNode( node.getValue()) ).asResource();
+ return evaluate( r );
- }
- else
- {
+ } else {
return true;
}
[04/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
index 6280a33..7913ad9 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
@@ -17,30 +17,30 @@
*/
package org.apache.jena.permissions.model;
-import java.io.* ;
-import java.net.URL ;
-import java.util.ArrayList ;
-import java.util.List ;
-import java.util.Set ;
-
-import org.apache.jena.datatypes.xsd.XSDDatatype ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
+import java.io.*;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
import org.apache.jena.permissions.*;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.graph.SecuredGraph;
import org.apache.jena.permissions.graph.SecuredPrefixMappingTest;
import org.apache.jena.permissions.model.SecuredModel;
-import org.apache.jena.rdf.model.* ;
-import org.junit.Assert ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.junit.runner.RunWith ;
-
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredModelTest
-{
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.shared.AccessDeniedException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredModelTest {
protected final MockSecurityEvaluator securityEvaluator;
protected SecuredModel securedModel;
protected Model baseModel;
@@ -48,8 +48,7 @@ public class SecuredModelTest
protected Property p;
protected Resource o;
- public SecuredModelTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredModelTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
}
@@ -58,14 +57,12 @@ public class SecuredModelTest
*
* @return
*/
- protected Model createModel()
- {
+ protected Model createModel() {
return ModelFactory.createDefaultModel();
}
@Before
- public void setup()
- {
+ public void setup() {
baseModel = createModel();
baseModel.removeAll();
securedModel = Factory.getInstance(securityEvaluator,
@@ -77,196 +74,140 @@ public class SecuredModelTest
}
@Test
- public void testAdd() throws Exception
- {
+ public void testAdd() throws Exception {
final List<Statement> stmt = baseModel.listStatements().toList();
final Set<Action> createAndUpdate = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update, Action.Create });
- try
- {
+ try {
securedModel.add(stmt);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(stmt.get(0));
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(stmt.toArray(new Statement[stmt.size()]));
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel.listStatements());
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, o);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo");
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", false);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", XSDDatatype.XSDstring);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", "en");
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -274,8 +215,7 @@ public class SecuredModelTest
}
@Test
- public void testAnonymousInModel()
- {
+ public void testAnonymousInModel() {
// test anonymous
final RDFNode rdfNode = ResourceFactory.createResource();
final RDFNode rdfNode2 = rdfNode.inModel(securedModel);
@@ -285,121 +225,89 @@ public class SecuredModelTest
}
@Test
- public void testAsRDFNode() throws Exception
- {
- securedModel.asRDFNode(NodeFactory.createURI("http://example.com/rdfNode"));
+ public void testAsRDFNode() throws Exception {
+ securedModel.asRDFNode(NodeFactory
+ .createURI("http://example.com/rdfNode"));
}
@Test
- public void testAsStatement()
- {
+ public void testAsStatement() {
final Triple t = new Triple(s.asNode(), p.asNode(), o.asNode());
- try
- {
+ try {
securedModel.asStatement(t);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testContains() throws Exception
- {
+ public void testContains() throws Exception {
final Statement stmt = baseModel.listStatements().next();
- try
- {
+ try {
securedModel.contains(stmt);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, "foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, "foo", "en");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -407,173 +315,128 @@ public class SecuredModelTest
}
@Test
- public void testContainsAll() throws Exception
- {
- try
- {
+ public void testContainsAll() throws Exception {
+ try {
securedModel.containsAll(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.containsAll(baseModel.listStatements());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateAlt() throws Exception
- {
+ public void testCreateAlt() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createAlt();
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.createAlt("foo");
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateBag() throws Exception
- {
+ public void testCreateBag() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createBag();
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.createBag("foo");
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateList() throws Exception
- {
+ public void testCreateList() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
final List<RDFNode> nodeList = new ArrayList<RDFNode>();
- try
- {
+ try {
securedModel.createList();
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
baseModel.removeAll();
- try
- {
+ try {
securedModel.createList(nodeList.iterator());
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
baseModel.removeAll();
- try
- {
+ try {
final RDFNode[] list = new RDFNode[] {
ResourceFactory.createResource(),
ResourceFactory.createResource(),
@@ -581,17 +444,13 @@ public class SecuredModelTest
ResourceFactory.createResource(), };
securedModel.createList(list);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -600,131 +459,100 @@ public class SecuredModelTest
}
@Test
- public void testCreateLiteral() throws Exception
- {
+ public void testCreateLiteral() throws Exception {
securedModel.createLiteral("foo");
securedModel.createLiteral("foo", false);
}
@Test
- public void testCreateLiteralBoolean() throws Exception
- {
+ public void testCreateLiteralBoolean() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, true);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralChar() throws Exception
- {
+ public void testCreateLiteralChar() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 'a');
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralDouble() throws Exception
- {
+ public void testCreateLiteralDouble() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1.0d);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralFloat() throws Exception
- {
+ public void testCreateLiteralFloat() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1.0f);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralInt() throws Exception
- {
+ public void testCreateLiteralInt() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -732,172 +560,131 @@ public class SecuredModelTest
}
@Test
- public void testCreateLiteralLong() throws Exception
- {
+ public void testCreateLiteralLong() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1L);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralObject() throws Exception
- {
+ public void testCreateLiteralObject() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
- securedModel.createLiteralStatement(s, p, new URL( "http://example.com/testing/URIType"));
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ try {
+ securedModel.createLiteralStatement(s, p, new URL(
+ "http://example.com/testing/URIType"));
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
e.printStackTrace();
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testDifference() throws Exception
- {
- try
- {
+ public void testDifference() throws Exception {
+ try {
securedModel.difference(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testEquals() throws Exception
- {
+ public void testEquals() throws Exception {
securedModel.equals(baseModel);
baseModel.equals(securedModel);
}
@Test
- public void testExpandPrefix() throws Exception
- {
- try
- {
+ public void testExpandPrefix() throws Exception {
+ try {
securedModel.expandPrefix("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetAlt() throws Exception
- {
+ public void testGetAlt() throws Exception {
final Resource a = baseModel
.createAlt("http://example.com/securedModel/alt");
- try
- {
+ try {
securedModel.getAlt(a);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getAlt("http://example.com/securedModel/alt");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetAnyReifiedStmt()
- {
+ public void testGetAnyReifiedStmt() {
// first with create.
final Set<Action> UCR = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create, Action.Read });
- try
- {
+ try {
securedModel.getAnyReifiedStatement(baseModel.listStatements()
.next());
- if (!securityEvaluator.evaluate(UCR))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(UCR)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(UCR))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(UCR)) {
e.printStackTrace();
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -905,357 +692,266 @@ public class SecuredModelTest
final Statement st = baseModel.listStatements().next();
baseModel.createReifiedStatement(st);
// now it is there so try with read
- try
- {
+ try {
securedModel.getAnyReifiedStatement(st);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetBag()
- {
+ public void testGetBag() {
final Resource b = baseModel
.createBag("http://example.com/securedModel/bag");
- try
- {
+ try {
securedModel.getBag(b);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getBag("http://example.com/securedModel/bag");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetGraph() throws Exception
- {
+ public void testGetGraph() throws Exception {
final Graph g = securedModel.getGraph();
Assert.assertTrue(g instanceof SecuredGraph);
EqualityTester.testInequality("getGraph test", g, baseModel.getGraph());
}
@Test
- public void testGetLock()
- {
+ public void testGetLock() {
securedModel.getLock();
}
@Test
- public void testGetProperty()
- {
+ public void testGetProperty() {
- try
- {
+ try {
securedModel.getProperty("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getProperty(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getProperty("fooNS", "foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetQNameFor() throws Exception
- {
- try
- {
+ public void testGetQNameFor() throws Exception {
+ try {
securedModel.qnameFor("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testgetRDFNode()
- {
+ public void testgetRDFNode() {
- try
- {
+ try {
securedModel.getRDFNode(NodeFactory.createURI("foo"));
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetReader()
- {
+ public void testGetReader() {
securedModel.getReader();
securedModel.getReader("TURTLE");
}
@Test
- public void testGetResource()
- {
+ public void testGetResource() {
securedModel.getResource("foo");
}
@Test
- public void testGetSeq()
- {
+ public void testGetSeq() {
final Resource s = baseModel
.createSeq("http://example.com/securedModel/seq");
- try
- {
+ try {
securedModel.getSeq(s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getSeq("http://example.com/securedModel/seq");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetWriter()
- {
+ public void testGetWriter() {
securedModel.getWriter();
securedModel.getWriter("TURTLE");
}
@Test
- public void testIndependent() throws Exception
- {
+ public void testIndependent() throws Exception {
Assert.assertFalse(securedModel.independent());
}
@Test
- public void testIntersection() throws Exception
- {
- try
- {
+ public void testIntersection() throws Exception {
+ try {
securedModel.intersection(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsClosed() throws Exception
- {
+ public void testIsClosed() throws Exception {
securedModel.isClosed();
}
@Test
- public void testIsEmpty() throws Exception
- {
- try
- {
+ public void testIsEmpty() throws Exception {
+ try {
securedModel.isEmpty();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsIsomorphicWith()
- {
- try
- {
+ public void testIsIsomorphicWith() {
+ try {
securedModel.isIsomorphicWith(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
baseModel.isIsomorphicWith(securedModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsReified()
- {
- try
- {
+ public void testIsReified() {
+ try {
securedModel.isReified(baseModel.listStatements().next());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -1263,149 +959,109 @@ public class SecuredModelTest
}
@Test
- public void testListLiteralStatements() throws Exception
- {
- try
- {
+ public void testListLiteralStatements() throws Exception {
+ try {
securedModel.listLiteralStatements(s, p, true);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, '0');
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 2.0d);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 2.0f);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 1);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testLock() throws Exception
- {
- try
- {
+ public void testLock() throws Exception {
+ try {
securedModel.lock();
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testPrefixMapping() throws Exception
- {
+ public void testPrefixMapping() throws Exception {
SecuredPrefixMappingTest.runTests(securityEvaluator, securedModel);
}
@Test
- public void testQuery() throws Exception
- {
+ public void testQuery() throws Exception {
final Selector s = new SimpleSelector();
- try
- {
+ try {
securedModel.query(s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRDFNodeInModel()
- {
+ public void testRDFNodeInModel() {
// test uri
final RDFNode rdfNode = ResourceFactory
.createResource("http://exmple.com/testInModel");
@@ -1416,8 +1072,7 @@ public class SecuredModelTest
}
@Test
- public void testReadEmpty() throws Exception
- {
+ public void testReadEmpty() throws Exception {
final Set<Action> createAndUpdate = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update, Action.Create });
@@ -1431,299 +1086,214 @@ public class SecuredModelTest
final String TTL_INPUT = "@prefix rt: <http://example.com/readTest#> . rt:1 a rt:3 .";
final String base = "http://example.com/test";
final String lang = "TURTLE";
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.xml");
securedModel.read(url.toString());
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final InputStream in = new ByteArrayInputStream(
XML_INPUT.getBytes());
securedModel.read(in, base);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final Reader reader = new StringReader(XML_INPUT);
securedModel.read(reader, base);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.ttl");
securedModel.read(url.toString(), lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final InputStream in = new ByteArrayInputStream(
TTL_INPUT.getBytes());
securedModel.read(in, base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final Reader reader = new StringReader(TTL_INPUT);
securedModel.read(reader, base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.ttl");
securedModel.read(url.toString(), base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
}
@Test
- public void testRemove() throws Exception
- {
+ public void testRemove() throws Exception {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
final List<Statement> stmt = baseModel.listStatements().toList();
- try
- {
+ try {
securedModel.remove(baseModel.listStatements().toList());
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(stmt.get(0));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(stmt.toArray(new Statement[stmt.size()]));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel.listStatements());
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(s, p, o);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -1731,302 +1301,225 @@ public class SecuredModelTest
}
@Test
- public void testRemoveAll() throws Exception
- {
+ public void testRemoveAll() throws Exception {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
- try
- {
+ try {
securedModel.removeAll();
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
// put some data back
baseModel.add(s, p, o);
- try
- {
+ try {
securedModel.removeAll(s, p, o);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemoveAllReifications()
- {
+ public void testRemoveAllReifications() {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
final List<Statement> stmt = baseModel.listStatements().toList();
baseModel.createReifiedStatement(stmt.get(0));
- try
- {
+ try {
securedModel.removeAllReifications(stmt.get(0));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRequiredProperty()
- {
+ public void testRequiredProperty() {
- try
- {
+ try {
securedModel.getRequiredProperty(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSize() throws Exception
- {
- try
- {
+ public void testSize() throws Exception {
+ try {
securedModel.size();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testUnion() throws Exception
- {
- try
- {
+ public void testUnion() throws Exception {
+ try {
securedModel.union(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
baseModel.union(securedModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testVariableInModel()
- {
- try
- {
+ public void testVariableInModel() {
+ try {
final RDFNode rdfNode = ResourceFactory
.createTypedLiteral("yeehaw");
final RDFNode rdfNode2 = rdfNode.inModel(securedModel);
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
Assert.assertEquals(
"Should have placed RDFNode in secured securedModel",
securedModel, rdfNode2.getModel());
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testWrapAsResource() throws Exception
- {
- securedModel.wrapAsResource(NodeFactory.createURI("http://example.com/rdfNode"));
+ public void testWrapAsResource() throws Exception {
+ securedModel.wrapAsResource(NodeFactory
+ .createURI("http://example.com/rdfNode"));
}
@Test
- public void testWrite() throws Exception
- {
+ public void testWrite() throws Exception {
final OutputStream out = new ByteArrayOutputStream();
final Writer writer = new CharArrayWriter();
final String lang = "TURTLE";
- try
- {
+ try {
securedModel.write(out);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(out, lang);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer, lang);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(out, lang, "http://example.com/securedGraph");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer, lang, "http://example.com/securedGraph");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
index affa7df..803a973 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
@@ -17,37 +17,33 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredProperty;
import org.apache.jena.permissions.model.impl.SecuredPropertyImpl;
-import org.apache.jena.rdf.model.Property ;
-import org.apache.jena.rdf.model.ResourceFactory ;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.ResourceFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredPropertyTest extends SecuredResourceTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredPropertyTest extends SecuredResourceTest {
- public SecuredPropertyTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredPropertyTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredProperty getSecuredProperty()
- {
+ private SecuredProperty getSecuredProperty() {
return (SecuredProperty) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final Property p = ResourceFactory
.createProperty("http://example.com/testProperty");
@@ -55,22 +51,16 @@ public class SecuredPropertyTest extends SecuredResourceTest
}
@Test
- public void testGetOrdinal()
- {
- try
- {
+ public void testGetOrdinal() {
+ try {
getSecuredProperty().getOrdinal();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
[05/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
index fd4331f..2915662 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
@@ -19,39 +19,36 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredAlt;
import org.apache.jena.permissions.model.impl.SecuredAltImpl;
-import org.apache.jena.rdf.model.Alt ;
-import org.apache.jena.rdf.model.ResourceFactory ;
+import org.apache.jena.rdf.model.Alt;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.shared.AccessDeniedException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredAltTest extends SecuredContainerTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredAltTest extends SecuredContainerTest {
private Alt alt;
- public SecuredAltTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredAltTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredAlt getSecuredAlt()
- {
+ private SecuredAlt getSecuredAlt() {
return (SecuredAlt) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
alt = baseModel.getAlt("http://example.com/testContainer");
setSecuredRDFNode(SecuredAltImpl.getInstance(securedModel, alt), alt);
@@ -60,259 +57,190 @@ public class SecuredAltTest extends SecuredContainerTest
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this, RDF.li(1), o )
- * @throws AccessDeniedException
*/
@Test
- public void testGetDefault()
- {
+ public void testGetDefault() {
alt.add("SomeDummyItem");
- try
- {
+ try {
getSecuredAlt().getDefault();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredAlt().getDefaultAlt();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredAlt().getDefaultBag();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredAlt().getDefaultSeq();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultBoolean()
- {
+ public void testGetDefaultBoolean() {
alt.add(true);
- try
- {
+ try {
getSecuredAlt().getDefaultBoolean();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultByte()
- {
+ public void testGetDefaultByte() {
alt.add(Byte.MAX_VALUE);
- try
- {
+ try {
getSecuredAlt().getDefaultByte();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultChar()
- {
+ public void testGetDefaultChar() {
alt.add('c');
- try
- {
+ try {
getSecuredAlt().getDefaultChar();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultDouble()
- {
+ public void testGetDefaultDouble() {
alt.add(3.14d);
- try
- {
+ try {
getSecuredAlt().getDefaultDouble();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultFloat()
- {
+ public void testGetDefaultFloat() {
alt.add(3.14f);
- try
- {
+ try {
getSecuredAlt().getDefaultFloat();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultInt()
- {
+ public void testGetDefaultInt() {
alt.add(2);
- try
- {
+ try {
getSecuredAlt().getDefaultInt();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultLanguage()
- {
+ public void testGetDefaultLanguage() {
alt.add("SomeDummyItem");
- try
- {
+ try {
getSecuredAlt().getDefaultLanguage();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredAlt().getDefaultLiteral();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -320,115 +248,81 @@ public class SecuredAltTest extends SecuredContainerTest
}
@Test
- public void testGetDefaultLong()
- {
+ public void testGetDefaultLong() {
alt.add(3L);
- try
- {
+ try {
getSecuredAlt().getDefaultLong();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultResource()
- {
+ public void testGetDefaultResource() {
alt.setDefault(ResourceFactory
.createResource("http://example.com/exampleResourec"));
- try
- {
+ try {
getSecuredAlt().getDefaultResource();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
/*
- * try
- * {
- * ResourceF f = ResourceFactory.getInstance();
- * getSecuredAlt().getDefaultResource( f );
- * if (!securityEvaluator.evaluate(Action.Read))
- * {
- * Assert.fail("Should have thrown AccessDenied Exception");
- * }
- * }
- * catch (final AccessDeniedException e)
- * {
- * if (securityEvaluator.evaluate(Action.Read))
- * {
- * Assert.fail(String
- * .format("Should not have thrown AccessDenied Exception: %s - %s",
- * e, e.getTriple()));
- * }
- * }
+ * try { ResourceF f = ResourceFactory.getInstance();
+ * getSecuredAlt().getDefaultResource( f ); if
+ * (!securityEvaluator.evaluate(Action.Read)) {
+ * Assert.fail("Should have thrown AccessDenied Exception"); } } catch
+ * (final AccessDeniedException e) { if
+ * (securityEvaluator.evaluate(Action.Read)) { Assert.fail(String
+ * .format("Should not have thrown AccessDenied Exception: %s - %s", e,
+ * e.getTriple())); } }
*/
@Test
- public void testGetDefaultShort()
- {
+ public void testGetDefaultShort() {
alt.setDefault(Short.MAX_VALUE);
- try
- {
+ try {
getSecuredAlt().getDefaultShort();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDefaultString()
- {
+ public void testGetDefaultString() {
alt.setDefault("Hello World");
- try
- {
+ try {
getSecuredAlt().getDefaultString();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -436,219 +330,183 @@ public class SecuredAltTest extends SecuredContainerTest
}
@Test
- public void testSetDefaultBoolean()
- {
+ public void testSetDefaultBoolean() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault(true);
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultChar()
- {
+ public void testSetDefaultChar() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault('c');
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultDouble()
- {
+ public void testSetDefaultDouble() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault(3.14d);
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultFloat()
- {
+ public void testSetDefaultFloat() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault(3.14f);
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultLong()
- {
+ public void testSetDefaultLong() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault(2L);
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultObject()
- {
+ public void testSetDefaultObject() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
final Object o = 2;
getSecuredAlt().setDefault(o);
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultResource()
- {
+ public void testSetDefaultResource() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault(
ResourceFactory
.createResource("http://example.com/resource"));
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultString()
- {
+ public void testSetDefaultString() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault("test");
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSetDefaultStringAndLang()
- {
+ public void testSetDefaultStringAndLang() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredAlt().setDefault("dos", "es");
- if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)
+ || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt()
+ .iterator().hasNext())) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
index 33c1fb0..83a905e 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
@@ -20,23 +20,20 @@ package org.apache.jena.permissions.model;
import org.apache.jena.permissions.MockSecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.model.impl.SecuredBagImpl;
-import org.apache.jena.rdf.model.Bag ;
+import org.apache.jena.rdf.model.Bag;
import org.junit.Before;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredBagTest extends SecuredContainerTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredBagTest extends SecuredContainerTest {
- public SecuredBagTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredBagTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final Bag bag = baseModel.getBag("http://example.com/testContainer");
bag.add("SomeDummyItem");
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredContainerTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredContainerTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredContainerTest.java
index 2d80725..e7ffa65 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredContainerTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredContainerTest.java
@@ -19,39 +19,36 @@ package org.apache.jena.permissions.model;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredContainer;
import org.apache.jena.permissions.model.impl.SecuredContainerImpl;
-import org.apache.jena.rdf.model.Container ;
-import org.apache.jena.rdf.model.ResourceFactory ;
-import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.rdf.model.Container;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.shared.AccessDeniedException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public abstract class SecuredContainerTest extends SecuredResourceTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public abstract class SecuredContainerTest extends SecuredResourceTest {
- public SecuredContainerTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredContainerTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredContainer getSecuredContainer()
- {
+ private SecuredContainer getSecuredContainer() {
return (SecuredContainer) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final Container container = baseModel
.getBag("http://example.com/testContainer");
@@ -62,22 +59,16 @@ public abstract class SecuredContainerTest extends SecuredResourceTest
}
@Test
- public void test()
- {
- try
- {
+ public void test() {
+ try {
getSecuredContainer().size();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -86,174 +77,127 @@ public abstract class SecuredContainerTest extends SecuredResourceTest
/**
* @sec.graph Update
* @sec.triple Create SecTriple( this, RDF.li, o );
- * @throws AccessDeniedException
*/
@Test
- public void testAdd()
- {
+ public void testAdd() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
- try
- {
+ try {
getSecuredContainer().add(true);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add('c');
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add(3.14D);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add(3.14F);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add(2L);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
final Object o = Integer.valueOf("1234");
- try
- {
+ try {
getSecuredContainer().add(o);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add(
ResourceFactory
.createResource("http://example.com/testResource"));
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add("foo");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().add("dos", "esp");
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -261,216 +205,158 @@ public abstract class SecuredContainerTest extends SecuredResourceTest
}
@Test
- public void testContains()
- {
- try
- {
+ public void testContains() {
+ try {
getSecuredContainer().contains(true);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains('c');
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains(3.14D);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
.format("Should not have thrown AccessDenied Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains(3.14F);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains(2L);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
final Object o = Integer.valueOf("1234");
- try
- {
+ try {
getSecuredContainer().contains(o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains(
ResourceFactory
.createResource("http://example.com/testResource"));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
.format("Should not have thrown AccessDenied Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
getSecuredContainer().contains("dos", "esp");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIterator()
- {
- try
- {
+ public void testIterator() {
+ try {
getSecuredContainer().iterator();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemove()
- {
+ public void testRemove() {
final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Delete });
final Statement s = baseModel.listStatements().next();
- try
- {
+ try {
getSecuredContainer().remove(s);
- if (!securityEvaluator.evaluate(perms))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(perms)) {
+ Assert.fail("Should have thrown AccessDeniedException");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(perms))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(perms)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredLiteralTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredLiteralTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredLiteralTest.java
index 446bdc4..55d599d 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredLiteralTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredLiteralTest.java
@@ -17,55 +17,46 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.datatypes.DatatypeFormatException ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.datatypes.DatatypeFormatException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredLiteral;
import org.apache.jena.permissions.model.impl.SecuredLiteralImpl;
-import org.apache.jena.rdf.model.Literal ;
-import org.apache.jena.rdf.model.ResourceFactory ;
-import org.apache.jena.rdf.model.ResourceRequiredException ;
-import org.apache.jena.shared.BadBooleanException ;
-import org.apache.jena.shared.BadCharLiteralException ;
-import org.junit.Assert ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.junit.runner.RunWith ;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.rdf.model.ResourceRequiredException;
+import org.apache.jena.shared.BadBooleanException;
+import org.apache.jena.shared.BadCharLiteralException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredLiteralTest extends SecuredRDFNodeTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredLiteralTest extends SecuredRDFNodeTest {
- public SecuredLiteralTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredLiteralTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredLiteral getSecuredLiteral()
- {
+ private SecuredLiteral getSecuredLiteral() {
return (SecuredLiteral) getSecuredRDFNode();
}
@Test
- public void sameValueAs()
- {
- try
- {
+ public void sameValueAs() {
+ try {
getSecuredLiteral().sameValueAs(
ResourceFactory.createPlainLiteral("Junk"));
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -73,395 +64,281 @@ public class SecuredLiteralTest extends SecuredRDFNodeTest
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
Literal l = ResourceFactory.createTypedLiteral("literal");
setSecuredRDFNode(SecuredLiteralImpl.getInstance(securedModel, l), l);
}
@Test
- public void testAsLiteral()
- {
+ public void testAsLiteral() {
getSecuredLiteral().asLiteral();
}
@Test
- public void testAsResource()
- {
- try
- {
+ public void testAsResource() {
+ try {
getSecuredLiteral().asResource();
Assert.fail("Should have thrown ResoruceRequiredException");
- }
- catch (final ResourceRequiredException e)
- {
+ } catch (final ResourceRequiredException e) {
// expected
}
}
@Test
- public void testGetBoolean()
- {
- try
- {
+ public void testGetBoolean() {
+ try {
getSecuredLiteral().getBoolean();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | BadBooleanException e )
- {
+ } catch (final DatatypeFormatException | BadBooleanException e) {
// expected
}
}
@Test
- public void testGetByte()
- {
- try
- {
+ public void testGetByte() {
+ try {
getSecuredLiteral().getByte();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetChar()
- {
- try
- {
+ public void testGetChar() {
+ try {
getSecuredLiteral().getChar();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | BadCharLiteralException e )
- {
+ } catch (final DatatypeFormatException | BadCharLiteralException e) {
// expected
}
}
@Test
- public void testGetDatatype()
- {
- try
- {
+ public void testGetDatatype() {
+ try {
getSecuredLiteral().getDatatype();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDatatypeURI()
- {
- try
- {
+ public void testGetDatatypeURI() {
+ try {
getSecuredLiteral().getDatatypeURI();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetDouble()
- {
- try
- {
+ public void testGetDouble() {
+ try {
getSecuredLiteral().getDouble();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetFloat()
- {
- try
- {
+ public void testGetFloat() {
+ try {
getSecuredLiteral().getFloat();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetInt()
- {
- try
- {
+ public void testGetInt() {
+ try {
getSecuredLiteral().getInt();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetLanguage()
- {
- try
- {
+ public void testGetLanguage() {
+ try {
getSecuredLiteral().getLanguage();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetLexicalForm()
- {
- try
- {
+ public void testGetLexicalForm() {
+ try {
getSecuredLiteral().getLexicalForm();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetLong()
- {
- try
- {
+ public void testGetLong() {
+ try {
getSecuredLiteral().getLong();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetShort()
- {
- try
- {
+ public void testGetShort() {
+ try {
getSecuredLiteral().getShort();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetString()
- {
- try
- {
+ public void testGetString() {
+ try {
getSecuredLiteral().getString();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- catch (final DatatypeFormatException | NumberFormatException e )
- {
+ } catch (final DatatypeFormatException | NumberFormatException e) {
// expected
}
}
@Test
- public void testGetValue()
- {
- try
- {
+ public void testGetValue() {
+ try {
getSecuredLiteral().getValue();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsWellFormedXML()
- {
- try
- {
+ public void testIsWellFormedXML() {
+ try {
getSecuredLiteral().isWellFormedXML();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
index 28b33ba..edd51ba 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelDetailTest.java
@@ -22,18 +22,18 @@ import java.security.Principal;
import java.util.Set;
import org.apache.http.auth.BasicUserPrincipal;
-import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.NodeFactory;
import org.apache.jena.permissions.Factory;
import org.apache.jena.permissions.SecurityEvaluator;
import org.apache.jena.permissions.model.SecuredModel;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.vocabulary.RDF ;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.vocabulary.RDF;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
- * Tests secured model functions against graph where only partial data is
+ * Tests secured model functions against graph where only partial data is
* available to the user.
*
*/
@@ -43,288 +43,337 @@ public class SecuredModelDetailTest {
private Model baseModel;
private SecuredModel securedModel;
private DetailEvaluator secEval;
- private Property pTo = ResourceFactory.createProperty("http://example.com/to");
+ private Property pTo = ResourceFactory
+ .createProperty("http://example.com/to");
private Property pFrom = ResourceFactory
- .createProperty( "http://example.com/from");
-
+ .createProperty("http://example.com/from");
+
@Before
- public void setup()
- {
+ public void setup() {
baseModel = ModelFactory.createDefaultModel();
baseModel.removeAll();
- URL url = SecuredModelDetailTest.class.getClassLoader().getResource( "org/apache/jena/permissions/model/detail.ttl");
- baseModel.read( url.toExternalForm() );
- secEval = new DetailEvaluator( baseModel );
+ URL url = SecuredModelDetailTest.class.getClassLoader().getResource(
+ "org/apache/jena/permissions/model/detail.ttl");
+ baseModel.read(url.toExternalForm());
+ secEval = new DetailEvaluator(baseModel);
securedModel = Factory.getInstance(secEval,
"http://example.com/detailModelTest", baseModel);
}
-
@Test
- public void testContains()
- {
+ public void testContains() {
secEval.setPrincipal("darla");
- /* darla can only add values to msg4
- ex:msg4 rdf:type ex:msg;
- ex:to "darla" ;
- ex:from "bob" ;
- ex:subj "bob to darla 1"
+ /*
+ * darla can only add values to msg4 ex:msg4 rdf:type ex:msg; ex:to
+ * "darla" ; ex:from "bob" ; ex:subj "bob to darla 1"
*/
-
- Resource s = ResourceFactory.createResource( String.format( NS_FMT, "msg3") );
- Assert.assertTrue( "should contain msg3", baseModel.contains( s, null ));
- Assert.assertFalse( "should not see msg3", securedModel.contains( s, null ));
- Assert.assertTrue( "Sould contain a resource msg3", baseModel.containsResource( s));
- Assert.assertFalse( "Should not contain a resource msg3'", securedModel.containsResource( s) );
-
- s = ResourceFactory.createResource( String.format( NS_FMT, "msg4") );
- Assert.assertTrue( "should contain msg4", baseModel.contains( s, null ));
- Assert.assertTrue( "should see msg4", securedModel.contains( s, null ));
- Assert.assertTrue( "Sould contain a resource msg4", baseModel.containsResource( s));
- Assert.assertTrue( "Should contain a resource msg4'", securedModel.containsResource( s) );
-
- Assert.assertTrue( "Sould contain a to 'bob'", baseModel.contains( null, pTo, "bob"));
- Assert.assertFalse( "Should not see to 'bob'", securedModel.contains( null, pTo, "bob") );
-
- Assert.assertTrue( "Sould contain a from 'bob'", baseModel.contains( null, pFrom, "bob"));
- Assert.assertTrue( "Should see from 'bob'", securedModel.contains( null, pFrom, "bob") );
+
+ Resource s = ResourceFactory.createResource(String.format(NS_FMT,
+ "msg3"));
+ Assert.assertTrue("should contain msg3", baseModel.contains(s, null));
+ Assert.assertFalse("should not see msg3",
+ securedModel.contains(s, null));
+ Assert.assertTrue("Sould contain a resource msg3",
+ baseModel.containsResource(s));
+ Assert.assertFalse("Should not contain a resource msg3'",
+ securedModel.containsResource(s));
+
+ s = ResourceFactory.createResource(String.format(NS_FMT, "msg4"));
+ Assert.assertTrue("should contain msg4", baseModel.contains(s, null));
+ Assert.assertTrue("should see msg4", securedModel.contains(s, null));
+ Assert.assertTrue("Sould contain a resource msg4",
+ baseModel.containsResource(s));
+ Assert.assertTrue("Should contain a resource msg4'",
+ securedModel.containsResource(s));
+
+ Assert.assertTrue("Sould contain a to 'bob'",
+ baseModel.contains(null, pTo, "bob"));
+ Assert.assertFalse("Should not see to 'bob'",
+ securedModel.contains(null, pTo, "bob"));
+
+ Assert.assertTrue("Sould contain a from 'bob'",
+ baseModel.contains(null, pFrom, "bob"));
+ Assert.assertTrue("Should see from 'bob'",
+ securedModel.contains(null, pFrom, "bob"));
}
-
+
@Test
- public void testListObjects()
- {
+ public void testListObjects() {
secEval.setPrincipal("darla");
- /* darla can only add values to msg4
- ex:msg4 rdf:type ex:msg;
- ex:to "darla" ;
- ex:from "bob" ;
- ex:subj "bob to darla 1"
+ /*
+ * darla can only add values to msg4 ex:msg4 rdf:type ex:msg; ex:to
+ * "darla" ; ex:from "bob" ; ex:subj "bob to darla 1"
*/
-
- Assert.assertTrue( baseModel.listObjects().toList().size() > 4);
- Assert.assertEquals( 4, securedModel.listObjects().toList().size());
-
- Assert.assertTrue( baseModel.listObjectsOfProperty( pFrom ).toList().size() > 1);
- Assert.assertEquals( 1, securedModel.listObjectsOfProperty( pFrom ).toList().size());
-
- Resource s = ResourceFactory.createResource( String.format( NS_FMT, "msg3"));
- Assert.assertEquals( 1, baseModel.listObjectsOfProperty( s, pFrom).toList().size());
- Assert.assertEquals( 0, securedModel.listObjectsOfProperty( s, pFrom ).toList().size());
-
- s = ResourceFactory.createResource( String.format( NS_FMT, "msg4"));
- Assert.assertEquals( 1, baseModel.listObjectsOfProperty( s, pFrom).toList().size());
- Assert.assertEquals( 1, securedModel.listObjectsOfProperty( s, pFrom ).toList().size());
+
+ Assert.assertTrue(baseModel.listObjects().toList().size() > 4);
+ Assert.assertEquals(4, securedModel.listObjects().toList().size());
+
+ Assert.assertTrue(baseModel.listObjectsOfProperty(pFrom).toList()
+ .size() > 1);
+ Assert.assertEquals(1, securedModel.listObjectsOfProperty(pFrom)
+ .toList().size());
+
+ Resource s = ResourceFactory.createResource(String.format(NS_FMT,
+ "msg3"));
+ Assert.assertEquals(1, baseModel.listObjectsOfProperty(s, pFrom)
+ .toList().size());
+ Assert.assertEquals(0, securedModel.listObjectsOfProperty(s, pFrom)
+ .toList().size());
+
+ s = ResourceFactory.createResource(String.format(NS_FMT, "msg4"));
+ Assert.assertEquals(1, baseModel.listObjectsOfProperty(s, pFrom)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listObjectsOfProperty(s, pFrom)
+ .toList().size());
}
-
+
@Test
public void testListResources() {
secEval.setPrincipal("darla");
- /* darla can only add values to msg4
- ex:msg4 rdf:type ex:msg;
- ex:to "darla" ;
- ex:from "bob" ;
- ex:subj "bob to darla 1"
+ /*
+ * darla can only add values to msg4 ex:msg4 rdf:type ex:msg; ex:to
+ * "darla" ; ex:from "bob" ; ex:subj "bob to darla 1"
*/
- Assert.assertEquals( 5, baseModel.listResourcesWithProperty( pFrom ).toList().size());
- Assert.assertEquals( 1, securedModel.listResourcesWithProperty( pFrom ).toList().size());
-
+ Assert.assertEquals(5, baseModel.listResourcesWithProperty(pFrom)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listResourcesWithProperty(pFrom)
+ .toList().size());
+
RDFNode o = ResourceFactory.createPlainLiteral("bob");
- Assert.assertEquals( 3, baseModel.listResourcesWithProperty( pFrom, o ).toList().size());
- Assert.assertEquals( 1, securedModel.listResourcesWithProperty( pFrom, o ).toList().size());
- Assert.assertEquals( 1, baseModel.listResourcesWithProperty( pTo, o ).toList().size());
- Assert.assertEquals( 0, securedModel.listResourcesWithProperty( pTo, o ).toList().size());
-
- Assert.assertEquals( 4, baseModel.listResourcesWithProperty( null, o ).toList().size());
- Assert.assertEquals( 1, securedModel.listResourcesWithProperty( null, o ).toList().size());
-
+ Assert.assertEquals(3, baseModel.listResourcesWithProperty(pFrom, o)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listResourcesWithProperty(pFrom, o)
+ .toList().size());
+ Assert.assertEquals(1, baseModel.listResourcesWithProperty(pTo, o)
+ .toList().size());
+ Assert.assertEquals(0, securedModel.listResourcesWithProperty(pTo, o)
+ .toList().size());
+
+ Assert.assertEquals(4, baseModel.listResourcesWithProperty(null, o)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listResourcesWithProperty(null, o)
+ .toList().size());
+
o = ResourceFactory.createPlainLiteral("alice");
- Assert.assertEquals( 4, baseModel.listResourcesWithProperty( null, o ).toList().size());
- Assert.assertEquals( 0, securedModel.listResourcesWithProperty( null, o ).toList().size());
+ Assert.assertEquals(4, baseModel.listResourcesWithProperty(null, o)
+ .toList().size());
+ Assert.assertEquals(0, securedModel.listResourcesWithProperty(null, o)
+ .toList().size());
}
-
+
@Test
- public void testListStatements()
- {
+ public void testListStatements() {
secEval.setPrincipal("darla");
- /* darla can only add values to msg4
- ex:msg4 rdf:type ex:msg;
- ex:to "darla" ;
- ex:from "bob" ;
- ex:subj "bob to darla 1"
+ /*
+ * darla can only add values to msg4 ex:msg4 rdf:type ex:msg; ex:to
+ * "darla" ; ex:from "bob" ; ex:subj "bob to darla 1"
*/
- Assert.assertEquals( 20, baseModel.listStatements().toList().size());
- Assert.assertEquals( 4, securedModel.listStatements().toList().size());
-
+ Assert.assertEquals(20, baseModel.listStatements().toList().size());
+ Assert.assertEquals(4, securedModel.listStatements().toList().size());
+
RDFNode o = ResourceFactory.createPlainLiteral("bob");
- Assert.assertEquals( 1, baseModel.listStatements( null, pTo, o).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( null, pTo, o).toList().size());
- Assert.assertEquals( 3, baseModel.listStatements( null, pFrom, o).toList().size());
- Assert.assertEquals( 1, securedModel.listStatements( null, pFrom, o).toList().size());
-
- Resource s = ResourceFactory.createResource( String.format( NS_FMT, "msg3"));
- Assert.assertEquals( 4, baseModel.listStatements( s, null, (RDFNode)null).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( s, null, (RDFNode)null).toList().size());
-
- Assert.assertEquals( 1, baseModel.listStatements( s, pTo, (RDFNode)null).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( s, pTo, (RDFNode)null).toList().size());
-
- Assert.assertEquals( 0, baseModel.listStatements( s, pTo, o).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( s, pTo, o).toList().size());
+ Assert.assertEquals(1, baseModel.listStatements(null, pTo, o).toList()
+ .size());
+ Assert.assertEquals(0, securedModel.listStatements(null, pTo, o)
+ .toList().size());
+ Assert.assertEquals(3, baseModel.listStatements(null, pFrom, o)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listStatements(null, pFrom, o)
+ .toList().size());
+
+ Resource s = ResourceFactory.createResource(String.format(NS_FMT,
+ "msg3"));
+ Assert.assertEquals(4, baseModel
+ .listStatements(s, null, (RDFNode) null).toList().size());
+ Assert.assertEquals(0,
+ securedModel.listStatements(s, null, (RDFNode) null).toList()
+ .size());
+
+ Assert.assertEquals(1, baseModel.listStatements(s, pTo, (RDFNode) null)
+ .toList().size());
+ Assert.assertEquals(0,
+ securedModel.listStatements(s, pTo, (RDFNode) null).toList()
+ .size());
+
+ Assert.assertEquals(0, baseModel.listStatements(s, pTo, o).toList()
+ .size());
+ Assert.assertEquals(0, securedModel.listStatements(s, pTo, o).toList()
+ .size());
o = ResourceFactory.createPlainLiteral("chuck");
- Assert.assertEquals( 1, baseModel.listStatements( s, pTo, o).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( s, pTo, o).toList().size());
-
-
- s = ResourceFactory.createResource( String.format( NS_FMT, "msg4"));
- Assert.assertEquals( 4, baseModel.listStatements( s, null, (RDFNode)null).toList().size());
- Assert.assertEquals( 4, securedModel.listStatements( s, null, (RDFNode)null).toList().size());
-
- Assert.assertEquals( 1, baseModel.listStatements( s, pTo, (RDFNode)null).toList().size());
- Assert.assertEquals( 1, securedModel.listStatements( s, pTo, (RDFNode)null).toList().size());
-
- Assert.assertEquals( 0, baseModel.listStatements( s, pTo, o).toList().size());
- Assert.assertEquals( 0, securedModel.listStatements( s, pTo, o).toList().size());
+ Assert.assertEquals(1, baseModel.listStatements(s, pTo, o).toList()
+ .size());
+ Assert.assertEquals(0, securedModel.listStatements(s, pTo, o).toList()
+ .size());
+
+ s = ResourceFactory.createResource(String.format(NS_FMT, "msg4"));
+ Assert.assertEquals(4, baseModel
+ .listStatements(s, null, (RDFNode) null).toList().size());
+ Assert.assertEquals(4,
+ securedModel.listStatements(s, null, (RDFNode) null).toList()
+ .size());
+
+ Assert.assertEquals(1, baseModel.listStatements(s, pTo, (RDFNode) null)
+ .toList().size());
+ Assert.assertEquals(1,
+ securedModel.listStatements(s, pTo, (RDFNode) null).toList()
+ .size());
+
+ Assert.assertEquals(0, baseModel.listStatements(s, pTo, o).toList()
+ .size());
+ Assert.assertEquals(0, securedModel.listStatements(s, pTo, o).toList()
+ .size());
o = ResourceFactory.createPlainLiteral("darla");
- Assert.assertEquals( 1, baseModel.listStatements( s, pTo, o).toList().size());
- Assert.assertEquals( 1, securedModel.listStatements( s, pTo, o).toList().size());
+ Assert.assertEquals(1, baseModel.listStatements(s, pTo, o).toList()
+ .size());
+ Assert.assertEquals(1, securedModel.listStatements(s, pTo, o).toList()
+ .size());
}
-
+
@Test
- public void testListSubjects()
- {
+ public void testListSubjects() {
secEval.setPrincipal("darla");
- /* darla can only add values to msg4
- ex:msg4 rdf:type ex:msg;
- ex:to "darla" ;
- ex:from "bob" ;
- ex:subj "bob to darla 1"
+ /*
+ * darla can only add values to msg4 ex:msg4 rdf:type ex:msg; ex:to
+ * "darla" ; ex:from "bob" ; ex:subj "bob to darla 1"
*/
- Assert.assertEquals( 5, baseModel.listSubjects().toList().size());
- Assert.assertEquals( 1, securedModel.listSubjects().toList().size());
-
- Assert.assertEquals( 5, baseModel.listSubjectsWithProperty( pTo ).toList().size());
- Assert.assertEquals( 1, securedModel.listSubjectsWithProperty( pTo ).toList().size());
-
+ Assert.assertEquals(5, baseModel.listSubjects().toList().size());
+ Assert.assertEquals(1, securedModel.listSubjects().toList().size());
+
+ Assert.assertEquals(5, baseModel.listSubjectsWithProperty(pTo).toList()
+ .size());
+ Assert.assertEquals(1, securedModel.listSubjectsWithProperty(pTo)
+ .toList().size());
+
RDFNode o = ResourceFactory.createPlainLiteral("darla");
- Assert.assertEquals( 1, baseModel.listSubjectsWithProperty( pTo, o ).toList().size());
- Assert.assertEquals( 1, securedModel.listSubjectsWithProperty( pTo, o ).toList().size());
-
+ Assert.assertEquals(1, baseModel.listSubjectsWithProperty(pTo, o)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listSubjectsWithProperty(pTo, o)
+ .toList().size());
+
o = ResourceFactory.createPlainLiteral("bob");
- Assert.assertEquals( 1, baseModel.listSubjectsWithProperty( pTo, o ).toList().size());
- Assert.assertEquals( 0, securedModel.listSubjectsWithProperty( pTo, o ).toList().size());
-
- Assert.assertEquals( 4, baseModel.listSubjectsWithProperty( null, o ).toList().size());
- Assert.assertEquals( 1, securedModel.listSubjectsWithProperty( null, o ).toList().size());
-
+ Assert.assertEquals(1, baseModel.listSubjectsWithProperty(pTo, o)
+ .toList().size());
+ Assert.assertEquals(0, securedModel.listSubjectsWithProperty(pTo, o)
+ .toList().size());
+
+ Assert.assertEquals(4, baseModel.listSubjectsWithProperty(null, o)
+ .toList().size());
+ Assert.assertEquals(1, securedModel.listSubjectsWithProperty(null, o)
+ .toList().size());
+
}
-
+
/**
- * An example evaluator that only provides access ot messages in the graph that
- * are from or to the principal.
+ * An example evaluator that only provides access ot messages in the graph
+ * that are from or to the principal.
*
*/
private class DetailEvaluator implements SecurityEvaluator {
-
+
private Principal principal;
private Model model;
- private RDFNode msgType = ResourceFactory.createResource( "http://example.com/msg" );
- private Property pTo = ResourceFactory.createProperty( "http://example.com/to" );
- private Property pFrom = ResourceFactory.createProperty( "http://example.com/from" );
-
+ private RDFNode msgType = ResourceFactory
+ .createResource("http://example.com/msg");
+ private Property pTo = ResourceFactory
+ .createProperty("http://example.com/to");
+ private Property pFrom = ResourceFactory
+ .createProperty("http://example.com/from");
+
/**
*
- * @param model The graph we are going to evaluate against.
+ * @param model
+ * The graph we are going to evaluate against.
*/
- public DetailEvaluator( Model model )
- {
+ public DetailEvaluator(Model model) {
this.model = model;
}
-
+
@Override
- public boolean evaluate(Object principal, Action action, SecNode graphIRI) {
+ public boolean evaluate(Object principal, Action action,
+ SecNode graphIRI) {
// we allow any action on a graph.
return true;
}
- private boolean evaluate( Resource r )
- {
+ private boolean evaluate(Resource r) {
// a message is only available to sender or recipient
- if (r.hasProperty( RDF.type, msgType ))
- {
- return r.hasProperty( pTo, ((Principal)principal).getName() ) ||
- r.hasProperty( pFrom, ((Principal)principal).getName());
+ if (r.hasProperty(RDF.type, msgType)) {
+ return r.hasProperty(pTo, principal.getName())
+ || r.hasProperty(pFrom,
+ principal.getName());
}
- return true;
+ return true;
}
-
- private boolean evaluate( SecNode node )
- {
- if (node.equals( SecNode.ANY )) {
- return false; // all wild cards are false
- }
-
- if (node.getType().equals( SecNode.Type.URI)) {
- Resource r = model.createResource( node.getValue() );
- return evaluate( r );
- }
- else if (node.getType().equals( SecNode.Type.Anonymous)) {
- Resource r = model.getRDFNode( NodeFactory.createAnon( new AnonId( node.getValue()) ) ).asResource();
- return evaluate( r );
+
+ private boolean evaluate(SecNode node) {
+ if (node.equals(SecNode.ANY)) {
+ return false; // all wild cards are false
}
- else
- {
+
+ if (node.getType().equals(SecNode.Type.URI)) {
+ Resource r = model.createResource(node.getValue());
+ return evaluate(r);
+ } else if (node.getType().equals(SecNode.Type.Anonymous)) {
+ Resource r = model.getRDFNode(
+ NodeFactory.createAnon(new AnonId(node.getValue())))
+ .asResource();
+ return evaluate(r);
+ } else {
return true;
}
}
-
- private boolean evaluate( SecTriple triple ) {
- return evaluate( triple.getSubject()) &&
- evaluate( triple.getObject()) &&
- evaluate( triple.getPredicate());
+
+ private boolean evaluate(SecTriple triple) {
+ return evaluate(triple.getSubject())
+ && evaluate(triple.getObject())
+ && evaluate(triple.getPredicate());
}
-
+
@Override
- public boolean evaluate(Object principal, Action action, SecNode graphIRI, SecTriple triple) {
- return evaluate( triple );
+ public boolean evaluate(Object principal, Action action,
+ SecNode graphIRI, SecTriple triple) {
+ return evaluate(triple);
}
@Override
- public boolean evaluate(Object principal, Set<Action> actions, SecNode graphIRI) {
+ public boolean evaluate(Object principal, Set<Action> actions,
+ SecNode graphIRI) {
return true;
}
@Override
- public boolean evaluate(Object principal, Set<Action> actions, SecNode graphIRI,
- SecTriple triple) {
- return evaluate( triple );
+ public boolean evaluate(Object principal, Set<Action> actions,
+ SecNode graphIRI, SecTriple triple) {
+ return evaluate(triple);
}
@Override
- public boolean evaluateAny(Object principal, Set<Action> actions, SecNode graphIRI) {
+ public boolean evaluateAny(Object principal, Set<Action> actions,
+ SecNode graphIRI) {
return true;
}
@Override
- public boolean evaluateAny(Object principal, Set<Action> actions, SecNode graphIRI,
- SecTriple triple) {
- return evaluate( triple );
+ public boolean evaluateAny(Object principal, Set<Action> actions,
+ SecNode graphIRI, SecTriple triple) {
+ return evaluate(triple);
}
@Override
- public boolean evaluateUpdate(Object principal, SecNode graphIRI, SecTriple from, SecTriple to) {
- return evaluate( from ) && evaluate( to );
+ public boolean evaluateUpdate(Object principal, SecNode graphIRI,
+ SecTriple from, SecTriple to) {
+ return evaluate(from) && evaluate(to);
}
- public void setPrincipal( String userName )
- {
- if (userName == null)
- {
+ public void setPrincipal(String userName) {
+ if (userName == null) {
principal = null;
}
- principal = new BasicUserPrincipal( userName );
+ principal = new BasicUserPrincipal(userName);
}
+
@Override
public Principal getPrincipal() {
return principal;
[07/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
index f506308..a8b5530 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredModel.java
@@ -28,7 +28,8 @@ import java.util.List ;
import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.graph.SecuredGraph;
import org.apache.jena.permissions.graph.SecuredPrefixMapping;
import org.apache.jena.permissions.model.impl.SecuredNodeIterator;
@@ -36,6 +37,8 @@ import org.apache.jena.permissions.model.impl.SecuredRSIterator;
import org.apache.jena.permissions.model.impl.SecuredResIterator;
import org.apache.jena.permissions.model.impl.SecuredStatementIterator;
import org.apache.jena.rdf.model.* ;
+import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.shared.PropertyNotFoundException ;
/**
@@ -52,165 +55,183 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
* @sec.graph Update
* @sec.triple Create for each statement as a triple.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final List<Statement> statements )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create for each statement in the securedModel as a triple.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredModel add( final Model m ) throws AccessDeniedException;
+ public SecuredModel add( final Model m ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the triple SecTriple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Resource s, final Property p, final RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the triple SecTriple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Resource s, final Property p, final String o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the triple SecTriple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Resource s, final Property p,
final String o, final boolean wellFormed )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the triple SecTriple(s,p,literal(lex,datatype))
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Resource s, final Property p,
final String lex, final RDFDatatype datatype )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the triple SecTriple(s,p,literal(o,l,false))
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Resource s, final Property p,
- final String o, final String l ) throws AccessDeniedException;
+ final String o, final String l ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create the statement as a triple
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredModel add( final Statement s ) throws AccessDeniedException;
+ public SecuredModel add( final Statement s ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create all the statements as triples.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final Statement[] statements )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create all the statements as triples.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel add( final StmtIterator iter )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final boolean o ) throws AccessDeniedException;
+ final boolean o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final char o ) throws AccessDeniedException;
+ final char o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final double o ) throws AccessDeniedException;
+ final double o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final float o ) throws AccessDeniedException;
+ final float o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final int o ) throws AccessDeniedException;
+ final int o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final Literal o ) throws AccessDeniedException;
+ final Literal o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredModel addLiteral( final Resource s, final Property p,
- final long o ) throws AccessDeniedException;
+ final long o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create triple(s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
@Deprecated
public SecuredModel addLiteral( final Resource s, final Property p,
- final Object o ) throws AccessDeniedException;
+ final Object o ) throws UpdateDeniedException, AddDeniedException;
@Override
public SecuredRDFNode asRDFNode( final Node n );
@@ -221,10 +242,12 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.graph Update it t does not exist
* @sec.triple Read if t does exist
* @sec.triple Create if t does exist
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
+ * @throws ReadException
*/
public SecuredStatement asStatement( final Triple t )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException, ReadDeniedException;
@Override
public SecuredModel begin();
@@ -235,199 +258,203 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, SecNode.ANY )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final Resource s, final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final Resource s, final Property p, final RDFNode o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final Resource s, final Property p, final String o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o,l,null) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean contains( final Resource s, final Property p,
- final String o, final String l ) throws AccessDeniedException;
+ final String o, final String l ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read s as a triple with null replaced by SecNode.ANY
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final Statement s ) throws AccessDeniedException;
+ public boolean contains( final Statement s ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read every statement in securedModel.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsAll( final Model model )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read every statement
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsAll( final StmtIterator iter )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read any statement in securedModel to be included in check, if
* no
* statement in securedModel can be read will return false;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsAny( final Model model )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read any statement in iter to be included in check, if no
* statement in iter can be read will return false;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsAny( final StmtIterator iter )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final boolean o ) throws AccessDeniedException;
+ final boolean o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final char o ) throws AccessDeniedException;
+ final char o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final double o ) throws AccessDeniedException;
+ final double o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final float o ) throws AccessDeniedException;
+ final float o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final int o ) throws AccessDeniedException;
+ final int o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, literal(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final long o ) throws AccessDeniedException;
+ final long o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, typedLiteral(o) )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsLiteral( final Resource s, final Property p,
- final Object o ) throws AccessDeniedException;
+ final Object o ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( s, p, resource) where SecTriple(s,p,resource) is in the
* securedModel.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean containsResource( final RDFNode r )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.ANY, RDF.type, Rdf.Alt)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredAlt createAlt() throws AccessDeniedException;
+ public SecuredAlt createAlt() throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( uri, RDF.type, Rdf.Alt)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredAlt createAlt( final String uri )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.ANY, RDF.type, Rdf.Bag)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredBag createBag() throws AccessDeniedException;
+ public SecuredBag createBag() throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( uri, RDF.type, Rdf.Bag)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredBag createBag( final String uri )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
- public SecuredRDFList createList() throws AccessDeniedException;
+ public SecuredRDFList createList() throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
@@ -436,11 +463,12 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* RDF.first.asNode(),
* member.asNode())
* @sec.triple Create SecTriple(SecNode.ANY, RDF.rest.asNode(), SecNode.ANY)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredRDFList createList( final Iterator<? extends RDFNode> members )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
@@ -449,92 +477,102 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* RDF.first.asNode(),
* member.asNode())
* @sec.triple Create SecTriple(SecNode.ANY, RDF.rest.asNode(), SecNode.ANY)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredRDFList createList( final RDFNode[] members )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final boolean o ) throws AccessDeniedException;
+ final Property p, final boolean o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final char o ) throws AccessDeniedException;
+ final Property p, final char o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final double o ) throws AccessDeniedException;
+ final Property p, final double o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final float o ) throws AccessDeniedException;
+ final Property p, final float o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final int o ) throws AccessDeniedException;
+ final Property p, final int o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final long o ) throws AccessDeniedException;
+ final Property p, final long o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredStatement createLiteralStatement( final Resource s,
- final Property p, final Object o ) throws AccessDeniedException;
+ final Property p, final Object o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Property createProperty( final String uri )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s,p,o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Property createProperty( final String nameSpace,
- final String localName ) throws AccessDeniedException;
+ final String localName ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
@@ -544,11 +582,13 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple create SecTriple( SecNode.Future, RDF.subject,
* t.getPredicate() )
* @sec.triple create SecTriple( SecNode.Future, RDF.subject, t.getObject() )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
public ReifiedStatement createReifiedStatement( final Statement s )
- throws AccessDeniedException;
+ throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
/**
* @sec.graph Update
@@ -556,41 +596,48 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple create SecTriple( uri, RDF.subject, t.getSubject() )
* @sec.triple create SecTriple( uri, RDF.subject, t.getPredicate() )
* @sec.triple create SecTriple( uri, RDF.subject, t.getObject() )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
public ReifiedStatement createReifiedStatement( final String uri,
- final Statement s ) throws AccessDeniedException;
+ final Statement s ) throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Read s as a triple
- * @sec.triple create SecTriple( SecNode.FUTURE, SecNode.IGNORE,
+ * @sec.triple Create SecTriple( SecNode.FUTURE, SecNode.IGNORE,
* SecNode.IGNORE )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredResource createResource() throws AccessDeniedException;
+ public SecuredResource createResource() throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Read s as a triple
- * @sec.triple create SecTriple( Anonymous(id), SecNode.IGNORE,
+ * @sec.triple Create SecTriple( Anonymous(id), SecNode.IGNORE,
* SecNode.IGNORE )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredResource createResource( final AnonId id )
- throws AccessDeniedException;
+ throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.type, type )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredResource createResource( final Resource type )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
@Override
@Deprecated
@@ -604,11 +651,13 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.graph Create if uri does not exist
* @sec.triple Read if SecTriple( uri, RDF.type, type ) exists
* @sec.triple Create if SecTriple( uri, RDF.type, type ) does not exist
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredResource createResource( final String uri, final Resource type )
- throws AccessDeniedException;
+ throws UpdateDeniedException, ReadDeniedException, AddDeniedException;
@Override
@Deprecated
@@ -617,67 +666,73 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.type, RDF.Alt )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
- public SecuredSeq createSeq() throws AccessDeniedException;
+ public SecuredSeq createSeq() throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( uri, RDF.type, RDF.Alt )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
public SecuredSeq createSeq( final String uri )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
public SecuredStatement createStatement( final Resource s,
- final Property p, final RDFNode o ) throws AccessDeniedException;
+ final Property p, final RDFNode o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
public SecuredStatement createStatement( final Resource s,
- final Property p, final String o ) throws AccessDeniedException;
+ final Property p, final String o ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws AccessDeniedRuntimeException
*/
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final boolean wellFormed )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s, p, literal(o,l,false ))
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final String l )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( s, p, literal(o,l,wellFormed )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @trhows AddDeniedException
*/
@Override
public SecuredStatement createStatement( final Resource s,
final Property p, final String o, final String l,
- final boolean wellFormed ) throws AccessDeniedException;
+ final boolean wellFormed ) throws UpdateDeniedException, AddDeniedException;
@Override
public SecuredLiteral createTypedLiteral( final boolean v );
@@ -725,43 +780,44 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
* @sec.graph Read
* @sec.triple Read for every triple contributed to the difference.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Model difference( final Model model ) throws AccessDeniedException;
+ public Model difference( final Model model ) throws ReadDeniedException;
/**
* @sec.graph Read if read lock is requested
* @sec.graph Update if write lock is requested
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public void enterCriticalSection( final boolean readLockRequested )
- throws AccessDeniedException;
+ throws ReadDeniedException, UpdateDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public String expandPrefix( final String prefixed )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( resource, RDF.type, RDF.alt )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredAlt getAlt( final Resource r ) throws AccessDeniedException;
+ public SecuredAlt getAlt( final Resource r ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( uri, RDF.type, RDF.alt )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredAlt getAlt( final String uri ) throws AccessDeniedException;
+ public SecuredAlt getAlt( final String uri ) throws ReadDeniedException;
/**
* @sec.graph Read if statement exists
@@ -779,27 +835,29 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* reification did not exist
* @sec.triple Create SecTriple( result, RDF.object, s.getObject() ) if
* reification did not exist
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredResource getAnyReifiedStatement( final Statement s )
- throws AccessDeniedException;
+ throws ReadDeniedException, UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( resource, RDF.type, RDF.Bag )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredBag getBag( final Resource r ) throws AccessDeniedException;
+ public SecuredBag getBag( final Resource r ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple( uri, RDF.type, RDF.Bag )
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredBag getBag( final String uri ) throws AccessDeniedException;
+ public SecuredBag getBag( final String uri ) throws ReadDeniedException;
@Override
public SecuredGraph getGraph();
@@ -807,35 +865,35 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
* @sec.graph Read
* @sec.triple Read on the returned statement.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatement getProperty( final Resource s, final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public Property getProperty( final String uri )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public Property getProperty( final String nameSpace, final String localName )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read if the node exists
* @sec.graph Update if the node does not exist
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public RDFNode getRDFNode( final Node n ) throws AccessDeniedException;
+ public RDFNode getRDFNode( final Node n ) throws ReadDeniedException;
/**
* .
@@ -850,13 +908,13 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read on SecTriple(s, p, SecNode.ANY) if
* PropertyNotFoundException
* was thrown
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws PropertyNotFoundException
*/
@Override
public SecuredStatement getRequiredProperty( final Resource s,
final Property p ) throws PropertyNotFoundException,
- AccessDeniedException;
+ ReadDeniedException;
@Override
public SecuredResource getResource( final String uri );
@@ -869,173 +927,172 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
*
* @sec.graph Read
* @sec.triple Read on SecTriple(resource, RDF.type, RDF.Seq)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredSeq getSeq( final Resource r ) throws AccessDeniedException;
+ public SecuredSeq getSeq( final Resource r ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on SecTriple(uri, RDF.type, RDF.Seq)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredSeq getSeq( final String uri ) throws AccessDeniedException;
+ public SecuredSeq getSeq( final String uri ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples contributed to the new securedModel.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Model intersection( final Model model ) throws AccessDeniedException;
+ public Model intersection( final Model model ) throws ReadDeniedException;
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isEmpty() throws AccessDeniedException;
+ public boolean isEmpty() throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read all compared triples. Triples that can not be read will
* not be compared.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean isIsomorphicWith( final Model g )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on s as triple
* @sec.triple Read on at least one set reified statements.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isReified( final Statement s ) throws AccessDeniedException;
+ public boolean isReified( final Statement s ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listLiteralStatements(
final Resource subject, final Property predicate,
- final boolean object ) throws AccessDeniedException;
+ final boolean object ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listLiteralStatements(
final Resource subject, final Property predicate, final char object )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listLiteralStatements(
final Resource subject, final Property predicate,
- final double object ) throws AccessDeniedException;
+ final double object ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
-
@Override
public SecuredStatementIterator listLiteralStatements(
final Resource subject, final Property predicate, final float object )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listLiteralStatements(
final Resource subject, final Property predicate, final long object )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public NsIterator listNameSpaces() throws AccessDeniedException;
+ public NsIterator listNameSpaces() throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each RDFNode returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredNodeIterator<RDFNode> listObjects() throws AccessDeniedException;
+ public SecuredNodeIterator<RDFNode> listObjects() throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each RDFNode returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredNodeIterator<RDFNode> listObjectsOfProperty( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each RDFNode returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredNodeIterator<RDFNode> listObjectsOfProperty( final Resource s,
- final Property p ) throws AccessDeniedException;
+ final Property p ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each Reified statement returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredRSIterator listReifiedStatements()
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on each Reified statement returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredRSIterator listReifiedStatements( final Statement st )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
@@ -1043,11 +1100,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
@@ -1055,12 +1112,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
-
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final boolean o ) throws AccessDeniedException;
+ final boolean o ) throws ReadDeniedException;
/**
*
@@ -1068,12 +1124,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
-
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final char o ) throws AccessDeniedException;
+ final char o ) throws ReadDeniedException;
/**
*
@@ -1081,11 +1136,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final double o ) throws AccessDeniedException;
+ final double o ) throws ReadDeniedException;
/**
*
@@ -1093,11 +1148,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final float o ) throws AccessDeniedException;
+ final float o ) throws ReadDeniedException;
/**
*
@@ -1105,11 +1160,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final long o ) throws AccessDeniedException;
+ final long o ) throws ReadDeniedException;
/**
*
@@ -1117,11 +1172,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned;
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final Object o ) throws AccessDeniedException;
+ final Object o ) throws ReadDeniedException;
/**
*
@@ -1129,63 +1184,63 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listResourcesWithProperty( final Property p,
- final RDFNode o ) throws AccessDeniedException;
+ final RDFNode o ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listStatements()
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listStatements( final Resource s,
- final Property p, final RDFNode o ) throws AccessDeniedException;
+ final Property p, final RDFNode o ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listStatements( final Resource subject,
final Property predicate, final String object )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listStatements( final Resource subject,
final Property predicate, final String object, final String lang )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all triples returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listStatements( final Selector s )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
@@ -1193,10 +1248,10 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredResIterator listSubjects() throws AccessDeniedException;
+ public SecuredResIterator listSubjects() throws ReadDeniedException;
/**
*
@@ -1204,11 +1259,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listSubjectsWithProperty( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
@@ -1216,11 +1271,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listSubjectsWithProperty( final Property p,
- final RDFNode o ) throws AccessDeniedException;
+ final RDFNode o ) throws ReadDeniedException;
/**
*
@@ -1228,11 +1283,11 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listSubjectsWithProperty( final Property p,
- final String o ) throws AccessDeniedException;
+ final String o ) throws ReadDeniedException;
/**
*
@@ -1240,19 +1295,19 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
* @sec.triple Read at least one SecTriple( resource, p, o ) for each
* resource
* returned
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResIterator listSubjectsWithProperty( final Property p,
- final String o, final String l ) throws AccessDeniedException;
+ final String o, final String l ) throws ReadDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredPrefixMapping lock() throws AccessDeniedException;
+ public SecuredPrefixMapping lock() throws ReadDeniedException;
@Override
public SecuredModel notifyEvent( final Object e );
@@ -1260,242 +1315,252 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String qnameFor( final String uri ) throws AccessDeniedException;
+ public String qnameFor( final String uri ) throws ReadDeniedException;
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredModel query( final Selector s ) throws AccessDeniedException;
+ public SecuredModel query( final Selector s ) throws ReadDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final InputStream in, final String base )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final InputStream in, final String base,
- final String lang ) throws AccessDeniedException;
+ final String lang ) throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final Reader reader, final String base )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final Reader reader, final String base,
- final String lang ) throws AccessDeniedException;
+ final String lang ) throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
- public SecuredModel read( final String url ) throws AccessDeniedException;
+ public SecuredModel read( final String url ) throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final String url, final String lang )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredModel read( final String url, final String base,
- final String lang ) throws AccessDeniedException;
+ final String lang ) throws UpdateDeniedException;
/**
*
* Listener will be filtered to only report events that the user can see.
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel register( final ModelChangedListener listener )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in statments.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredModel remove( final List<Statement> statements )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in baseModel.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel remove( final Model m ) throws AccessDeniedException;
+ public SecuredModel remove( final Model m ) throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on SecTriple( s, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel remove( final Resource s, final Property p, final RDFNode o ) throws AccessDeniedException;
+ public SecuredModel remove( final Resource s, final Property p, final RDFNode o ) throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on statment.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredModel remove( final Statement s )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in statments.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredModel remove( final Statement[] statements )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in iter.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredModel remove( final StmtIterator iter )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement in the securedModel
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredModel removeAll() throws AccessDeniedException;
+ public SecuredModel removeAll() throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every statement identified by SecTriple( s,p,o)
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredModel removeAll( final Resource s, final Property p,
- final RDFNode r ) throws AccessDeniedException;
+ final RDFNode r ) throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every reification statement for each statement in
* statments.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public void removeAllReifications( final Statement s )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public SecuredPrefixMapping removeNsPrefix( final String prefix )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Update
* @sec.triple Delete on every reification statement fore each statement in
* rs.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public void removeReification( final ReifiedStatement rs )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public String setReaderClassName( final String lang, final String className )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
public String setWriterClassName( final String lang, final String className )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String shortForm( final String uri ) throws AccessDeniedException;
+ public String shortForm( final String uri ) throws ReadDeniedException;
/**
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public long size() throws AccessDeniedException;
+ public long size() throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements contributed to the union.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Model union( final Model model ) throws AccessDeniedException;
+ public Model union( final Model model ) throws ReadDeniedException;
@Override
public SecuredModel unregister( final ModelChangedListener listener );
@@ -1507,60 +1572,60 @@ public interface SecuredModel extends Model, SecuredPrefixMapping
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final OutputStream out )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final OutputStream out, final String lang )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final OutputStream out, final String lang,
- final String base ) throws AccessDeniedException;
+ final String base ) throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final Writer writer )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final Writer writer, final String lang )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
*
* @sec.graph Read
* @sec.triple Read on all statements that are written.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredModel write( final Writer writer, final String lang,
- final String base ) throws AccessDeniedException;
+ final String base ) throws ReadDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredProperty.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredProperty.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredProperty.java
index 9a5add6..222ebef 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredProperty.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredProperty.java
@@ -17,7 +17,7 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.rdf.model.Property ;
/**
@@ -30,9 +30,9 @@ public interface SecuredProperty extends SecuredResource, Property
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public int getOrdinal() throws AccessDeniedException;
+ public int getOrdinal() throws ReadDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFList.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFList.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFList.java
index b629333..6552a26 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFList.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFList.java
@@ -21,9 +21,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.rdf.model.* ;
+import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
import org.apache.jena.util.iterator.ExtendedIterator ;
public interface SecuredRDFList extends RDFList, SecuredResource
@@ -33,10 +36,11 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.graph Update
* @sec.triple Create SecTriple(SecNode.FUTURE, listFirst(), value)
* @sec.triple Create SecTriple(SecNode.FUTURE, listFirst(), listNil())
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public void add( final RDFNode value ) throws AccessDeniedException;
+ public void add( final RDFNode value ) throws UpdateDeniedException, AddDeniedException;
/**
* Resulting list will contain the readable nodes from this list
@@ -44,10 +48,12 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, value )
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.rest, this )
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public RDFList append( final Iterator<? extends RDFNode> nodes )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* Resulting list will contain the readable nodes from this list
@@ -56,9 +62,11 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, value )
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.rest, this )
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public RDFList append( final RDFList list ) throws AccessDeniedException;
+ public RDFList append( final RDFList list ) throws UpdateDeniedException, AddDeniedException;
/**
* Uses the security settings for the application of the function calls.
@@ -67,11 +75,11 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.graph Read
* @sec.triple Read (to be included in the calculation)
* @sec.triple other permissions required by the function.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* graph Read or other permissions are not met
*/
@Override
- public void apply( final ApplyFn fn ) throws AccessDeniedException;
+ public void apply( final ApplyFn fn ) throws ReadDeniedException;
/**
* This method is intended to provide the capabilities to apply functions
@@ -89,10 +97,10 @@ public interface SecuredRDFList extends RDFList, SecuredResource
*
* @sec.graph Read
* @sec.triple Read and constraints
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
public void apply( Set<Action> constraints, final ApplyFn fn )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.triple Read for triples containing the returned RDFNodes.
@@ -106,39 +114,42 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, node ) for each
* node in
* nodes.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public void concatenate( final Iterator<? extends RDFNode> nodes )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, node ) for each
* node in
* list.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
- public void concatenate( final RDFList list ) throws AccessDeniedException;
+ public void concatenate( final RDFList list ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, value )
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.rest, this )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredRDFList cons( final RDFNode value )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean contains( final RDFNode value ) throws AccessDeniedException;
+ public boolean contains( final RDFNode value ) throws ReadDeniedException;
/**
* Creates a copy of this list comprising the readable elements of this
@@ -147,9 +158,11 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* @sec.triple Read on each triple to be read.
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.first, value )
* @sec.triple Create SecTriple( SecNode.FUTURE, RDF.rest, this )
+ * @throws ReadDeniedException
+ * @throws AddDeniedException
*/
@Override
- public SecuredRDFList copy();
+ public SecuredRDFList copy() throws ReadDeniedException, AddDeniedException;
/**
* Answer the node that is the i'th element of the list, assuming that the
@@ -159,13 +172,13 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* List may be shortened by security constraints.
*
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public SecuredRDFNode get( final int i ) throws AccessDeniedException,
+ public SecuredRDFNode get( final int i ) throws ReadDeniedException,
EmptyListException, ListIndexException, InvalidListException;
/**
@@ -175,11 +188,11 @@ public interface SecuredRDFList extends RDFList, SecuredResource
*
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
*/
@Override
- public RDFNode getHead() throws AccessDeniedException, EmptyListException;
+ public RDFNode getHead() throws ReadDeniedException, EmptyListException;
/**
* The value that is at the tail of the list.
@@ -188,77 +201,78 @@ public interface SecuredRDFList extends RDFList, SecuredResource
*
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public SecuredRDFList getTail() throws AccessDeniedException,
+ public SecuredRDFList getTail() throws ReadDeniedException,
EmptyListException, ListIndexException, InvalidListException;
/**
* @sec.graph Read
+ * @throws ReadDeniedException
*/
@Override
- public String getValidityErrorMessage() throws AccessDeniedException;
+ public String getValidityErrorMessage() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public int indexOf( final RDFNode value ) throws AccessDeniedException,
+ public int indexOf( final RDFNode value ) throws ReadDeniedException,
EmptyListException, ListIndexException, InvalidListException;
/**
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
public int indexOf( final RDFNode value, final int start )
- throws AccessDeniedException, EmptyListException,
+ throws ReadDeniedException, EmptyListException,
ListIndexException, InvalidListException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isEmpty() throws AccessDeniedException;
+ public boolean isEmpty() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean isValid() throws AccessDeniedException, EmptyListException,
+ public boolean isValid() throws ReadDeniedException, EmptyListException,
ListIndexException, InvalidListException;
/**
* @sec.graph Read
* @sec.triple Read for triple containing value to be included in the result.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public ExtendedIterator<RDFNode> iterator() throws AccessDeniedException;
+ public ExtendedIterator<RDFNode> iterator() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read + requiredPerms for triple containing value to be
* included in the result.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
public ExtendedIterator<RDFNode> iterator( Set<Action> requiredPerms )
- throws AccessDeniedException, EmptyListException,
+ throws ReadDeniedException, EmptyListException,
ListIndexException, InvalidListException;
/**
@@ -268,14 +282,14 @@ public interface SecuredRDFList extends RDFList, SecuredResource
*
* @sec.graph Read
* @sec.triple Read for triple containing value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
public Object reduce( final ReduceFn fn, final Object initial )
- throws AccessDeniedException, EmptyListException,
+ throws ReadDeniedException, EmptyListException,
ListIndexException, InvalidListException;
/**
@@ -292,123 +306,129 @@ public interface SecuredRDFList extends RDFList, SecuredResource
* The reduction function
* @param initial
* The initial state for the ruduce value.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
public Object reduce( Set<Action> requiredActions, final ReduceFn fn,
- final Object initial ) throws AccessDeniedException,
+ final Object initial ) throws ReadDeniedException,
EmptyListException, ListIndexException, InvalidListException;
/**
* @sec.graph Update
* @sec.triple Delete for triple containing value.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public RDFList remove( final RDFNode val ) throws AccessDeniedException;
+ public RDFList remove( final RDFNode val ) throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete for all triples.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
@Deprecated
- public void removeAll() throws AccessDeniedException;
+ public void removeAll() throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete for the head triple.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public RDFList removeHead() throws AccessDeniedException;
+ public RDFList removeHead() throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete for triple containing value.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public void removeList() throws AccessDeniedException;
+ public void removeList() throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
- * @sec.triple Update for triplie i, and value.
- * @throws AccessDeniedException
+ * @sec.triple Update for triple i, and value.
+ * @throws UpdateDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
public SecuredRDFNode replace( final int i, final RDFNode value )
- throws AccessDeniedException;
+ throws UpdateDeniedException;
/**
* @sec.graph Read
* @sec.triple Read for triples included in the comparison.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
public boolean sameListAs( final RDFList list )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Create for triple containing value.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
public SecuredRDFNode setHead( final RDFNode value )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
*/
@Override
- public void setStrict( final boolean strict ) throws AccessDeniedException;
+ public void setStrict( final boolean strict ) throws UpdateDeniedException;
/**
* Size may be modified by security constraionts.
*
* @sec.graph Read
* @sec.triple Read for triples counted in the result.
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
*/
@Override
- public int size() throws AccessDeniedException;
+ public int size() throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Create for triple containing value.
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredRDFList with( final RDFNode value )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFNode.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFNode.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFNode.java
index fee3a91..e320469 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFNode.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredRDFNode.java
@@ -18,7 +18,7 @@
package org.apache.jena.permissions.model;
import org.apache.jena.graph.Node ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.impl.SecuredItem;
import org.apache.jena.rdf.model.Model ;
import org.apache.jena.rdf.model.RDFNode ;
@@ -33,27 +33,27 @@ public interface SecuredRDFNode extends RDFNode, SecuredItem
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public Node asNode() throws AccessDeniedException;
+ public Node asNode() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public <T extends RDFNode> boolean canAs( final Class<T> view )
- throws AccessDeniedException;
+ throws ReadDeniedException;
@Override
public SecuredModel getModel();
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public RDFNode inModel( final Model m ) throws AccessDeniedException;
+ public RDFNode inModel( final Model m ) throws ReadDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredReifiedStatement.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredReifiedStatement.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredReifiedStatement.java
index 471f718..1eea2dc 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredReifiedStatement.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredReifiedStatement.java
@@ -17,7 +17,8 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
+
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.rdf.model.ReifiedStatement ;
/**
@@ -30,9 +31,9 @@ public interface SecuredReifiedStatement extends ReifiedStatement,
{
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public SecuredStatement getStatement();
+ public SecuredStatement getStatement() throws ReadDeniedException;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredResource.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredResource.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredResource.java
index 45576e7..8f9ce38 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredResource.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/SecuredResource.java
@@ -18,9 +18,12 @@
package org.apache.jena.permissions.model;
import org.apache.jena.datatypes.RDFDatatype ;
-import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.ReadDeniedException;
+import org.apache.jena.permissions.UpdateDeniedException;
import org.apache.jena.permissions.model.impl.SecuredStatementIterator;
import org.apache.jena.rdf.model.* ;
+import org.apache.jena.shared.AddDeniedException;
+import org.apache.jena.shared.DeleteDeniedException;
/**
* The interface for secured Resource instances.
@@ -36,101 +39,112 @@ public interface SecuredResource extends Resource, SecuredRDFNode
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public SecuredResource addLiteral( final Property p, final boolean o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property p, final char o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, value, d )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property value, final double d )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, value, d )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property value, final float d )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property p, final Literal o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property p, final long o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addLiteral( final Property p, final Object o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addProperty( final Property p, final RDFNode o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addProperty( final Property p, final String o )
- throws AccessDeniedException;
+ throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, literal(lexicalForm,datatype) )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addProperty( final Property p, final String lexicalForm,
- final RDFDatatype datatype ) throws AccessDeniedException;
+ final RDFDatatype datatype ) throws UpdateDeniedException, AddDeniedException;
/**
* @sec.graph Update
* @sec.triple Create (this, p, o )
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws AddDeniedException
*/
@Override
public Resource addProperty( final Property p, final String o,
- final String l ) throws AccessDeniedException;
+ final String l ) throws UpdateDeniedException, AddDeniedException;
@Override
public SecuredResource asResource();
@@ -143,191 +157,193 @@ public interface SecuredResource extends Resource, SecuredRDFNode
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean equals( final Object o ) throws AccessDeniedException;
+ public boolean equals( final Object o ) throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public AnonId getId() throws AccessDeniedException;
+ public AnonId getId() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getLocalName() throws AccessDeniedException;
+ public String getLocalName() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getNameSpace() throws AccessDeniedException;
+ public String getNameSpace() throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatement getProperty( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredResource getPropertyResourceValue( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatement getRequiredProperty( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public String getURI() throws AccessDeniedException;
+ public String getURI() throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final boolean o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final char o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final double o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final float o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final long o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasLiteral( final Property p, final Object o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean hasProperty( final Property p ) throws AccessDeniedException;
+ public boolean hasProperty( final Property p ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasProperty( final Property p, final RDFNode o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,o)
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasProperty( final Property p, final String o )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read SecTriple(this,p,literal(o,l))
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public boolean hasProperty( final Property p, final String o, final String l )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
- public boolean hasURI( final String uri ) throws AccessDeniedException;
+ public boolean hasURI( final String uri ) throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read on returned Statements
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listProperties()
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Read
* @sec.triple Read on returned Statements
- * @throws AccessDeniedException
+ * @throws ReadDeniedException
*/
@Override
public SecuredStatementIterator listProperties( final Property p )
- throws AccessDeniedException;
+ throws ReadDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete on associated Statements
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
public SecuredResource removeAll( final Property p )
- throws AccessDeniedException;
+ throws UpdateDeniedException, DeleteDeniedException;
/**
* @sec.graph Update
* @sec.triple Delete on all Statements
- * @throws AccessDeniedException
+ * @throws UpdateDeniedException
+ * @throws DeleteDeniedException
*/
@Override
- public SecuredResource removeProperties() throws AccessDeniedException;
+ public SecuredResource removeProperties() throws UpdateDeniedException, DeleteDeniedException;
}