| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>DefaultFilter.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">Apache Shiro :: Test Coverage</a> > <a href="../index.html" class="el_bundle">shiro-web</a> > <a href="index.source.html" class="el_package">org.apache.shiro.web.filter.mgt</a> > <span class="el_source">DefaultFilter.java</span></div><h1>DefaultFilter.java</h1><pre class="source lang-java linenums">/* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.apache.shiro.web.filter.mgt; |
| |
| import org.apache.shiro.util.ClassUtils; |
| import org.apache.shiro.web.filter.authc.*; |
| import org.apache.shiro.web.filter.authz.*; |
| import org.apache.shiro.web.filter.session.NoSessionCreationFilter; |
| |
| import javax.servlet.Filter; |
| import javax.servlet.FilterConfig; |
| import javax.servlet.ServletException; |
| import java.util.LinkedHashMap; |
| import java.util.Map; |
| |
| /** |
| * Enum representing all of the default Shiro Filter instances available to web applications. Each filter instance is |
| * typically accessible in configuration the {@link #name() name} of the enum constant. |
| * |
| * @since 1.0 |
| */ |
| <span class="pc" id="L38">public enum DefaultFilter {</span> |
| |
| <span class="fc" id="L40"> anon(AnonymousFilter.class),</span> |
| <span class="fc" id="L41"> authc(FormAuthenticationFilter.class),</span> |
| <span class="fc" id="L42"> authcBasic(BasicHttpAuthenticationFilter.class),</span> |
| <span class="fc" id="L43"> logout(LogoutFilter.class),</span> |
| <span class="fc" id="L44"> noSessionCreation(NoSessionCreationFilter.class),</span> |
| <span class="fc" id="L45"> perms(PermissionsAuthorizationFilter.class),</span> |
| <span class="fc" id="L46"> port(PortFilter.class),</span> |
| <span class="fc" id="L47"> rest(HttpMethodPermissionFilter.class),</span> |
| <span class="fc" id="L48"> roles(RolesAuthorizationFilter.class),</span> |
| <span class="fc" id="L49"> ssl(SslFilter.class),</span> |
| <span class="fc" id="L50"> user(UserFilter.class);</span> |
| |
| private final Class<? extends Filter> filterClass; |
| |
| <span class="fc" id="L54"> private DefaultFilter(Class<? extends Filter> filterClass) {</span> |
| <span class="fc" id="L55"> this.filterClass = filterClass;</span> |
| <span class="fc" id="L56"> }</span> |
| |
| public Filter newInstance() { |
| <span class="fc" id="L59"> return (Filter) ClassUtils.newInstance(this.filterClass);</span> |
| } |
| |
| public Class<? extends Filter> getFilterClass() { |
| <span class="fc" id="L63"> return this.filterClass;</span> |
| } |
| |
| public static Map<String, Filter> createInstanceMap(FilterConfig config) { |
| <span class="fc" id="L67"> Map<String, Filter> filters = new LinkedHashMap<String, Filter>(values().length);</span> |
| <span class="fc bfc" id="L68" title="All 2 branches covered."> for (DefaultFilter defaultFilter : values()) {</span> |
| <span class="fc" id="L69"> Filter filter = defaultFilter.newInstance();</span> |
| <span class="pc bpc" id="L70" title="1 of 2 branches missed."> if (config != null) {</span> |
| try { |
| <span class="nc" id="L72"> filter.init(config);</span> |
| <span class="nc" id="L73"> } catch (ServletException e) {</span> |
| <span class="nc" id="L74"> String msg = "Unable to correctly init default filter instance of type " +</span> |
| <span class="nc" id="L75"> filter.getClass().getName();</span> |
| <span class="nc" id="L76"> throw new IllegalStateException(msg, e);</span> |
| <span class="nc" id="L77"> }</span> |
| } |
| <span class="fc" id="L79"> filters.put(defaultFilter.name(), filter);</span> |
| } |
| <span class="fc" id="L81"> return filters;</span> |
| } |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html> |