List of usage examples for javax.servlet FilterConfig getInitParameter
public String getInitParameter(String name);
String
containing the value of the named initialization parameter, or null
if the initialization parameter does not exist. From source file:org.glite.slcs.acl.AccessControlListFactory.java
/** * Creates a new instance of AccessControlList implementation. * /*w w w. j av a2 s. co m*/ * @param filterConfig * The FilterConfig containing the ACLImplementation parameter. * @return A new instance of the implmenting AccessControlList * @throws SLCSException * If the instantiation of the AccessControlList * implementation failed. */ public static AccessControlList newInstance(FilterConfig filterConfig) throws SLCSException { // get implementing class name String className = filterConfig.getInitParameter("ACLImplementation"); // check null or empty if (className == null || className.equals("")) { throw new SLCSConfigurationException("Filter parameter ACLImplementation is missing or empty"); } LOG.info("AccessControlList implementation=" + className); // instantiate new AccessControlList impl = null; try { impl = (AccessControlList) Class.forName(className).newInstance(); impl.init(filterConfig); } catch (InstantiationException e) { LOG.error("Can not instantiate class: " + className, e); throw new SLCSException("Can not instantiate class: " + className, e); } catch (IllegalAccessException e) { LOG.error("Illegal access for class: " + className, e); throw new SLCSException("Illegal access for class: " + className, e); } catch (ClassNotFoundException e) { LOG.error("Implementation not found: " + className, e); throw new SLCSException("Implementation not found: " + className, e); } return impl; }
From source file:org.xchain.framework.filter.MultipartFormDataFilter.java
protected static int getIntInitParameter(FilterConfig filterConfig, String parameterName, int defaultValue) throws ServletException { int value = defaultValue; String parameterValue = filterConfig.getInitParameter(parameterName); if (parameterValue != null) { try {// ww w . jav a 2s. c o m value = Integer.parseInt(parameterValue); } catch (NumberFormatException nfe) { throw new ServletException("Could not parse " + parameterName + " parameter for filter " + filterConfig.getFilterName() + ".", nfe); } } return value; }
From source file:org.xchain.framework.filter.MultipartFormDataFilter.java
protected static long getLongInitParameter(FilterConfig filterConfig, String parameterName, long defaultValue) throws ServletException { long value = defaultValue; String parameterValue = filterConfig.getInitParameter(parameterName); if (parameterValue != null) { try {/*from w ww . ja va 2s. c o m*/ value = Long.parseLong(parameterValue); } catch (NumberFormatException nfe) { throw new ServletException("Could not parse " + parameterName + " parameter for filter " + filterConfig.getFilterName() + ".", nfe); } } return value; }
From source file:org.jdesigner.platform.web.filter.FilterHelpers.java
/** * Gets the forwardTo init parameter that is common to many filters. * /*from w w w . j a va 2 s.c om*/ * @param filterConfig * The filterConfig instance associated with the filter. * @return The value of the forwardTo init param. */ public static String initForwardTo(FilterConfig filterConfig) { String forwardTo = filterConfig.getInitParameter("forwardTo"); log.info("forwardTo = " + forwardTo); return forwardTo; }
From source file:org.jdesigner.platform.web.filter.FilterHelpers.java
/** * Gets the redirectTo init parameter that is common to many filters. * //w w w . j av a 2 s .c o m * @param filterConfig * The filterConfig instance associated with the filter. * @return The value of the redirectTo init param. */ public static String initRedirectTo(FilterConfig filterConfig) { String redirectTo = filterConfig.getInitParameter("redirectTo"); log.info("redirectTo = " + redirectTo); return redirectTo; }
From source file:org.xchain.framework.filter.MultipartFormDataFilter.java
protected static String getStringInitParameter(FilterConfig filterConfig, String parameterName, String defaultValue) throws ServletException { // get the value. String value = defaultValue;//from ww w .j a v a 2s . co m String parameterValue = filterConfig.getInitParameter(parameterName); if (parameterValue != null) { value = parameterValue; } return value; }
From source file:org.apache.ambari.server.security.authorization.AmbariAuthorizationFilter.java
/** * Get the parameter value from the given servlet filter configuration. * * @param filterConfig the servlet configuration * @param parameterName the parameter name * @param defaultValue the default value * @return the parameter value or the default value if not set *///from w ww . ja v a 2 s. c o m private static String getParameterValue(FilterConfig filterConfig, String parameterName, String defaultValue) { String value = filterConfig.getInitParameter(parameterName); if (value == null || value.length() == 0) { value = filterConfig.getServletContext().getInitParameter(parameterName); } return value == null || value.length() == 0 ? defaultValue : value; }
From source file:com.zz.globalsession.filter.AbstractGlobalSessionFilter.java
protected static String getConfigValue(FilterConfig config, String keyName) { String fromInitParam = config.getInitParameter(keyName); if (fromInitParam != null) { return fromInitParam; }/*w w w. jav a2 s . co m*/ return System.getProperty(keyName); }
From source file:org.jdesigner.platform.web.filter.FilterHelpers.java
/** * This is a common function used by a number of filters to get the init * parameter that describes the path list. * /*from w w w . j av a 2 s. c o m*/ * @param filterName * The name of the filter calling this function. This is for * logging purposes. * @param filterConfig * The filterConfig instance associated with the filter. * @return The pathSpec value. * @throws ServletException * If anything goes wrong. */ public static String initPathSpec(String filterName, FilterConfig filterConfig) throws ServletException { // Get the pathSpec init parameter. String pathSpec = filterConfig.getInitParameter("pathSpec"); if (pathSpec != null) { if (!pathSpec.equalsIgnoreCase("include") && !pathSpec.equalsIgnoreCase("exclude")) { String es = filterName + " could not initialize " + "because pathSpec init parameter " + "was not a valid value (must be 'include' or 'exclude')"; log.error(es); throw new ServletException(es); } } log.info("pathSpec = " + pathSpec); return pathSpec; }
From source file:org.jdesigner.platform.web.filter.FilterHelpers.java
/** * This is a common function used by a number of filters to get the list of * paths the filter will function or not function on. * /*from ww w . j a va 2 s .c om*/ * @param filterName * The name of the filter calling this function. This is for * logging purposes. * @param filterConfig * The filterConfig instance associated with the filter. * @return The list of paths configured for the filter. */ public static ArrayList initPathList(String filterName, FilterConfig filterConfig) { // Get the comma-separater list of paths pathList init parameter. String csvPathList = filterConfig.getInitParameter("pathList"); ArrayList al = new ArrayList(); if (csvPathList != null) { log.info("csvPathList = " + csvPathList); StringTokenizer st = new StringTokenizer(csvPathList, ","); // Parse the CSV. while (st.hasMoreTokens()) { String s = st.nextToken(); StringBuffer sb = new StringBuffer(s.length() + 10); // We need to replace any wildcard characters with a suitable // regex. for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '*') { sb.append(".*"); } else { sb.append(s.charAt(i)); } } // Modified paths can now be added to the collection. al.add(sb.toString()); } } log.info("pathList = " + al); return al; }