Skip to content

Instantly share code, notes, and snippets.

@mbarkley
Last active August 29, 2015 14:01
Show Gist options
  • Save mbarkley/03cd031cd51c3b635273 to your computer and use it in GitHub Desktop.
Save mbarkley/03cd031cd51c3b635273 to your computer and use it in GitHub Desktop.
An example of securing Errai Bus RPCs with Errai Security
@Remote
@RestrictedAccess(roles = "user")
public interface RemoteService {
public void authenticatedUserService();
/*
* Because this method and its enclosing class are both restricted,
* a user must have both roles to access this.
*/
@RestrictedAccess(roles = "admin")
public void adminService();
}
public RemoteServiceCaller {
@Inject
private Caller<RemoteService> serviceCaller;
public void callServices() {
/*
* This call uses default error-handling. Security errors will
* cause page-redirection.
*/
serviceCaller.call(new RemoteCallback<Void>() {
public void callback(Void o) {
// handle success
}
}).authenticatedUserService();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment