Well we don't keep a cache of permissions/roles on the client. In our app we always have to load data from the server when a user switches between places. So when doing this server request we also ask the server to check the permissions that are relevant for the UI of that current place. All these permissions are defined as enums (one per place) and placed in the shared package so we can use these enums also on server side to secure our server methods.
A typical activity thats starts and loads its data would do (using Command pattern):
this.server.execute(
new BatchCommand(
new CheckPermissionsCommand(PlaceAPermissions.CREATE, PlaceAPermissions.DELETE),
new LoadDataForThisActivityCommand()
)
)
and in its onSuccess method we are setting the evaluated permissions to the view like:
boolean[] evaluatedPermissions = commandResult.getPermissions();
this.view.secure(evaluatedPermissions[0], ...);
which basically shows/hides all relevant UI elements and also secures view methods like setCreateButtonEnabled(boolean isEnabled) to respect the permissions.
During the server request everything relevant is disabled by default and the actually UI is hidden (a loading overlay will be shown).
So far it works great for us. But of course this does not enforce anything. The developer has to implement the UI "security" on its own.
-- J.