org.sakaiproject.component.legacy.security
Class NoSecurity

java.lang.Object
  extended byorg.sakaiproject.component.legacy.security.NoSecurity
All Implemented Interfaces:
SecurityService

public class NoSecurity
extends Object
implements SecurityService

NoSecurity is an example implementation of the Sakai SecurityService.

Work Interfaces:

Implementation Design:

External Dependencies:

Version:
$Revision: 3310 $
Author:
University of Michigan, Sakai Software Development Team

Field Summary
protected  Logger m_logger
          Dependency: logging service
 
Fields inherited from interface org.sakaiproject.service.legacy.security.SecurityService
SERVICE_NAME
 
Constructor Summary
NoSecurity()
           
 
Method Summary
 void addKey(String userOrGroup, String lockOrRole, String resourceOrGroup, boolean allow)
          Add a new key.
 void clearAdvisors()
          Remove any SecurityAdvisors from this thread.
 void destroy()
          Final cleanup.
protected  User getUser(User user)
          Get the authenticated session user
protected  String getUserId(User u)
           
 boolean hasAdvisors()
          Check if there are any security advisors stacked for this thread.
 void init()
          Final initialization, once all dependencies are set.
 boolean isSuperUser()
          Is this a super special super (admin) user?
 SecurityAdvisor popAdvisor()
          Remove one SecurityAdvisor from the stack for this thread, if any exist.
 void pushAdvisor(SecurityAdvisor advisor)
          Establish a new SecurityAdvisor for this thread, at the top of the stack (it gets first dibs on the answer).
 void removeKey(String userOrGroup, String lockOrRole, String resourceOrGroup, boolean allow)
          Remove any keys that exactly match this key specification.
 void setLogger(Logger service)
          Dependency: logging service.
 boolean unlock(String lock, String resource)
          Can the user in the security context unlock the lock for use with this resource?
 boolean unlock(User user, String lock, String resource)
          Can the user in the security context unlock the lock for use with this resource?
 List unlockUsers(String lock, String reference)
          Access the List of Users who can unlock the lock for use with this resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_logger

protected Logger m_logger
Dependency: logging service

Constructor Detail

NoSecurity

public NoSecurity()
Method Detail

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Final cleanup.


getUser

protected User getUser(User user)
Get the authenticated session user

Parameters:
user - If not null, use this user, else use the session one.
Returns:
the User object authenticated to the current request's session.

isSuperUser

public boolean isSuperUser()
Is this a super special super (admin) user?

Specified by:
isSuperUser in interface SecurityService
Returns:
true, if the user is a cut above the rest, false if a mere mortal.

unlock

public boolean unlock(String lock,
                      String resource)
Can the user in the security context unlock the lock for use with this resource?

Specified by:
unlock in interface SecurityService
Parameters:
lock - The lock id string.
resource - The resource id string, or null if no resource is involved.
Returns:
true, if the user can unlock the lock, false otherwise.

unlock

public boolean unlock(User user,
                      String lock,
                      String resource)
Can the user in the security context unlock the lock for use with this resource?

Specified by:
unlock in interface SecurityService
Parameters:
lock - The lock id string.
resource - The resource id string, or null if no resource is involved.
user - The user.
Returns:
true, if the user can unlock the lock, false otherwise.

unlockUsers

public List unlockUsers(String lock,
                        String reference)
Access the List of Users who can unlock the lock for use with this resource.

Specified by:
unlockUsers in interface SecurityService
Parameters:
lock - The lock id string.
reference - The resource reference string.
Returns:
A List (User) of the users can unlock the lock (may be empty).

addKey

public void addKey(String userOrGroup,
                   String lockOrRole,
                   String resourceOrGroup,
                   boolean allow)
Add a new key.

Specified by:
addKey in interface SecurityService
Parameters:
userOrGroup - The id of the user or user group which is given the key.
lockOrRole - The id of the lock or role (lock group) which the key opens.
resourceOrGroup - the id of the resource or resource group which restricts the key (the key will work only for these resources. null if no resource is involved).
allow - true if the key allows access, false if it denys access.

removeKey

public void removeKey(String userOrGroup,
                      String lockOrRole,
                      String resourceOrGroup,
                      boolean allow)
Remove any keys that exactly match this key specification.

Specified by:
removeKey in interface SecurityService
Parameters:
userOrGroup - The id of the user or user group which is given the key.
lockOrRole - The id of the lock or role (lock group) which the key opens.
resourceOrGroup - the id of the resource or resource group which restricts the key (the key will work only for these resources. null if no resource is involved).
allow - true if the key allows access, false if it denys access.

getUserId

protected String getUserId(User u)

pushAdvisor

public void pushAdvisor(SecurityAdvisor advisor)
Description copied from interface: SecurityService
Establish a new SecurityAdvisor for this thread, at the top of the stack (it gets first dibs on the answer).

Specified by:
pushAdvisor in interface SecurityService
Parameters:
advisor - The advisor to establish

popAdvisor

public SecurityAdvisor popAdvisor()
Description copied from interface: SecurityService
Remove one SecurityAdvisor from the stack for this thread, if any exist.

Specified by:
popAdvisor in interface SecurityService
Returns:
advisor The advisor popped of, or null if the stack is empty.

hasAdvisors

public boolean hasAdvisors()
Description copied from interface: SecurityService
Check if there are any security advisors stacked for this thread.

Specified by:
hasAdvisors in interface SecurityService
Returns:
true if some advisors are defined, false if not.

clearAdvisors

public void clearAdvisors()
Description copied from interface: SecurityService
Remove any SecurityAdvisors from this thread.

Specified by:
clearAdvisors in interface SecurityService