Tabnine Logo
FilterChainManager.createChain
Code IndexAdd Tabnine 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)

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

  • Finding current android device location
  • setRequestProperty (URLConnection)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getResourceAsStream (ClassLoader)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now