org.norther.tammi.spray.filter
Class DefaultBranchFilter<F extends Filter>

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer<V>
          extended by org.norther.tammi.core.security.DefaultSecureContainer<V>
              extended by org.norther.tammi.spray.filter.DefaultSecureContainerFilter<V>
                  extended by org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter<F>
                      extended by org.norther.tammi.spray.filter.DefaultBranchFilter<F>
Type Parameters:
F - the registered filter type.
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container<F>, Manageable, MBeanDelegate, AccessController, SecureContainer<F>, BranchFilter<F>, ContainerFilter<F>, ContainerKeyFilter<F>, KeyFilter, SecureContainerFilter<F>, SecureContainerKeyFilter<F>, SecureFilter
Direct Known Subclasses:
DefaultLinkFilter

public class DefaultBranchFilter<F extends Filter>
extends DefaultSecureContainerKeyFilter<F>
implements BranchFilter<F>

A default implementation of BranchFilter applying the filter key first to request attributes and then to request parameters to obtain the mapped name of the filter branch.

Version:
$Id: DefaultBranchFilter.java,v 1.5 2010-05-05 10:33:50 cvsimp Exp $
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
 
Constructor Summary
  DefaultBranchFilter()
          Constructs a new filter.
protected DefaultBranchFilter(KeyFilter filter)
          Constructs a new filter with a filter adaptee.
  DefaultBranchFilter(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 getBranch(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the name of the selected branch for the specified request.
 String getDefaultBranch()
          Gets the default branch key.
 Filter getFilter(String name)
          Gets referent of the filter MBean of the specified branch.
 void setDefaultBranch(String name)
          Sets the default branch name.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter
getFilter, getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultSecureContainerFilter
checkPermission, destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.security.DefaultSecureContainer
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, 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.spray.filter.SecureFilter
checkPermission
 
Methods inherited from interface org.norther.tammi.core.security.AccessController
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
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 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

DefaultBranchFilter

public DefaultBranchFilter()
Constructs a new filter.


DefaultBranchFilter

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

Parameters:
key - the filter key.

DefaultBranchFilter

protected DefaultBranchFilter(KeyFilter filter)
Constructs a new filter with a filter adaptee.

Parameters:
filter - the filter adaptee.
Method Detail

getDefaultBranch

public String getDefaultBranch()
Description copied from interface: BranchFilter
Gets the default branch key.

Specified by:
getDefaultBranch in interface BranchFilter<F extends Filter>
Returns:
the default key or null.

setDefaultBranch

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

Specified by:
setDefaultBranch in interface BranchFilter<F extends Filter>
Parameters:
name - the branch name.

getFilter

public Filter getFilter(String name)
Description copied from interface: BranchFilter
Gets referent of the filter MBean of the specified branch.

Specified by:
getFilter in interface BranchFilter<F extends Filter>
Parameters:
name - the branch name.
Returns:
the referent of the filter MBean or null.

getBranch

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

Specified by:
getBranch in interface BranchFilter<F extends Filter>
Parameters:
request - the request to process.
response - the response to return.
chain - the current filter chain.
Returns:
the branch name to apply or null.

checkPermission

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

Specified by:
checkPermission in interface BranchFilter<F extends Filter>
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: BranchFilter
Checks whether or not the specified principal has an execute permission to the selected branch.

Specified by:
checkPermission in interface BranchFilter<F extends Filter>
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 DefaultSecureContainerFilter<F extends Filter>
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.