Skip to content

Instantly share code, notes, and snippets.

@runeflobakk
Created October 30, 2011 20:48
Show Gist options
  • Save runeflobakk/1326422 to your computer and use it in GitHub Desktop.
Save runeflobakk/1326422 to your computer and use it in GitHub Desktop.
Hele vote-metoden hvor implementasjonen reflekterer bedre slik vi ville forklart forrutsetningene for brukertilgang.
public int vote(Authentication authentication,
Object object,
Collection<ConfigAttribute> attributes) {
Collection<ConfigAttribute> supportedAttributes =
select(attributes, new SupportedBy(this));
if (supportedAttributes.isEmpty()) {
return ACCESS_ABSTAIN;
}
Object p = authentication.getPrincipal();
if (p instanceof MyPrincipal
&& exists(supportedAttributes, new AcceptingSecurityLevelOf((MyPrincipal) p))) {
return ACCESS_GRANTED;
} else {
return ACCESS_DENIED;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment