org.mycore.access
Class MCRAccessManager

java.lang.Object
  extended by org.mycore.access.MCRAccessManager

public class MCRAccessManager
extends Object

Version:
$Revision: 15371 $ $Date: 2009-06-15 16:50:47 +0200 (Mon, 15 Jun 2009) $
Author:
Thomas Scheffler

Field Summary
static Logger LOGGER
           
 
Constructor Summary
MCRAccessManager()
           
 
Method Summary
static void addRule(MCRObjectID id, String permission, Element rule, String description)
          adds an access rule for an MCRObjectID to an access system.
static void addRule(String id, String permission, Element rule, String description)
          adds an access rule for an ID to an access system.
static boolean checkPermission(MCRObjectID id, String permission)
          determines whether the current user has the permission to perform a certain action.
static boolean checkPermission(String permission)
          determines whether the current user has the permission to perform a certain action.
static boolean checkPermission(String id, String permission)
          determines whether the current user has the permission to perform a certain action.
static boolean checkPermissionForReadingDerivate(String derID)
          checks whether the current user has the permission to read/see a derivate check is also against the mcrobject, the derivate belongs to both checks must return true
it is needed in MCRFileNodeServlet and MCRZipServlet
static MCRAccessInterface getAccessImpl()
           
static Element getFalseRule()
          return a rule, that forbids something for all, but superuser
static Collection<String> getPermissionsForID(MCRObjectID id)
          lists all permissions defined for the id.
static Collection<String> getPermissionsForID(String id)
          lists all permissions defined for the id.
static Element getTrueRule()
          return a rule, that allows something for everybody
static boolean hasRule(String id, String permission)
          return true if a rule for the id exist
static void removeAllRules(MCRObjectID id)
          removes all rules for the MCRObjectID.
static void removeRule(MCRObjectID id, String permission)
          removes the permission rule for the MCRObjectID.
static void removeRule(String id, String permission)
          removes the permission rule for the ID.
static void updateRule(MCRObjectID id, String permission, Element rule, String description)
          updates an access rule for an MCRObjectID.
static void updateRule(String id, String permission, Element rule, String description)
          updates an access rule for an ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

public static final Logger LOGGER
Constructor Detail

MCRAccessManager

public MCRAccessManager()
Method Detail

getAccessImpl

public static MCRAccessInterface getAccessImpl()

addRule

public static void addRule(MCRObjectID id,
                           String permission,
                           Element rule,
                           String description)
                    throws MCRException
adds an access rule for an MCRObjectID to an access system.

Parameters:
id - the MCRObjectID of the object
permission - the access permission for the rule
rule - the access rule
description - description for the given access rule, e.g. "allows public access"
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.addRule(String, String, org.jdom.Element, String)

addRule

public static void addRule(String id,
                           String permission,
                           Element rule,
                           String description)
                    throws MCRException
adds an access rule for an ID to an access system.

Parameters:
id - the ID of the object as String
permission - the access permission for the rule
rule - the access rule
description - description for the given access rule, e.g. "allows public access"
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.addRule(String, String, org.jdom.Element, String)

removeRule

public static void removeRule(MCRObjectID id,
                              String permission)
                       throws MCRException
removes the permission rule for the MCRObjectID.

Parameters:
id - the MCRObjectID of an object
permission - the access permission for the rule
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.removeRule(String, String)

removeRule

public static void removeRule(String id,
                              String permission)
                       throws MCRException
removes the permission rule for the ID.

Parameters:
id - the ID of an object as String
permission - the access permission for the rule
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.removeRule(String, String)

removeAllRules

public static void removeAllRules(MCRObjectID id)
                           throws MCRException
removes all rules for the MCRObjectID.

Parameters:
id - the MCRObjectID of an object
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.removeRule(String)

updateRule

public static void updateRule(MCRObjectID id,
                              String permission,
                              Element rule,
                              String description)
                       throws MCRException
updates an access rule for an MCRObjectID.

Parameters:
id - the MCRObjectID of the object
permission - the access permission for the rule
rule - the access rule
description - description for the given access rule, e.g. "allows public access"
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.updateRule(String, String, Element, String)

updateRule

public static void updateRule(String id,
                              String permission,
                              Element rule,
                              String description)
                       throws MCRException
updates an access rule for an ID.

Parameters:
id - the ID of the object
permission - the access permission for the rule
rule - the access rule
description - description for the given access rule, e.g. "allows public access"
Throws:
MCRException - if an errow was occured
See Also:
MCRAccessInterface.updateRule(String, String, Element, String)

checkPermission

public static boolean checkPermission(MCRObjectID id,
                                      String permission)
determines whether the current user has the permission to perform a certain action.

Parameters:
id - the MCRObjectID of the object
permission - the access permission for the rule
Returns:
true if the access is allowed otherwise it return
See Also:
MCRAccessInterface.checkPermission(String, String)

checkPermission

public static boolean checkPermission(String id,
                                      String permission)
determines whether the current user has the permission to perform a certain action.

Parameters:
id - the MCRObjectID of the object
permission - the access permission for the rule
Returns:
true if the permission for the id is given

checkPermission

public static boolean checkPermission(String permission)
determines whether the current user has the permission to perform a certain action.

Parameters:
permission - the access permission for the rule
Returns:
true if the permission exist

checkPermissionForReadingDerivate

public static boolean checkPermissionForReadingDerivate(String derID)
checks whether the current user has the permission to read/see a derivate check is also against the mcrobject, the derivate belongs to both checks must return true
it is needed in MCRFileNodeServlet and MCRZipServlet

Parameters:
derID - String ID of a MyCoRe-Derivate
Returns:
true if the access is allowed otherwise it return false

getPermissionsForID

public static Collection<String> getPermissionsForID(String id)
lists all permissions defined for the id.

Parameters:
id - the ID of the object as String
Returns:
a List of all for id defined permissions

getPermissionsForID

public static Collection<String> getPermissionsForID(MCRObjectID id)
lists all permissions defined for the id.

Parameters:
id - the MCRObjectID of the object
Returns:
a List of all for id defined permissions

getTrueRule

public static Element getTrueRule()
return a rule, that allows something for everybody

Returns:
a rule, that allows something for everybody

getFalseRule

public static Element getFalseRule()
return a rule, that forbids something for all, but superuser

Returns:
a rule, that forbids something for all, but superuser

hasRule

public static boolean hasRule(String id,
                              String permission)
return true if a rule for the id exist

Parameters:
id - the MCRObjectID of the object
permission - the access permission for the rule