org.mmbase.security.implementation.cloudcontext
Class BasicContextProvider

java.lang.Object
  extended by org.mmbase.security.implementation.cloudcontext.BasicContextProvider
All Implemented Interfaces:
ContextProvider

public class BasicContextProvider
extends Object
implements ContextProvider

This is a basic implemention of ContextProvider that implements all the methods in a default way.

Since:
MMBase-1.9.1
Version:
$Id: BasicContextProvider.java 41894 2010-04-13 14:05:25Z michiel $
Author:
Michiel Meeuwissen

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.mmbase.security.implementation.cloudcontext.ContextProvider
ContextProvider.AllowingContexts
 
Constructor Summary
BasicContextProvider(MMObjectBuilder... b)
           
BasicContextProvider(NodeSearchQuery... q)
           
BasicContextProvider(String... b)
           
 
Method Summary
protected  boolean allows(MMObjectNode contextNode, MMObjectNode groupOrUserNode, Operation operation)
           
protected  boolean canReadAll()
           
 Authorization.QueryCheck check(User userContext, Query query, Operation operation)
           
protected  boolean disableContextChecks()
           
protected  SortedSet<String> getAllContexts()
          Returns a Set (of Strings) of all existing contexts
protected  SortedSet<String> getAllowingContexts(User user, Operation operation)
           
 String getContextName(MMObjectNode contextNode)
          Returns the name of the context belonging to a certain context node.
protected  String getContextNameField(String table)
          For the given context- builder return which field contains the 'context'.
 MMObjectNode getContextNode(MMObjectNode node)
          Returns the MMObjectNode representing the 'context' of a certain other node
 MMObjectNode getContextNode(String context)
          Returns the MMObjectNode representing the 'context' which is identifier with the given name.
 Collection<NodeSearchQuery> getContextQueries()
           
protected  SortedSet<String> getDisallowingContexts(User user, Operation operation)
          Returns a Set (of Strings) of all existing contexts for which the given operation is not allowed for the given user.
 Set<MMObjectNode> getGroupsAndUsers(MMObjectNode contextNode, Operation operation)
           
protected  Collection<MMObjectNode> getGroupsOrUsers(MMObjectNode contextNode, Operation operation, MMObjectBuilder groupsOrUsers)
           
protected  int getMaxContextsInQuery()
           
 Set<String> getPossibleContexts(User user)
           
 Set<String> getPossibleContexts(User user, MMObjectNode node)
           
 boolean grant(User user, MMObjectNode contextNode, MMObjectNode groupOrUserNode, Operation operation)
           
protected  boolean isAllContextsPossible()
           
 boolean mayDo(User user, MMObjectNode node, Operation operation)
           
 boolean mayDoOnContext(MMObjectNode userNode, MMObjectNode contextNode, Operation operation, boolean checkOwnRights)
           
protected  boolean mayDoOnContext(User user, MMObjectNode contextNode, Operation operation, boolean checkOwnRights)
           
 boolean mayGrant(User user, MMObjectNode contextNode, MMObjectNode groupOrUserNode, Operation operation)
          Whether, or not, the user is allowed to grant the security operation to the group or user on the context node.
 boolean mayRevoke(User user, MMObjectNode contextNode, MMObjectNode groupOrUserNode, Operation operation)
          Whether, or not, the user is allowed to revoke the security operation to the group or user on the context node.
 boolean revoke(User user, MMObjectNode contextNode, MMObjectNode groupOrUserNode, Operation operation)
           
 void setContext(User user, MMObjectNode node, String context)
          Sets the context of the given ode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicContextProvider

public BasicContextProvider(NodeSearchQuery... q)

BasicContextProvider

public BasicContextProvider(MMObjectBuilder... b)

BasicContextProvider

public BasicContextProvider(String... b)
Method Detail

isAllContextsPossible

protected boolean isAllContextsPossible()

canReadAll

protected boolean canReadAll()

getMaxContextsInQuery

protected int getMaxContextsInQuery()

disableContextChecks

protected boolean disableContextChecks()

getContextNameField

protected String getContextNameField(String table)
For the given context- builder return which field contains the 'context'.


getContextQueries

public Collection<NodeSearchQuery> getContextQueries()
Specified by:
getContextQueries in interface ContextProvider

getContextName

public String getContextName(MMObjectNode contextNode)
                      throws SecurityException
Description copied from interface: ContextProvider
Returns the name of the context belonging to a certain context node.

Specified by:
getContextName in interface ContextProvider
Throws:
SecurityException

setContext

public void setContext(User user,
                       MMObjectNode node,
                       String context)
Description copied from interface: ContextProvider
Sets the context of the given ode.

Specified by:
setContext in interface ContextProvider

getAllContexts

protected SortedSet<String> getAllContexts()
Returns a Set (of Strings) of all existing contexts


getDisallowingContexts

protected SortedSet<String> getDisallowingContexts(User user,
                                                   Operation operation)
Returns a Set (of Strings) of all existing contexts for which the given operation is not allowed for the given user.


getAllowingContexts

protected SortedSet<String> getAllowingContexts(User user,
                                                Operation operation)

getContextNode

public MMObjectNode getContextNode(MMObjectNode node)
Description copied from interface: ContextProvider
Returns the MMObjectNode representing the 'context' of a certain other node

Specified by:
getContextNode in interface ContextProvider
Returns:
The MMObjectNode presenting the context of the given node.

getContextNode

public MMObjectNode getContextNode(String context)
Description copied from interface: ContextProvider
Returns the MMObjectNode representing the 'context' which is identifier with the given name.

Specified by:
getContextNode in interface ContextProvider

getPossibleContexts

public Set<String> getPossibleContexts(User user,
                                       MMObjectNode node)
                                throws SecurityException
Specified by:
getPossibleContexts in interface ContextProvider
Throws:
SecurityException

getPossibleContexts

public Set<String> getPossibleContexts(User user)
                                throws SecurityException
Specified by:
getPossibleContexts in interface ContextProvider
Throws:
SecurityException

mayDo

public boolean mayDo(User user,
                     MMObjectNode node,
                     Operation operation)
Specified by:
mayDo in interface ContextProvider

mayDoOnContext

protected boolean mayDoOnContext(User user,
                                 MMObjectNode contextNode,
                                 Operation operation,
                                 boolean checkOwnRights)

mayDoOnContext

public boolean mayDoOnContext(MMObjectNode userNode,
                              MMObjectNode contextNode,
                              Operation operation,
                              boolean checkOwnRights)
Specified by:
mayDoOnContext in interface ContextProvider

mayGrant

public boolean mayGrant(User user,
                        MMObjectNode contextNode,
                        MMObjectNode groupOrUserNode,
                        Operation operation)
Description copied from interface: ContextProvider
Whether, or not, the user is allowed to grant the security operation to the group or user on the context node.

Specified by:
mayGrant in interface ContextProvider

mayRevoke

public boolean mayRevoke(User user,
                         MMObjectNode contextNode,
                         MMObjectNode groupOrUserNode,
                         Operation operation)
Description copied from interface: ContextProvider
Whether, or not, the user is allowed to revoke the security operation to the group or user on the context node.

Specified by:
mayRevoke in interface ContextProvider
To Do:
untested

getGroupsAndUsers

public Set<MMObjectNode> getGroupsAndUsers(MMObjectNode contextNode,
                                           Operation operation)
Returns:
a Set of all groups and users which are allowed for the given operation (not recursively).

getGroupsOrUsers

protected Collection<MMObjectNode> getGroupsOrUsers(MMObjectNode contextNode,
                                                    Operation operation,
                                                    MMObjectBuilder groupsOrUsers)
Returns:
A Collection of groups or users which are allowed for the given operation (not recursively)

check

public Authorization.QueryCheck check(User userContext,
                                      Query query,
                                      Operation operation)
Specified by:
check in interface ContextProvider

allows

protected boolean allows(MMObjectNode contextNode,
                         MMObjectNode groupOrUserNode,
                         Operation operation)

grant

public boolean grant(User user,
                     MMObjectNode contextNode,
                     MMObjectNode groupOrUserNode,
                     Operation operation)
Specified by:
grant in interface ContextProvider

revoke

public boolean revoke(User user,
                      MMObjectNode contextNode,
                      MMObjectNode groupOrUserNode,
                      Operation operation)
Specified by:
revoke in interface ContextProvider


MMBase 2.0-SNAPSHOT - null