Skip to content

Instantly share code, notes, and snippets.

@pauldijou
Created March 7, 2012 23:41
Show Gist options
  • Save pauldijou/1997314 to your computer and use it in GitHub Desktop.
Save pauldijou/1997314 to your computer and use it in GitHub Desktop.
DeltaSpike Security API : what I want to write
// 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