Codota Logo
FilterChainManager.createChain
Code IndexAdd Codota to your IDE (free)

How to use
createChain
method
in
org.apache.shiro.web.filter.mgt.FilterChainManager

Best Java code snippets using org.apache.shiro.web.filter.mgt.FilterChainManager.createChain (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: apache/shiro

  protected void createChains(Map<String, String> urls, FilterChainManager manager) {
    if (CollectionUtils.isEmpty(urls)) {
      if (log.isDebugEnabled()) {
        log.debug("No urls to process.");
      }
      return;
    }

    if (log.isTraceEnabled()) {
      log.trace("Before url processing.");
    }

    for (Map.Entry<String, String> entry : urls.entrySet()) {
      String path = entry.getKey();
      String value = entry.getValue();
      manager.createChain(path, value);
    }
  }
}
origin: theonedev/onedev

@Inject
public OneFilterChainResolver(
    Set<FilterChainConfigurator> filterChainConfigurators, 
    BasicAuthenticationFilter basicAuthenticationFilter) {
  
  super();
  
  FilterChainManager filterChainManager = getFilterChainManager();
  
  filterChainManager.addFilter("authcBasic", basicAuthenticationFilter);
  
  for (FilterChainConfigurator configurator: filterChainConfigurators) {
    configurator.configure(filterChainManager);
  }
  
  filterChainManager.createChain("/**", "authcBasic");
}

org.apache.shiro.web.filter.mgtFilterChainManagercreateChain

Javadoc

Creates a filter chain for the given chainName with the specified chainDefinitionString.

Conventional Use

Because the FilterChainManager interface does not impose any restrictions on filter chain names, (it expects only Strings), a convenient convention is to make the chain name an actual URL path expression (such as an org.apache.shiro.util.AntPathMatcher). For example:

createChain(path_expression, path_specific_filter_chain_definition); This convention can be used by a FilterChainResolver to inspect request URL paths against the chain name (path) and, if a match is found, return the corresponding chain for runtime filtering.

Chain Definition Format

The chainDefinition method argument is expected to conform to the following format:
 
filter1[optional_config1], filter2[optional_config2], ..., filterN[optional_configN]
where
  1. filterN is the name of a filter previously #addFilter(String,javax.servlet.Filter) with the manager, and
  2. [optional_configN] is an optional bracketed string that has meaning for that particular filter for this particular chain
If the filter does not need specific config for that chain name/URL path, you may discard the brackets - that is, filterN[] just becomes filterN.

And because this method does create a chain, remember that order matters! The comma-delimited filter tokens in the chainDefinition specify the chain's execution order.

Examples

/account/** = authcBasic
This example says "Create a filter named ' /account/**' consisting of only the ' authcBasic' filter". Also because the authcBasic filter does not need any path-specific config, it doesn't have any config brackets [].

/remoting/** = authcBasic, roles[b2bClient], perms["remote:invoke:wan,lan"]
This example by contrast uses the 'roles' and 'perms' filters which do use bracket notation. This definition says:

Construct a filter chain named ' /remoting/**' which

  1. ensures the user is first authenticated ( authcBasic) then
  2. ensures that user has the b2bClient role, and then finally
  3. ensures that they have the remote:invoke:lan,wan permission.

Note: because elements within brackets [ ] can be comma-delimited themselves, you must quote the internal bracket definition if commas are needed (the above example has 'lan,wan'). If we didn't do that, the parser would interpret the chain definition as four tokens:

  1. authcBasic
  2. roles[b2bclient]
  3. perms[remote:invoke:lan
  4. wan]
which is obviously incorrect. So remember to use quotes if your internal bracket definitions need to use commas.

Popular methods of FilterChainManager

  • getChainNames
  • hasChains
  • proxy
  • addFilter
    Adds a filter to the 'pool' of available filters that can be used when #addToChain(String,String,Str
  • getFilters
    Returns the pool of available Filters managed by this manager, keyed by name.

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • runOnUiThread (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now