congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
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

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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