2009/4/24 Ian Boston <[email protected]>:
> Excellent :),
> Thank you,
> I should be able to refactor our JR 14 access manager onto this quite
> easily.
>
> One question,
> I see its all or nothing, if the plugin is there isGranted doesnt look at
> the default.
> I was wondering if there was a way of checking the default, and then checkin
> the plugin, knowing the defaults response. That way the plugin could enhance
> the default ACM where possible. (ie chain)

That's a good point.

But I think

> this.accessManagerPlugin.isGranted(namePathResolver.getJCRPath(absPath),
> permissions,super.isGranted(absPath, permissions));

would cause a lot of overhead, because you'd effectively check
permissions twice - once with the plugin, once with
DefaultAccessManager. And the permission checking is actually quite
heavy.


Instead, how about letting AccessManagerPlugin.isGranted return a
Boolean (as opposed to the lower-case boolean). The plugin can return
true or false as before, but can also return null to indicate that
DefaultAccessManager should be used.
Would that be sufficient in your case?

> There appear to be some public methods that don't delegate to the plugin.
> like
>
> +    public boolean isGranted(Path parentPath, Name childName, int
> permissions) throws RepositoryException {
> +        return super.isGranted(parentPath, childName, permissions);
> +    }
>
> and checkPermission
>
> was that intentional ?

Well, the intention was to keep the AccessManagerPlugin interface as
simple as possible, to reduce unnecessary work on impementors.
At the time of writing it, I didn't see a need for checkPermission,
since the DefaultAccessManager#checkPermission does nothing but call
isGranted, and throwing an exception if isGranted returns false.
The same goes for isGranted(parentPath, childName, permissions): The
only thing it does, is appending childName to parentPath, and calling
isGranted on the resulting path.
See the source code for DefaultAccessManager at [1].
Do you think you'll need to override those methods? I guess it's now
big harm in adding them.

[1] http://tinyurl.com/ctmxlv

-- 
Vidar S. Ramdal <[email protected]> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway
+47 21 531941, ext 2070

Reply via email to