org.norther.tammi.spray.filter
Class DefaultBranchingFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer
          extended by org.norther.tammi.core.security.DefaultSecureContainer
              extended by org.norther.tammi.spray.filter.AbstractSecureContainerFilter
                  extended by org.norther.tammi.spray.filter.AbstractSecureContainerKeyFilter
                      extended by org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter
                          extended by org.norther.tammi.spray.filter.DefaultBranchingFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container, Manageable, MBeanDelegate, AccessController, SecureContainer, BranchingFilter, ContainerFilter, ContainerKeyFilter, KeyFilter, SecureContainerFilter, SecureContainerKeyFilter, SecureFilter
Direct Known Subclasses:
DefaultLinkFilter

public class DefaultBranchingFilter
extends DefaultSecureContainerKeyFilter
implements BranchingFilter

A default implementation of BranchingFilter applying the filter key first to request attributes and then to request parameters to obtain the mapping key of the filter branch.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static String BRANCH_KEY
          The branch key.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultBranchingFilter()
          Constructs a new filter.
DefaultBranchingFilter(String key)
          Constructs a new filter with a key.
 
Method Summary
 boolean checkPermission(Principal principal, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether or not the specified principal has an execute permission to the selected branch.
 boolean checkPermission(ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether or not the specified request has an execute permission to the selected branch.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          Invokes a filter mapped to the branch key.
 String getBranchKey(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the branch key of the selected branch for the specified request.
 String getDefaultKey()
          Gets the default branch key.
 Filter getFilter(String key)
          Gets referent of the filter MBean of the specified key.
 void setDefaultKey(String key)
          Sets the default branch key.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter
getFilter
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractSecureContainerKeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractSecureContainerFilter
checkPermission, checkPermission, checkPermission, destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.security.DefaultSecureContainer
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, checkPermission, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, getPermissibleRoles, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from class org.norther.tammi.core.base.DefaultContainer
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanHandle, getMBeanHandles, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
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.core.base.Container
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 
Methods inherited from interface org.norther.tammi.spray.filter.SecureFilter
checkPermission, checkPermission, checkPermission
 
Methods inherited from interface org.norther.tammi.core.security.AccessController
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, checkPermission, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, getPermissibleRoles, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 
Methods inherited from interface org.norther.tammi.core.base.Container
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 

Field Detail

BRANCH_KEY

public static final String BRANCH_KEY
The branch key.

See Also:
Constant Field Values
Constructor Detail

DefaultBranchingFilter

public DefaultBranchingFilter()
Constructs a new filter.


DefaultBranchingFilter

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

Parameters:
key - the filter key.
Method Detail

getDefaultKey

public String getDefaultKey()
Description copied from interface: BranchingFilter
Gets the default branch key.

Specified by:
getDefaultKey in interface BranchingFilter
Returns:
the default key or null.

setDefaultKey

public void setDefaultKey(String key)
Description copied from interface: BranchingFilter
Sets the default branch key. The default key is applied, if the request doesn't specify an explicit branch key.

Specified by:
setDefaultKey in interface BranchingFilter
Parameters:
key - the default key.

getFilter

public Filter getFilter(String key)
Description copied from interface: BranchingFilter
Gets referent of the filter MBean of the specified key.

Specified by:
getFilter in interface BranchingFilter
Parameters:
key - the branch key.
Returns:
the referent of the filter MBean or null.

getBranchKey

public String getBranchKey(ServletRequest request,
                           ServletResponse response,
                           FilterChain chain)
Description copied from interface: BranchingFilter
Gets the branch key of the selected branch for the specified request.

Specified by:
getBranchKey in interface BranchingFilter
Parameters:
request - the request to process.
response - the response to return.
chain - the current filter chain.
Returns:
the branch key to apply or null.

checkPermission

public boolean checkPermission(ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
Description copied from interface: BranchingFilter
Checks whether or not the specified request has an execute permission to the selected branch.

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

checkPermission

public boolean checkPermission(Principal principal,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
Description copied from interface: BranchingFilter
Checks whether or not the specified principal has an execute permission to the selected branch.

Specified by:
checkPermission in interface BranchingFilter
Parameters:
principal - the authenticated principal.
request - the request of the branch.
response - the corresponding response.
chain - the active filter chain.
Returns:
true if the principal has the permission, false otherwise.

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws ServletException,
                     IOException
Invokes a filter mapped to the branch key. If none is found, it passes the request forward.

Specified by:
doFilter in interface Filter
Overrides:
doFilter in class AbstractSecureContainerFilter
Parameters:
request - the request to process.
response - the response to return.
chain - the current filter chain.
Throws:
ServletException - for servlet errors.
IOException - for general errors.


Copyright © 2004 The Norther Organization. All rights reserved.