You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Angela Schreiber <an...@adobe.com> on 2012/07/19 10:40:17 UTC

TreeImpl vs ReadOnlyTree

hi all

while working on a initial permission check upon read access in
oak i found that there are two implementations of the Tree interface:

- TreeImpl:
   > only used within RootImpl
   > package private create method, private constructor

- ReadOnlyTree:
   > used in NameValidatorProvider and NamespaceValidatorProvider
   > public constructore taking a NodeState

as far as TreeImpl is concerned it looks perfectly fine to add the
permission checks in the appropriated places as that information
is exposed to API comsumers such as e.g. oak-jcr.

however, i am not totally sure about the aim and goal of the
ReadOnlyTree and unfortunately there is no javadoc explaining the
expected usage/exposure.

the current usages in the validator providers and the constructor
taking a NodeState gave me the impression that this implementation
is expected to be rather used for system internal evaluation where
enforcing access control for the editing content session may in fact
prevent that task: the mentioned validators for example access
namespace information stored underneath /jcr:system that may or may
not be accessible to a given content session.

so:
- what is the aim of the ReadOnlyTree?
- is my assumption correct or would it be required to enforce access
   restrictions on the ReadOnlyTree as well?
- if the ReadOnlyTree is meant to be an 'internal' implementation of
   the Tree interface, can we really enforce that it cannot be abused?
- i quickly checked if the NodeState interface was really just used
   within oak-core and not exposed: however i found that there as least
   one reference to the NodeState interface in oak-jcr (observation).

kind regards
angela

Re: TreeImpl vs ReadOnlyTree

Posted by Angela Schreiber <an...@adobe.com>.
hi jukka

thanks for the info.

> As you noticed, it's meant for use by plugins that want to access a
> raw NodeState through the Tree API without any internal layers
> (security, etc.) in between. Ideally such a wrapper wouldn't be
> needed, as it mixes levels of abstraction, which is why I didn't want
> to spend too much time documenting it (I'm hoping to refactor it away
> later).

ok. i agree that it somewhat mixes levels, but that seems the be
a common problem with the current separation between oak-api and
the spi package (see below).

> Yes. As long as a client doesn't see the underlying NodeStates (or the
> MicroKernel), it can't do anything useful with ReadOnlyTree.
>
>> - i quickly checked if the NodeState interface was really just used
>>    within oak-core and not exposed: however i found that there as least
>>    one reference to the NodeState interface in oak-jcr (observation).
>
> That should probably move to a plugin in oak-core.

one more comment regarding the exposure of NodeState: i realized that
the NodeState interface also makes it's way to the oak-API through
Root#getChangeExtractor. i create a new issue
https://issues.apache.org/jira/browse/OAK-191 to address this.

but i somewhat looks to be a basic problem (or misunderstanding) caused
the separation between oak-api and the spi.

just one additional example: the kind of permission evaluation i
envision for oak-core would to some extend need to read the access
control information from the content and evaluate if a given
Tree/NodeState or PropertyState was readable/writable taking all
the different types of content into account: regular, version content,
access control content, node type definitions and so forth...

in other words: the internal permission evaluation would need to
be aware of the nature of the individual content items. using
the Tree/PropertyState interface for that matter looks a bit
odd while at the same time the NodeState doesn't seem to be suitable either.

kind regards
angela

Re: TreeImpl vs ReadOnlyTree

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Jul 19, 2012 at 10:40 AM, Angela Schreiber <an...@adobe.com> wrote:
> - what is the aim of the ReadOnlyTree?

As you noticed, it's meant for use by plugins that want to access a
raw NodeState through the Tree API without any internal layers
(security, etc.) in between. Ideally such a wrapper wouldn't be
needed, as it mixes levels of abstraction, which is why I didn't want
to spend too much time documenting it (I'm hoping to refactor it away
later).

> - is my assumption correct or would it be required to enforce access
>   restrictions on the ReadOnlyTree as well?

You're correct.

> - if the ReadOnlyTree is meant to be an 'internal' implementation of
>   the Tree interface, can we really enforce that it cannot be abused?

Yes. As long as a client doesn't see the underlying NodeStates (or the
MicroKernel), it can't do anything useful with ReadOnlyTree.

> - i quickly checked if the NodeState interface was really just used
>   within oak-core and not exposed: however i found that there as least
>   one reference to the NodeState interface in oak-jcr (observation).

That should probably move to a plugin in oak-core.

BR,

Jukka Zitting