Created
October 30, 2011 20:24
-
-
Save runeflobakk/1326386 to your computer and use it in GitHub Desktop.
Funksjon for å avgjøre om MyPrincipal sitt sikkerhetsnivå er høyt nok for det som kreves av ConfigAttributes
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
public class SecurityLevelVoter implements AccessDecisionVoter { | |
private String securityLevelPrefix = "SECURITY_LEVEL_"; | |
//...snip... | |
private class AcceptingSecurityLevelOf implements Predicate<ConfigAttribute> { | |
private final int principalSecurityLevel; | |
public AcceptingSecurityLevelOf(MyPrincipal principal) { | |
principalSecurityLevel = toInt(principal.getSecurityLevel(), Integer.MIN_VALUE); | |
} | |
@Override | |
public boolean evaluate(ConfigAttribute attribute) { | |
String requiredSecurityLevel = | |
removeStart(attribute.getAttribute(), securityLevelPrefix); | |
return principalSecurityLevel >= toInt(requiredSecurityLevel, Integer.MAX_VALUE); | |
} | |
} | |
//...snip... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment