Author: adrianc
Date: Wed Dec 23 18:27:42 2009
New Revision: 893591
URL: http://svn.apache.org/viewvc?rev=893591&view=rev
Log:
Cleaned up the generics in the AccessController interfaces/classes.
Modified:
ofbiz/branches/executioncontext20090812/BranchReadMe.txt
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/AccessController.java
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ExecutionContext.java
ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
Modified: ofbiz/branches/executioncontext20090812/BranchReadMe.txt
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/BranchReadMe.txt?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/BranchReadMe.txt (original)
+++ ofbiz/branches/executioncontext20090812/BranchReadMe.txt Wed Dec 23
18:27:42 2009
@@ -73,9 +73,9 @@
2009-08-28: Permissions checking has been implemented. The code has
a few bugs, and there are places where the ExecutionContext isn't being
passed along, so OFBiz won't run with the AuthorizationManager enabled.
-Consequently, the AuthorizationManager is disabled by default. It still
-"pretends" to check permissions, but it always grants access. You can
-enable it with a property in api.properties.
+Consequently, the AuthorizationManager is disabled by default. When it
+is disabled, it still "pretends" to check permissions, but it always
+grants access. You can enable it with a property in api.properties.
When a user first logs in, all of their permissions are gathered from the
security entities and are used to assemble a tree-like Java structure.
@@ -84,3 +84,10 @@
the tree, accumulating permissions along the way. This is how permission
inheritance is achieved. The permission object is then queried if the user
has the requested permission and the result is returned to the artifact.
+
+---------------------------------------------------------------------
+
+2009-12-23: This branch will not be synchronized with the trunk from now on.
+I tried to do a merge from the trunk and there were too many conflicts to
+resolve. When the time comes to implement the security-aware artifacts in
+the trunk, the handful of affected classes can be ported over manually.
Modified:
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java
Wed Dec 23 18:27:42 2009
@@ -27,7 +27,7 @@
* separate the permissions-checking logic from the artifacts
* that use it.
*/
-public interface AccessController<E> {
+public interface AccessController {
/** Returns silently if the user has been granted
<code>permission</code>
* access for the current artifact, throws
<code>AccessControlException</code>
@@ -51,7 +51,7 @@
* were specified for the current artifact, or the original
* <code>List</code> otherwise
*/
- public List<E> applyFilters(List<E> list);
+ public <E> List<E> applyFilters(List<E> list);
/** Applies permission filters to a <code>ListIterator</code>. The
* returned <code>ListIterator</code> is security-aware, so methods
@@ -63,6 +63,6 @@
* were specified for the current artifact, or the original
* <code>ListIterator</code> otherwise
*/
- public ListIterator<E> applyFilters(ListIterator<E> list);
+ public <E> ListIterator<E> applyFilters(ListIterator<E> list);
}
Modified:
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
Wed Dec 23 18:27:42 2009
@@ -74,7 +74,7 @@
String location = template.getName();
ExecutionContext executionContext = (ExecutionContext)
contextBean.getWrappedObject();
executionContext.pushExecutionArtifact(new
GenericExecutionArtifact(location, artifactId));
- AccessController<?> accessController =
executionContext.getAccessController();
+ AccessController accessController =
executionContext.getAccessController();
try {
accessController.checkPermission(permission);
body.render(env.getOut());
Modified:
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
Wed Dec 23 18:27:42 2009
@@ -48,7 +48,7 @@
*
* @return An <code>AccessController</code> instance
*/
- public AccessController<?> getAccessController();
+ public AccessController getAccessController();
/** Returns the currency unit of measure.
*
@@ -57,7 +57,7 @@
public String getCurrencyUom();
/** Returns the current execution path. Artifacts in the path are separated
- * with a slash.
+ * with a forward slash.
*
* @return The current execution path
*/
Modified:
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
Wed Dec 23 18:27:42 2009
@@ -36,7 +36,7 @@
import org.ofbiz.service.ModelService;
/** An implementation of the <code>AccessController</code> interface. */
-public class AccessControllerImpl<E> implements AccessController<E> {
+public class AccessControllerImpl implements AccessController {
public static final String module = AccessControllerImpl.class.getName();
@@ -75,14 +75,14 @@
"@" + this.executionContext.getExecutionPath() + "[" +
permission + "]");
}
- public List<E> applyFilters(List<E> list) {
+ public <E> List<E> applyFilters(List<E> list) {
if (this.permission.getFilterNames().size() > 0) {
return new SecurityAwareList<E>(list,
this.permission.getFilterNames(), this.executionContext);
}
return list;
}
- public ListIterator<E> applyFilters(ListIterator<E> listIterator) {
+ public <E> ListIterator<E> applyFilters(ListIterator<E> listIterator) {
if (this.permission.getFilterNames().size() > 0) {
return new SecurityAwareListIterator<E>(listIterator,
this.permission.getFilterNames(), this.executionContext);
}
Modified:
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
Wed Dec 23 18:27:42 2009
@@ -39,13 +39,13 @@
* An implementation of the AuthorizationManager interface that uses the OFBiz
database
* for authorization data storage.
*/
-public class AuthorizationManagerImpl<E> extends OFBizSecurity implements
AuthorizationManager {
+public class AuthorizationManagerImpl extends OFBizSecurity implements
AuthorizationManager {
// Right now this class implements permission checking only.
public static final String module =
AuthorizationManagerImpl.class.getName();
protected static final UtilCache<String, PathNode> userPermCache = new
UtilCache<String, PathNode>("authorization.UserPermissions");
- public static final AccessController<?> nullAccessController = new
NullAccessController();
+ public static final AccessController nullAccessController = new
NullAccessController();
protected static boolean underConstruction = false;
public AuthorizationManagerImpl() {
@@ -127,8 +127,7 @@
userPermCache.remove(userLogin.getString("userLogin"));
}
- @SuppressWarnings("unchecked")
- public AccessController<?>
getAccessController(org.ofbiz.api.context.ExecutionContext executionContext)
throws AccessControlException {
+ public AccessController
getAccessController(org.ofbiz.api.context.ExecutionContext executionContext)
throws AccessControlException {
String userLoginId = ((ExecutionContext)
executionContext).getUserLogin().getString("userLoginId");
PathNode node = userPermCache.get(userLoginId);
if (node == null) {
Modified:
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
Wed Dec 23 18:27:42 2009
@@ -117,7 +117,7 @@
}
}
- public AccessController<?> getAccessController() {
- return (AccessController<?>)
this.getSecurity().getAccessController(this);
+ public AccessController getAccessController() {
+ return (AccessController) this.getSecurity().getAccessController(this);
}
}
Modified:
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java
Wed Dec 23 18:27:42 2009
@@ -29,17 +29,17 @@
/** An implementation of the <code>AccessController</code> interface
* that allows unrestricted access.
*/
-public class NullAccessController<E> implements AccessController<E> {
+public class NullAccessController implements AccessController {
public EntityListIterator applyFilters(EntityListIterator listIterator) {
return listIterator;
}
- public List<E> applyFilters(List<E> list) {
+ public <E> List<E> applyFilters(List<E> list) {
return list;
}
- public ListIterator<E> applyFilters(ListIterator<E> list) {
+ public <E> ListIterator<E> applyFilters(ListIterator<E> list) {
return list;
}
Modified:
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/AccessController.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/AccessController.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/AccessController.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/AccessController.java
Wed Dec 23 18:27:42 2009
@@ -26,7 +26,7 @@
* the <code>applyFilters</code> method can be overridden to handle
* <code>EntityListIterator</code>.
*/
-public interface AccessController<E> extends
org.ofbiz.api.authorization.AccessController<E> {
+public interface AccessController extends
org.ofbiz.api.authorization.AccessController {
/** Applies permission filters to an <code>EntityListIterator</code>. The
* returned <code>EntityListIterator</code> is security-aware, so methods
Modified:
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
Wed Dec 23 18:27:42 2009
@@ -368,7 +368,7 @@
public GenericValue create(GenericValue value, boolean doCacheClear)
throws GenericEntityException {
this.executionContext.pushExecutionArtifact(value);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
accessController.checkPermission(Create);
@@ -522,7 +522,7 @@
public GenericValue createOrStore(GenericValue value, boolean
doCacheClear) throws GenericEntityException {
this.executionContext.pushExecutionArtifact(value);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
GenericValue checkValue = this.findOne(value.getEntityName(),
value.getPrimaryKey(), false);
@@ -780,7 +780,7 @@
ecaRunner.evalRules(EntityEcaHandler.EV_RETURN,
EntityEcaHandler.OP_FIND, dummyValue, false);
this.executionContext.pushExecutionArtifact(modelEntity);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
eli = accessController.applyFilters(eli);
this.executionContext.popExecutionArtifact();
return eli;
@@ -835,7 +835,7 @@
}
this.decryptFields(results);
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
results = accessController.applyFilters(results);
return results;
} catch (GenericEntityException e) {
@@ -904,7 +904,7 @@
}
this.decryptFields(results);
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
results = accessController.applyFilters(results);
return results;
} catch (GenericEntityException e) {
@@ -992,7 +992,7 @@
EntityListIterator eli = this.find(entityName,
whereEntityCondition, havingEntityCondition, UtilMisc.toSet(fieldsToSelect),
orderBy, findOptions);
eli.setDelegator(this);
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.findByCondition", entityName));
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
eli = accessController.applyFilters(eli);
this.executionContext.popExecutionArtifact();
List<GenericValue> list = eli.getCompleteList();
@@ -1241,7 +1241,7 @@
List<GenericValue> cacheList =
this.delegatorData.cache.get(entityName, entityCondition, orderBy);
if (cacheList != null) {
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.findList", entityName));
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
cacheList = accessController.applyFilters(cacheList);
this.executionContext.popExecutionArtifact();
return cacheList;
@@ -1264,7 +1264,7 @@
this.delegatorData.cache.put(entityName, entityCondition,
orderBy, list);
}
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.findList", entityName));
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
list = accessController.applyFilters(list);
this.executionContext.popExecutionArtifact();
return list;
@@ -1313,7 +1313,7 @@
eli.setDelegator(this);
// TODO: add decrypt fields
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.findListIteratorByCondition",
modelViewEntity.getEntityName()));
- AccessController<GenericValue> accessController =
(AccessController<GenericValue>) this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
eli = accessController.applyFilters(eli);
this.executionContext.popExecutionArtifact();
return eli;
@@ -2183,7 +2183,7 @@
public int removeByCondition(String entityName, EntityCondition condition,
boolean doCacheClear) throws GenericEntityException {
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.removeByCondition", entityName));
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
accessController.checkPermission(Delete);
@@ -2238,7 +2238,7 @@
public int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear)
throws GenericEntityException {
this.executionContext.pushExecutionArtifact(primaryKey);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
accessController.checkPermission(Delete);
@@ -2325,7 +2325,7 @@
public int removeValue(GenericValue value, boolean doCacheClear) throws
GenericEntityException {
this.executionContext.pushExecutionArtifact(value);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
// NOTE: this does not call the GenericDelegator.removeByPrimaryKey
// method because it has more information to pass to the ECA rule
hander
boolean beganTransaction = false;
@@ -2553,7 +2553,7 @@
public int store(GenericValue value, boolean doCacheClear) throws
GenericEntityException {
this.executionContext.pushExecutionArtifact(value);
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
accessController.checkPermission(Update);
@@ -2717,7 +2717,7 @@
public int storeByCondition(String entityName, Map<String, ? extends
Object> fieldsToSet, EntityCondition condition, boolean doCacheClear) throws
GenericEntityException {
this.executionContext.pushExecutionArtifact(new
GenericExecutionArtifact("GenericDelegator.storeByCondition", entityName));
- AccessController<?> accessController =
this.executionContext.getAccessController();
+ AccessController accessController =
this.executionContext.getAccessController();
boolean beganTransaction = false;
try {
accessController.checkPermission(Update);
Modified:
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ExecutionContext.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ExecutionContext.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ExecutionContext.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ExecutionContext.java
Wed Dec 23 18:27:42 2009
@@ -24,7 +24,7 @@
*/
public interface ExecutionContext extends
org.ofbiz.api.context.ExecutionContext {
- public AccessController<?> getAccessController();
+ public AccessController getAccessController();
/** Returns the current <code>GenericDelegator</code> instance.
*
@@ -38,9 +38,9 @@
*/
public GenericValue getUserLogin();
- /** Sets the current <code>GenericDelegator</code> instance.
+ /** Sets the current <code>Delegator</code> instance.
*
- * @param delegator The new <code>GenericDelegator</code> instance
+ * @param delegator The new <code>Delegator</code> instance
*/
public void setDelegator(GenericDelegator delegator);
Modified:
ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=893591&r1=893590&r2=893591&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
(original)
+++
ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
Wed Dec 23 18:27:42 2009
@@ -477,7 +477,7 @@
// TODO: Find an implementation-agnostic way to do this
protected static class LoaderExecutionContext extends ExecutionContextImpl
{
@Override
- public AccessController<?> getAccessController() {
+ public AccessController getAccessController() {
return AuthorizationManagerImpl.nullAccessController;
}
}