org.norther.tammi.spray.filter
Class DefaultSecureKeyFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.spray.filter.DefaultFilter
          extended by org.norther.tammi.spray.filter.DefaultKeyFilter
              extended by org.norther.tammi.spray.filter.DefaultSecureKeyFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Manageable, MBeanDelegate, AccessController, KeyFilter, SecureFilter, SecureKeyFilter
Direct Known Subclasses:
DefaultFlowFilter, DefaultFormFilter, DefaultTaskFilter

public class DefaultSecureKeyFilter
extends DefaultKeyFilter
implements SecureKeyFilter

A default implementation of SecureKeyFilter.

Version:
$Id: DefaultSecureKeyFilter.java,v 1.6 2009/09/28 15:08:26 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.spray.filter.DefaultKeyFilter
DEFAULT_KEY
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Constructor Summary
DefaultSecureKeyFilter()
          Constructs a new filter.
DefaultSecureKeyFilter(String key)
          Constructs a new filter with a key.
 
Method Summary
 void addAllowedPermission(String role, Permission permission)
          Adds an allowed permission for a specified role.
 void addDeniedPermission(String role, Permission permission)
          Adds a denied permission for a specified role.
 Enumeration<Permission> allowedPermissions(String role)
          Returns an enumeration of allowed permissions for a specified role.
 Set<String> allowedRoleSet()
          Returns a read-only set of roles with allowed permissions.
 boolean checkPermission(Permission permission, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether or not the specified request has the specified permission.
 boolean checkPermission(Principal principal, Permission permission)
          Checks whether or not the specified principal has the specified permission.
 void clearAllowedPermissions()
          Clears all allowed permissions.
 void clearDeniedPermissions()
          Clears all denied permissions.
 Enumeration<Permission> deniedPermissions(String role)
          Returns an enumeration of denied permissions for a specified role.
 Set<String> deniedRoleSet()
          Returns a read only set of roles with denied permissions.
 String[] getPermissibleRoles(Permission permission)
          Gets the roles having the specified permission.
 boolean isProtected()
          Checks whether the access controller is protected by any allowed or denied permissions.
 void removeAllowedPermissions(String role)
          Removes allowed permissions for a specified role.
 void removeDeniedPermissions(String role)
          Removes denied permissions for a specified role.
 void setAllowedPermissions(String role, Permission[] permissions)
          Sets allowed permissions for a specified role.
 void setDeniedPermissions(String role, Permission[] permissions)
          Sets denied permissions for a specified role.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultKeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultFilter
destroy, doFilter, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Constructor Detail

DefaultSecureKeyFilter

public DefaultSecureKeyFilter()
Constructs a new filter.


DefaultSecureKeyFilter

public DefaultSecureKeyFilter(String key)
Constructs a new filter with a key.

Parameters:
key - the filter key.
Method Detail

isProtected

public boolean isProtected()
Description copied from interface: AccessController
Checks whether the access controller is protected by any allowed or denied permissions.

Specified by:
isProtected in interface AccessController
Returns:
true if the access controller is protected, false otherwise.

allowedPermissions

public Enumeration<Permission> allowedPermissions(String role)
Description copied from interface: AccessController
Returns an enumeration of allowed permissions for a specified role.

Specified by:
allowedPermissions in interface AccessController
Parameters:
role - the specified role.
Returns:
an enumeration of allowed permissions.

setAllowedPermissions

public void setAllowedPermissions(String role,
                                  Permission[] permissions)
Description copied from interface: AccessController
Sets allowed permissions for a specified role.

Specified by:
setAllowedPermissions in interface AccessController
Parameters:
role - the specified role.
permissions - an array of permissions.

addAllowedPermission

public void addAllowedPermission(String role,
                                 Permission permission)
Description copied from interface: AccessController
Adds an allowed permission for a specified role.

Specified by:
addAllowedPermission in interface AccessController
Parameters:
role - the specified role.
permission - the allowed permission.

removeAllowedPermissions

public void removeAllowedPermissions(String role)
Description copied from interface: AccessController
Removes allowed permissions for a specified role.

Specified by:
removeAllowedPermissions in interface AccessController
Parameters:
role - the specified role.

clearAllowedPermissions

public void clearAllowedPermissions()
Description copied from interface: AccessController
Clears all allowed permissions.

Specified by:
clearAllowedPermissions in interface AccessController

allowedRoleSet

public Set<String> allowedRoleSet()
Description copied from interface: AccessController
Returns a read-only set of roles with allowed permissions.

Specified by:
allowedRoleSet in interface AccessController
Returns:
a set of allowed roles.

deniedPermissions

public Enumeration<Permission> deniedPermissions(String role)
Description copied from interface: AccessController
Returns an enumeration of denied permissions for a specified role.

Specified by:
deniedPermissions in interface AccessController
Parameters:
role - the specified role.
Returns:
an enumeration of denied permissions.

setDeniedPermissions

public void setDeniedPermissions(String role,
                                 Permission[] permissions)
Description copied from interface: AccessController
Sets denied permissions for a specified role.

Specified by:
setDeniedPermissions in interface AccessController
Parameters:
role - the specified role.
permissions - an array of permissions.

addDeniedPermission

public void addDeniedPermission(String role,
                                Permission permission)
Description copied from interface: AccessController
Adds a denied permission for a specified role.

Specified by:
addDeniedPermission in interface AccessController
Parameters:
role - the specified role.
permission - the denied permission.

removeDeniedPermissions

public void removeDeniedPermissions(String role)
Description copied from interface: AccessController
Removes denied permissions for a specified role.

Specified by:
removeDeniedPermissions in interface AccessController
Parameters:
role - the role to be updated.

clearDeniedPermissions

public void clearDeniedPermissions()
Description copied from interface: AccessController
Clears all denied permissions.

Specified by:
clearDeniedPermissions in interface AccessController

deniedRoleSet

public Set<String> deniedRoleSet()
Description copied from interface: AccessController
Returns a read only set of roles with denied permissions.

Specified by:
deniedRoleSet in interface AccessController
Returns:
a set of denied roles.

getPermissibleRoles

public String[] getPermissibleRoles(Permission permission)
Description copied from interface: AccessController
Gets the roles having the specified permission. More specifically, this method checks whether the passed permission is implied by the allowed permissions, not implied by the denied permissions and a role is mapped to the corresponding permission.

If the access controller is not protected by any permissions, null is returned. If there are not any roles having the requested permission, an empty array is returned.

Specified by:
getPermissibleRoles in interface AccessController
Parameters:
permission - the permission to be checked for.
Returns:
an array of roles, an empty array or null.

checkPermission

public boolean checkPermission(Principal principal,
                               Permission permission)
Description copied from interface: AccessController
Checks whether or not the specified principal has the specified permission.

Specified by:
checkPermission in interface AccessController
Parameters:
principal - the authenticated principal (null = unauthenticated).
permission - the permission to be checked for.
Returns:
true if the principal has the permission, false otherwise.

checkPermission

public boolean checkPermission(Permission permission,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
Description copied from interface: SecureFilter
Checks whether or not the specified request has the specified permission. If it does, true is returned, otherwise false is returned. More specifically, this method checks whether the passed permission is implied by the allowed permissions, not implied by the denied permissions and the principal of the request has an appropriate role mapped to the corresponding permission.

If the access controller is not protected by any permissions, true is returned.

Specified by:
checkPermission in interface SecureFilter
Parameters:
permission - the permission to be checked for.
request - the authenticated request.
response - the corresponding response.
chain - the active filter chain.
Returns:
true if the request has the permission, false otherwise.


Copyright © 2004 The Norther Organization. All rights reserved.