Created
February 10, 2017 14:32
-
-
Save Acarus/a7acc7749f9c4cae99094574d68ec4c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean interpret(String expression, String actorId) { | |
String[] checks = expression.split(AND); | |
for (String check : checks) { | |
String[] operands = check.split(COLON); | |
String scopeId = operands[0].trim(); | |
String permissionName = operands[1].trim(); | |
boolean value; | |
if (scopeId.equals(ANY)) { | |
value = permissionName.equals(ANY) ? hasAnyPermissionsInAnyScopes(actorId) : | |
hasPermissionInAnyScopes(actorId, permissionName); | |
} else { | |
value = permissionName.equals(ANY) ? hasAnyPermissionsInScope(actorId, scopeId) : | |
resourceService.hasPermissionOnResource(actorId, permissionName, scopeId); | |
} | |
if (!value) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment