private static FilterInfo getFilterInfo(FilterDef fd) {
   FilterInfo fi = new FilterInfo();
   fi.setFilterName(fd.getFilterName());
   fi.setFilterClass(fd.getFilterClass());
   fi.setFilterDesc(fd.getDescription());
   return fi;
 }
  /** Return a String representation of this object. */
  @Override
  public String toString() {

    StringBuilder sb = new StringBuilder("ApplicationFilterConfig[");
    sb.append("name=");
    sb.append(filterDef.getFilterName());
    sb.append(", filterClass=");
    sb.append(filterDef.getFilterClass());
    sb.append("]");
    return (sb.toString());
  }
  /**
   * Return the application Filter we are configured for.
   *
   * @exception ClassCastException if the specified class does not implement the <code>
   *     javax.servlet.Filter</code> interface
   * @exception ClassNotFoundException if the filter class cannot be found
   * @exception IllegalAccessException if the filter class cannot be publicly instantiated
   * @exception InstantiationException if an exception occurs while instantiating the filter object
   * @exception ServletException if thrown by the filter's init() method
   * @throws NamingException
   * @throws InvocationTargetException
   */
  Filter getFilter()
      throws ClassCastException, ClassNotFoundException, IllegalAccessException,
          InstantiationException, ServletException, InvocationTargetException, NamingException {

    // Return the existing filter instance, if any
    if (this.filter != null) return (this.filter);

    // Identify the class loader we will be using
    String filterClass = filterDef.getFilterClass();
    this.filter = (Filter) getInstanceManager().newInstance(filterClass);

    initFilter();

    return (this.filter);
  }
  public List getApplicationFilterMaps(Context context) {
    FilterMap[] fms = context.findFilterMaps();
    List filterMaps = new ArrayList(fms.length);
    for (int i = 0; i < fms.length; i++) {
      if (fms[i] != null) {
        String dm;
        switch (fms[i].getDispatcherMapping()) {
          case FilterMap.ERROR:
            dm = "ERROR";
            break;
          case FilterMap.FORWARD:
            dm = "FORWARD";
            break;
            // case FilterMap.FORWARD_ERROR: dm = "FORWARD,ERROR"; break;
          case FilterMap.INCLUDE:
            dm = "INCLUDE";
            break;
            // case FilterMap.INCLUDE_ERROR: dm = "INCLUDE,ERROR"; break;
            // case FilterMap.INCLUDE_ERROR_FORWARD: dm = "INCLUDE,ERROR,FORWARD"; break;
            // case FilterMap.INCLUDE_FORWARD: dm = "INCLUDE,FORWARD"; break;
          case FilterMap.REQUEST:
            dm = "REQUEST";
            break;
            // case FilterMap.REQUEST_ERROR: dm = "REQUEST,ERROR"; break;
            // case FilterMap.REQUEST_ERROR_FORWARD: dm = "REQUEST,ERROR,FORWARD"; break;
            // case FilterMap.REQUEST_ERROR_FORWARD_INCLUDE: dm = "REQUEST,ERROR,FORWARD,INCLUDE";
            // break;
            // case FilterMap.REQUEST_ERROR_INCLUDE: dm = "REQUEST,ERROR,INCLUDE"; break;
            // case FilterMap.REQUEST_FORWARD: dm = "REQUEST,FORWARD"; break;
            // case FilterMap.REQUEST_INCLUDE: dm = "REQUEST,INCLUDE"; break;
            // case FilterMap.REQUEST_FORWARD_INCLUDE: dm = "REQUEST,FORWARD,INCLUDE"; break;
          default:
            dm = "";
        }

        String filterClass = "";
        org.apache.tomcat.util.descriptor.web.FilterDef fd =
            context.findFilterDef(fms[i].getFilterName());
        if (fd != null) {
          filterClass = fd.getFilterClass();
        }

        List filterMappings = getFilterMappings(fms[i], dm, filterClass);
        filterMaps.addAll(filterMappings);
      }
    }
    return filterMaps;
  }
  /** Release the Filter instance associated with this FilterConfig, if there is one. */
  void release() {

    unregisterJMX();

    if (this.filter != null) {
      try {
        if (Globals.IS_SECURITY_ENABLED) {
          try {
            SecurityUtil.doAsPrivilege("destroy", filter);
          } finally {
            SecurityUtil.remove(filter);
          }
        } else {
          filter.destroy();
        }
      } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        context
            .getLogger()
            .error(
                sm.getString(
                    "applicationFilterConfig.release",
                    filterDef.getFilterName(),
                    filterDef.getFilterClass()),
                t);
      }
      if (!context.getIgnoreAnnotations()) {
        try {
          ((StandardContext) context).getInstanceManager().destroyInstance(this.filter);
        } catch (Exception e) {
          Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
          ExceptionUtils.handleThrowable(t);
          context.getLogger().error("ApplicationFilterConfig.preDestroy", t);
        }
      }
    }
    this.filter = null;
  }
 /** Return the class of the filter we are configuring. */
 public String getFilterClass() {
   return filterDef.getFilterClass();
 }