org.mmbase.security
Class Authorization

java.lang.Object
  extended byorg.mmbase.security.Configurable
      extended byorg.mmbase.security.Authorization
Direct Known Subclasses:
ContextAuthorization, NoAuthorization, OwnerAuthorization, Verify, Verify

public abstract class Authorization
extends Configurable

The abstract implementation of the Authorization. To make your own implementation of authorization, you have to extend this class, and implement the abstract methods.

Version:
$Id: Authorization.java,v 1.23 2005/01/30 16:46:35 nico Exp $
Author:
Eduard Witteveen, Michiel Meeuwissen

Nested Class Summary
static class Authorization.QueryCheck
          Defines the result of a security check on a query.
 
Field Summary
static Authorization.QueryCheck COMPLETE_CHECK
          Constant which can be used as a result for the check query function.
static Authorization.QueryCheck NO_CHECK
          Constant which can be used as a result for the check query function.
 
Fields inherited from class org.mmbase.security.Configurable
configFile, configResource, configWatcher, manager
 
Constructor Summary
Authorization()
           
 
Method Summary
abstract  boolean check(UserContext user, int nodeid, int srcnodeid, int dstnodeid, Operation operation)
          This method should be overrided by an extending class.
abstract  boolean check(UserContext user, int nodeid, Operation operation)
          This method should be overrided by an extending class.
 Authorization.QueryCheck check(UserContext user, Query query, Operation operation)
          Checks rights on a query.
abstract  void create(UserContext user, int nodeid)
          This method should be overrided by an extending class.
abstract  String getContext(UserContext user, int nodeid)
          This method could be overrided by an extending class.
abstract  Set getPossibleContexts(UserContext user, int nodeid)
          This method could be overrided by an extending class.
abstract  void remove(UserContext user, int nodeid)
          This method should be overrided by an extending class.
abstract  void setContext(UserContext user, int nodeid, String context)
          This method could be overrided by an extending class.
abstract  void update(UserContext user, int nodeid)
          This method should be overrided by an extending class.
 void verify(UserContext user, int nodeid, int srcnodeid, int dstnodeid, Operation operation)
          This method wraps the check-method with the same arguments.
 void verify(UserContext user, int nodeid, Operation operation)
          This method wraps the check-method with the same arguments.
 
Methods inherited from class org.mmbase.security.Configurable
load, load
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CHECK

public static final Authorization.QueryCheck NO_CHECK
Constant which can be used as a result for the check query function. It means: 'No extra contraints to be added, and the query's result will have to be postprocessed for security.

Since:
MMBase-1.7

COMPLETE_CHECK

public static final Authorization.QueryCheck COMPLETE_CHECK
Constant which can be used as a result for the check query function. It means: 'No extra contraints to be added, but the query's result will not have to be postprocessed for security. This means that there are no restrictions on the given operation at all (normally: 'read' is permit to everybody).

Since:
MMBase-1.7
Constructor Detail

Authorization

public Authorization()
Method Detail

create

public abstract void create(UserContext user,
                            int nodeid)
This method should be overrided by an extending class. It has to be called, when a new Node has been created. This way, the authentication can create default rights for this object, depending on the UserContext and generate logging information.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has just been added to the MMBase cloud.

update

public abstract void update(UserContext user,
                            int nodeid)
This method should be overrided by an extending class. It has to be called, when a Node has been changed. This way, the authentication can generate log information for this object, which can be used for accountability

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has just been changed in the cloud.

remove

public abstract void remove(UserContext user,
                            int nodeid)
This method should be overrided by an extending class. It has to be called, when a Node has been removed from the cloud. This way, the authentication can generate log information for this node, and remove the authorization object which belongs to this node.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has just been removed in the cloud.

check

public abstract boolean check(UserContext user,
                              int nodeid,
                              Operation operation)
This method should be overrided by an extending class. This method checks if an operation is permitted on a certain node done by a certain user.

Parameters:
user - The UserContext, containing the information the user.
nodeid - The id of the MMObjectNode, which has to be checked. It the action is CREATE then this will be interpreted as a typedef node.
operation - The operation which will be performed.
Returns:
true if the operation is permitted, false if the operation is not permitted,

verify

public void verify(UserContext user,
                   int nodeid,
                   Operation operation)
            throws SecurityException
This method wraps the check-method with the same arguments. The only difference being that it throws on exception if the specified operation is not permitted. It is wise to override check, and not verify (And I wonder why this method is not simply final).

Throws:
SecurityException - If the assertion fails
See Also:
check(UserContext, int, Operation)

check

public abstract boolean check(UserContext user,
                              int nodeid,
                              int srcnodeid,
                              int dstnodeid,
                              Operation operation)
This method should be overrided by an extending class. This method checks if the creation of a certain relation or changing the source or destination of a certain relation done by a certain user is permitted.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the relation which has to be checked. If the operation is CREATE then this will be interpreted as the typedef node (extending insrel) for the relation to be created.
srcnodeid - The id of the (new) source node of the relation.
dstnodeid - The id of the (new) destination node of the relation.
operation - The operation which will be performed (CREATE (create relation) or CHANGE_RELATION (source and/or destination are changed).
Returns:
true if the operation is permitted, false if the operation is not permitted,

verify

public void verify(UserContext user,
                   int nodeid,
                   int srcnodeid,
                   int dstnodeid,
                   Operation operation)
            throws SecurityException
This method wraps the check-method with the same arguments. The only difference being that it throws on exception if the specified operation is not permitted. It is wise to override check, and not verify (And I wonder why this method is not simply final).

Throws:
SecurityException - If the assertion fails
See Also:
check(UserContext, int, int, int, Operation)

getContext

public abstract String getContext(UserContext user,
                                  int nodeid)
                           throws SecurityException
This method could be overrided by an extending class. This method returns the context of a specific node.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has to be asserted.
Returns:
the context setting of the node.
Throws:
SecurityException - If operation is not allowed(needs read rights)

setContext

public abstract void setContext(UserContext user,
                                int nodeid,
                                String context)
                         throws SecurityException
This method could be overrided by an extending class. This method changes the rights on a node, by telling the authorization that it should use the context which is defined.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has to be asserted.
context - The context which rights the node will get
Throws:
SecurityException - If operation is not allowed
SecurityException - If context is not known

getPossibleContexts

public abstract Set getPossibleContexts(UserContext user,
                                        int nodeid)
                                 throws SecurityException
This method could be overrided by an extending class. This method returns a list of contexts which can be used to change the node.

Parameters:
user - The UserContext, containing the information about the user.
nodeid - The id of the MMObjectNode, which has to be asserted.
Returns:
a Set of Strings which represent a context in readable form..
Throws:
SecurityException

check

public Authorization.QueryCheck check(UserContext user,
                                      Query query,
                                      Operation operation)
Checks rights on a query. This means that the query is explored and (if possible) a constraint for it is constructed, which, if appied to the query, makes it return only checked results for the given user. Of course, this will normally only be implemented for the 'READ' operation. The constraint is not applied automaticly. This has to be done by using BasicQuery.setSecurityConstraint().

Parameters:
user - The UserContext, for which the query must be considered
query - The query to be explored
Returns:
A Authorization.QueryCheck structure (containing whether the constriant is sufficient, and the new constraint or null).
Since:
MMBase-1.7


MMBase build 1.8.1.20060716