My application has some features that are available to all users, and some other features that should only be restricted to authenticated users. All these limited functions exist within a certain set of GWT places, therefore all Places available in the application can be divided into two groups: "Accessible to all" and "Limited". In my opinion, places with limited access can implement some interface (let them say that it will be RestrictedAccess ), and if the user goes to one of them and has not yet been authenticated, he will be redirected to the login screen - this is more OO- approach than using URL filters.
I am trying to achieve:
- Information about whether the user has been authenticated or not. stored on the server (this is not something that can be stored in a cookie ...)
- The login page is the standard place for GWT + view + activity (!)
- Username and password verification is done on the server side.
So far, I have introduced the RestrictedAccess interface, which is implemented by some set of places. My implementation of FilteredActivityMapper.Filter , which is passed to the FilteredActivityMapper application activity handler, has the following logic:
Place filter(Place place) { if (place instanceof RestrictedAccess && !userHasBeenAuthenticated()) { return new LoginPlace(); } // return the original place - user has been already authenticated or // place is accesible for all users return place; } private boolean userHasBeenAuthenticated() { // remote call - how to do ??? }
The problem is with the userHasBeenAuthenticated() method (the user should not be redirected to LoginPlace if it has already been authenticated). If I want to store this information on the server side, I need to make a GWT RPC / request factory call here, but both of them are asynchronous, so I cannot work with its result in the filter method.
I know that I can use web.xml filters or some external infrastructure (for example, spring security), but none of these approaches allows me to have a login page as a standard form based on GWT or to specify in more OO that access to a specific place should be limited.
Thanks in advance for any tips.
EDIT . I began to wonder if the filtering of places (limited / not limited) should generally take place on the client side. If, as suggested, there is an opportunity to hack a code indicating whether the user has been authenticated or not, there is also an opportunity to hack the site filtering code so that you can access limited places without logging in.