Created
March 7, 2012 23:41
-
-
Save pauldijou/1997314 to your computer and use it in GitHub Desktop.
DeltaSpike Security API : what I want to write
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
// Inside a JSF page : | |
<h:commandButton action="create" rendered="#{identity.can('create','user')}">Create User</h:commandButton> | |
// Inside Java code : | |
// (would be better with annotations of course) | |
public class UserAction | |
{ | |
@Inject | |
private Identity identity; | |
public String persist(User user) | |
{ | |
if(identity.can('create','user') | |
{ | |
return doPersist(user); | |
} | |
else | |
{ | |
throw new SecurityViolation(); | |
} | |
} | |
private String doPersist(User user) | |
{ | |
// persist the user in database | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment