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.apache.struts2.dispatcher.FilterDispatcher.java
/** * Create a default {@link Dispatcher} that subclasses can override * with a custom Dispatcher, if needed./* ww w . j a va 2s . c o m*/ * * @param filterConfig Our FilterConfig * @return Initialized Dispatcher */ protected Dispatcher createDispatcher(FilterConfig filterConfig) { Map<String, String> params = new HashMap<String, String>(); for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); String value = filterConfig.getInitParameter(name); params.put(name, value); } return new Dispatcher(filterConfig.getServletContext(), params); }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void setupRequestUriTitleUrlPattern(FilterConfig filterConfig) { String pattern = filterConfig.getInitParameter("requestUriTitleUrlPattern"); if (pattern != null && pattern.trim().length() > 0) { this.requestUriTitleUrlPattern = Pattern.compile(pattern); }/* ww w. j a v a 2 s . c o m*/ }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void setupSubRequestUrlPatternUrlPattern(FilterConfig filterConfig) { String pattern = filterConfig.getInitParameter("subRequestUrlPattern"); if (pattern != null && pattern.trim().length() > 0) { this.subRequestUrlPattern = Pattern.compile(pattern); }//from w w w. j a v a 2 s . c o m }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void setupExceptUrlPattern(FilterConfig filterConfig) { String pattern = filterConfig.getInitParameter("exceptUrlPattern"); if (pattern == null || pattern.trim().length() == 0) { pattern = filterConfig.getInitParameter("ignoreUrlPattern"); // for compatible }//ww w .j a v a 2s . c o m if (pattern != null && pattern.trim().length() > 0) { this.exceptUrlPattern = Pattern.compile(pattern); } }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void setupExceptExtSet(FilterConfig filterConfig) { final String value = filterConfig.getInitParameter("exceptExtSet"); if (value != null) { final String[] splitAry = value.split(","); // e.g. js,css,png,gif,jpg,ico,svg,svgz,ttf exceptExtSet = new LinkedHashSet<String>(); for (String element : splitAry) { exceptExtSet.add("." + element.trim()); }/* ww w . ja v a2 s. com*/ } else { // as default final List<String> defaultExtList = getDefaultExceptExtSet(); exceptExtSet = new LinkedHashSet<String>(defaultExtList); } }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void setupRequestCharacterEncoding(FilterConfig filterConfig) { this.requestCharacterEncoding = filterConfig.getInitParameter("requestCharacterEncoding"); }
From source file:org.infoglue.cms.security.InfoGlueAuthenticationFilter.java
public void init(FilterConfig config) throws ServletException { loginUrl = config.getInitParameter("org.infoglue.cms.security.loginUrl"); logoutUrl = config.getInitParameter("org.infoglue.cms.security.logoutUrl"); invalidLoginUrl = config.getInitParameter("org.infoglue.cms.security.invalidLoginUrl"); successLoginBaseUrl = config.getInitParameter("org.infoglue.cms.security.successLoginBaseUrl"); authenticatorClass = config.getInitParameter("org.infoglue.cms.security.authenticatorClass"); authorizerClass = config.getInitParameter("org.infoglue.cms.security.authorizerClass"); serverName = config.getInitParameter("org.infoglue.cms.security.serverName"); authConstraint = config.getInitParameter("org.infoglue.cms.security.authConstraint"); extraParametersFile = config.getInitParameter("org.infoglue.cms.security.extraParametersFile"); casValidateUrl = config.getInitParameter("org.infoglue.cms.security.casValidateUrl"); casProxyValidateUrl = config.getInitParameter("org.infoglue.cms.security.casProxyValidateUrl"); casServiceUrl = config.getInitParameter("org.infoglue.cms.security.casServiceUrl"); casLogoutUrl = config.getInitParameter("org.infoglue.cms.security.casLogoutUrl"); //casRenew = config.getInitParameter("org.infoglue.cms.security.casRenew"); if (extraParametersFile != null) { try {/* w w w . ja va2 s.c o m*/ extraProperties = new Properties(); extraProperties.load(CmsPropertyHandler.class.getResourceAsStream("/" + extraParametersFile)); } catch (Exception e) { logger.error("Error loading properties from file " + "/" + extraParametersFile + ". Reason:" + e.getMessage()); e.printStackTrace(); } } try { initializeCMSProperties(); } catch (Exception e) { e.printStackTrace(); } this.filterConfig = config; String filterURIs = filterConfig.getInitParameter(FILTER_URIS_PARAMETER); uriMatcher = URIMatcher.compilePatterns(splitString(filterURIs, ","), false); try { boolean anonymousExists = UserControllerProxy.getController() .userExists(CmsPropertyHandler.getAnonymousUser()); if (!anonymousExists) logger.error("The anonymous user '" + CmsPropertyHandler.getAnonymousUser() + "' was not found. Add it immediately."); } catch (Exception e) { logger.error("Error checking if the anonymous user '" + CmsPropertyHandler.getAnonymousUser() + "' was not found. Message:" + e.getMessage()); } }
From source file:org.alfresco.web.scripts.servlet.X509ServletFilterBase.java
public void init(FilterConfig config) throws ServletException { try {/*from w w w .j av a2 s . c o m*/ /* * Find out if we are enforcing. */ if (logger.isDebugEnabled()) { logger.debug("Initializing X509ServletFilter"); } this.enforce = checkEnforce(config.getServletContext()); if (logger.isDebugEnabled()) { logger.debug("Enforcing X509 Authentication:" + this.enforce); } if (this.enforce) { /* * We are enforcing so get the cert-contains string. */ this.certContains = config.getInitParameter("cert-contains"); if (logger.isDebugEnabled()) { if (certContains == null) { logger.debug("Not enforcing cert-contains"); } else { logger.debug("Enforcing cert-contains:" + this.certContains); } } } } catch (Exception e) { throw new ServletException(e); } }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected boolean isBooleanParameter(FilterConfig filterConfig, String name, boolean defaultValue) { final String value = filterConfig.getInitParameter(name); return value != null ? value.trim().equalsIgnoreCase("true") : defaultValue; }
From source file:org.apache.click.extras.cayenne.DataContextFilter.java
/** * Initialize the shared Cayenne configuration. If the * <tt>use-shared-cache</tt> init parameter is defined * * @see Filter#init(FilterConfig)//from w ww. j a v a2 s . c o m * * @param config the filter configuration * @throws RuntimeException if an initialization error occurs */ public synchronized void init(FilterConfig config) { HtmlStringBuffer buffer = new HtmlStringBuffer(); buffer.append("DataContextFilter initialized: "); filterConfig = config; ServletUtil.initializeSharedConfiguration(config.getServletContext()); dataDomain = Configuration.getSharedConfiguration().getDomain(); String value = null; value = config.getInitParameter("auto-rollback"); if (StringUtils.isNotBlank(value)) { autoRollback = "true".equalsIgnoreCase(value); } buffer.append(" auto-rollback=" + autoRollback); value = config.getInitParameter("session-scope"); if (StringUtils.isNotBlank(value)) { sessionScope = "true".equalsIgnoreCase(value); } buffer.append(", session-scope=" + sessionScope); value = config.getInitParameter("shared-cache"); if (StringUtils.isNotBlank(value)) { sharedCache = "true".equalsIgnoreCase(value); } buffer.append(", shared-cache="); buffer.append((sharedCache != null) ? sharedCache : "default"); value = config.getInitParameter("oscache-enabled"); boolean oscacheEnabled = "true".equalsIgnoreCase(value); if (oscacheEnabled) { dataDomain.setQueryCacheFactory(new OSQueryCacheFactory()); } buffer.append(", oscache-enabled=" + oscacheEnabled); String classname = config.getInitParameter("lifecycle-listener"); if (StringUtils.isNotEmpty(classname)) { try { @SuppressWarnings("unchecked") Class listenerClass = ClickUtils.classForName(classname); LifecycleCallbackRegistry registry = dataDomain.getEntityResolver().getCallbackRegistry(); LifecycleListener lifecycleListener = (LifecycleListener) listenerClass.newInstance(); if (registry.isEmpty(LifecycleEvent.POST_LOAD)) { registry.addDefaultListener(lifecycleListener); buffer.append(", lifecycle-listener=" + classname); } else { String message = "Could not get LifecycleCallbackRegistry from domain: " + dataDomain.getName(); throw new RuntimeException(message); } } catch (Exception e) { String message = "Could not configure LifecycleCallbackRegistry: " + classname; throw new RuntimeException(message, e); } } // Log init data, note LogService is not yet initialized getFilterConfig().getServletContext().log(buffer.toString()); }