mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
bug5239: factored the "!" into a DENY_PREFIX constant and used consistently
This commit is contained in:
1 parent
2155b7d2d3
commit
b9fec1400c
2 files changed
+18
-9
No files matched your search
+16
-1
@@ -32,6 +32,8 @@ import com.sap.sse.security.shared.impl.UserGroupImpl;
|
||||
*
|
||||
*/
|
||||
public interface SecurityAccessControlList<G extends SecurityUserGroup<?>> extends Serializable {
|
||||
String DENY_PREFIX = "!";
|
||||
|
||||
/**
|
||||
* Checks whether this access control list grants the {@code user} the permission to execute {@code action} on the
|
||||
* object to which this ACL pertains.
|
||||
@@ -80,7 +82,20 @@ public interface SecurityAccessControlList<G extends SecurityUserGroup<?>> exten
|
||||
* @return {@code true} if it is a denied action, {@code false} otherwise
|
||||
*/
|
||||
static boolean isDeniedAction(String action) {
|
||||
return action.startsWith("!");
|
||||
return action.startsWith(DENY_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a leading ! (see {@link #DENY_PREFIX}) if there is one; otherwise prefixes the action with a !
|
||||
*/
|
||||
static String invertAction(String action) {
|
||||
final String result;
|
||||
if (isDeniedAction(action)) {
|
||||
result = action.substring(DENY_PREFIX.length());
|
||||
} else {
|
||||
result = DENY_PREFIX+action;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-8
@@ -106,7 +106,7 @@ public abstract class AbstractAccessControlList<G extends SecurityUserGroup<?>>
|
||||
}
|
||||
for (final Entry<G, Set<WildcardPermission>> allowedEntry : deniedActionsByUserGroup.entrySet()) {
|
||||
for (final WildcardPermission permission : allowedEntry.getValue()) {
|
||||
Util.addToValueSet(result, allowedEntry.getKey(), "!"+permission.toString());
|
||||
Util.addToValueSet(result, allowedEntry.getKey(), invertAction(permission.toString()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -120,13 +120,7 @@ public abstract class AbstractAccessControlList<G extends SecurityUserGroup<?>>
|
||||
* Removes a leading ! if there is one; otherwise prefixes the action with a !
|
||||
*/
|
||||
private String invertAction(String action) {
|
||||
final String result;
|
||||
if (isDeniedAction(action)) {
|
||||
result = action.substring(1);
|
||||
} else {
|
||||
result = "!"+action;
|
||||
}
|
||||
return result;
|
||||
return SecurityAccessControlList.invertAction(action);
|
||||
}
|
||||
|
||||
private boolean denyPermission(G userGroup, String action) {
|
||||
|
||||
Reference in new issue
Block a user