This PageRequest interface is really similar to something Johannes Barop just 
contributed, but his was a private inner class of Navigation. The fact that 
this has cropped up twice in the past two days indicates that something is 
missing from the public API :)

But! Couldn't we just express the hasPermission method like this:

> PermissionStatus hasPermission(User user, Page page);

We could create the Page widget instance itself, write the @PageState fields to 
it, and then ask the permission resolver if we should be allowed to show it. 
This may be more convenient in many cases because of the type coercion that the 
framework does when writing page state fields. Does this make sense?

Going even further, why not use the exact same PermissionResolver interface as 
PicketLink? Then we can stick them in the shared package and reuse them between 
client and server. Since they're created by the bean manager, there's tons of 
stuff we could share between client and server simply by injecting the 
contextual information we need in order to make the decision.

I'm not saying they have to be shareable in all cases, but in many cases it 
should be possible. "Write it once!" is one of the Errai design principles--at 
least according to the marketing segment of our conference talks. ;-)

-Jonathan

On 2013-06-20, at 5:48 AM, Erik Jan de Wit wrote:

> Hi,
> 
> So I've worked some more on fine grained security and I've come up with the 
> following inspired by picket link:
> 
> public interface RequestPermissionResolver {
>  
>   public enum PermissionStatus {
>     ALLOW, DENY, NOT_APPLICABLE
>   }
>  
>   /**
>    * Tests if the currently authenticated user has permission to 'see' the 
> specified page request.
>    *
>    * @param user the user to validate the pageRequest for
>    * @param pageRequest The pageRequest for which the permission is required
>    * @return ALLOW if the current user has the permission DENY or 
> NOT_APPLICABLE.
>    */
>   PermissionStatus hasPermission(User user, PageRequest pageRequest);
> 
> The PageRequest contains the name of the page and the state. By implementing 
> this interface the user can create logic if he wants to show the page that is 
> about to get shown to the user or not.
> 
> The only problem I have now is what should we do when the user decides not to 
> show the page? I can see 4 possibilities:
> 
>       1. Create a message that is shown on the interface somewhere
>               The problems with this are, what message to show should be 
> translatable and where / how to show it, must 
>               also be customisable. Could also be helpful as a general error 
> message framework?
> 
>       2. Navigate to other page
>               We could navigate to an other page, with a role SecurityError 
> or something like that. This will mean the user
>               has full control of what will be shown when security errors 
> occur.
> 
>       3. We redirect to the login page
>               This is kinda strange because one is already logged in and if 
> there is no message this is not really helping
> 
>       4. Throw an exception
>               This is also not really helping as there is no way for the user 
> to do something at this point.
> 
> What do you guys think?
> 
>       Cheers,
>               Erik Jan
> 
> 
> _______________________________________________
> errai-dev mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/errai-dev

_______________________________________________
errai-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/errai-dev

Reply via email to