Last active
August 29, 2015 14:01
An example of securing Errai Bus RPCs with Errai Security
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
@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(); | |
} |
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 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