Author: adrianc
Date: Thu Jan 14 14:38:03 2010
New Revision: 899221
URL: http://svn.apache.org/viewvc?rev=899221&view=rev
Log:
Cleaned up the OFBizPermission class.
Modified:
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
Modified:
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java?rev=899221&r1=899220&r2=899221&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
(original)
+++
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
Thu Jan 14 14:38:03 2010
@@ -83,7 +83,7 @@
public <E> List<E> applyFilters(List<E> list) {
OFBizPermission permission = new OFBizPermission("applyFilters");
PermissionsGatherer permissionsGatherer = new
PermissionsGatherer(this.node, permission);
- permissionsGatherer.gatherPermissions(new
ArtifactPath(ThreadContext.getExecutionPathAsArray()));
+
permissionsGatherer.gatherPermissions(ThreadContext.getExecutionPath());
if (permission.getFilterNames().size() > 0) {
try {
LocalDispatcher dispatcher = ThreadContext.getDispatcher();
@@ -164,7 +164,7 @@
protected boolean hasServicePermission(OFBizPermission permission) {
try {
- if (permission.getServiceNames().size() == 0) {
+ if (permission.getServiceNames().size() == 0 ||
permission.isAdmin()) {
return true;
}
LocalDispatcher dispatcher = ThreadContext.getDispatcher();
Modified:
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java?rev=899221&r1=899220&r2=899221&view=diff
==============================================================================
---
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
(original)
+++
ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
Thu Jan 14 14:38:03 2010
@@ -57,6 +57,23 @@
this.excludePermissions = new PermissionsUnion(name);
}
+ public void accumulatePermissions(OFBizPermission permission) {
+ if (permission == null || this.adminPermission != null) {
+ return;
+ }
+ if (permission.includePermissions.getPermissionsSet().contains(Admin))
{
+ this.reset();
+ this.adminPermission = Admin;
+ return;
+ }
+
this.includePermissions.getPermissionsSet().removeAll(permission.excludePermissions.getPermissionsSet());
+
this.excludePermissions.getPermissionsSet().removeAll(permission.includePermissions.getPermissionsSet());
+
this.includePermissions.getPermissionsSet().addAll(permission.includePermissions.getPermissionsSet());
+
this.excludePermissions.getPermissionsSet().addAll(permission.excludePermissions.getPermissionsSet());
+ this.filters.addAll(permission.filters);
+ this.services.addAll(permission.services);
+ }
+
public void addFilter(String filter) {
this.filters.add(filter);
}
@@ -73,7 +90,7 @@
try {
OFBizPermission that = (OFBizPermission) obj;
return this.getName().equals(that.getName());
- } catch (Exception e) {}
+ } catch (ClassCastException e) {}
return false;
}
@@ -82,6 +99,14 @@
return null;
}
+ public Set<String> getFilterNames() {
+ return this.filters;
+ }
+
+ public Set<String> getServiceNames() {
+ return this.services;
+ }
+
@Override
public int hashCode() {
return this.getName().hashCode();
@@ -95,28 +120,8 @@
return this.includePermissions.implies(permission) &&
!this.excludePermissions.implies(permission);
}
- public Set<String> getFilterNames() {
- return this.filters;
- }
-
- public Set<String> getServiceNames() {
- return this.services;
- }
-
- public void accumulatePermissions(OFBizPermission permission) {
- if (permission == null || this.adminPermission != null) {
- return;
- }
- if (permission.includePermissions.getPermissionsSet().contains(Admin))
{
- this.adminPermission = Admin;
- return;
- }
-
this.includePermissions.getPermissionsSet().removeAll(permission.excludePermissions.getPermissionsSet());
-
this.excludePermissions.getPermissionsSet().removeAll(permission.includePermissions.getPermissionsSet());
-
this.includePermissions.getPermissionsSet().addAll(permission.includePermissions.getPermissionsSet());
-
this.excludePermissions.getPermissionsSet().addAll(permission.excludePermissions.getPermissionsSet());
- this.filters.addAll(permission.filters);
- this.services.addAll(permission.services);
+ public boolean isAdmin() {
+ return this.adminPermission != null;
}
public void reset() {