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.hadoop.gateway.dispatch.DefaultHttpClientFactory.java
private int getMaxConnections(FilterConfig filterConfig) { int maxConnections = 32; GatewayConfig config = (GatewayConfig) filterConfig.getServletContext() .getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE); if (config != null) { maxConnections = config.getHttpClientMaxConnections(); }/*from w w w . j av a 2s.c o m*/ String str = filterConfig.getInitParameter("httpclient.maxConnections"); if (str != null) { try { maxConnections = Integer.parseInt(str); } catch (NumberFormatException e) { // Ignore it and use the default. } } return maxConnections; }
From source file:org.overlord.commons.auth.filters.SamlBearerTokenAuthFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */// w ww . jav a2s .c o m @Override public void init(FilterConfig config) throws ServletException { // Realm String parameter = config.getInitParameter("realm"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { realm = parameter; } else { realm = defaultRealm(); } // Allowed issuers parameter = config.getInitParameter("allowedIssuers"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { allowedIssuers = new HashSet<String>(); String[] split = parameter.split(","); //$NON-NLS-1$ for (String issuer : split) { allowedIssuers.add(issuer); } } else { allowedIssuers = defaultAllowedIssuers(); } // Signature Required parameter = config.getInitParameter("signatureRequired"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { signatureRequired = Boolean.parseBoolean(parameter); } else { signatureRequired = defaultSignatureRequired(); } // Keystore Path parameter = config.getInitParameter("keystorePath"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keystorePath = parameter; } else { keystorePath = defaultKeystorePath(); } // Keystore Password parameter = config.getInitParameter("keystorePassword"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keystorePassword = parameter; } else { keystorePassword = defaultKeystorePassword(); } // Key alias parameter = config.getInitParameter("keyAlias"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keyAlias = parameter; } else { keyAlias = defaultKeyAlias(); } // Key Password parameter = config.getInitParameter("keyPassword"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keyPassword = parameter; } else { keyPassword = defaultKeyPassword(); } }
From source file:mitm.djigzo.web.utils.IPFilter.java
private void initInetNetwork(FilterConfig filterConfig) throws UnknownHostException { /*/*from w ww . j a v a 2 s . co m*/ * The IP filter network will be loaded from the system properties (if available) */ String networkSpec = System.getProperty(IP_FILTER_NETWORK_PARAMETER); /* * If not set try to load it from the web.xml filter settings */ if (StringUtils.isBlank(networkSpec)) { networkSpec = filterConfig.getInitParameter("network"); } if (StringUtils.isBlank(networkSpec)) { networkSpec = "*"; } filter = new InetNetworkFilter(networkSpec); logger.info("IPFilter initialized with network " + networkSpec); }
From source file:org.esco.cas.client.CasSingleLogoutClusterFilter.java
@Override public void init(final FilterConfig config) throws ServletException { // Get local hostName on initialization this.clientHostName = config.getInitParameter(CasSingleLogoutClusterFilter.CLIENT_HOSTNAME_PARAMETER); if (!StringUtils.hasText(this.clientHostName)) { try {//from ww w.j av a2s. c o m final InetAddress localMachine = InetAddress.getLocalHost(); this.clientHostName = localMachine.getHostName(); CasSingleLogoutClusterFilter.LOG.info("Detected Hostname for local machine: [{}]", this.clientHostName); } catch (UnknownHostException e) { final String errorMsg = String.format( "Error while detecting IP Address of server. You need to configure the filter parameter: [%1$s]", CasSingleLogoutClusterFilter.CLIENT_HOSTNAME_PARAMETER); CasSingleLogoutClusterFilter.LOG.error(errorMsg, e); } } // Get comma delimited list of peer dns names from a filter config final String peerList = config.getInitParameter(CasSingleLogoutClusterFilter.PEERS_PARAMETER); if (!StringUtils.hasText(peerList)) { CasSingleLogoutClusterFilter.LOG .warn("No peers URL configured the CasSingleLogoutClusterFilter will not works !"); } String[] peersDescription = peerList.split(","); for (String peerDescription : peersDescription) { try { this.peers.add(new Peer(peerDescription)); } catch (MalformedURLException e) { // We don't block the webapp initializiation. Just log an error. CasSingleLogoutClusterFilter.LOG.error( "Malformed peer URL [{}] among CasSingleLogoutClusterFilter peers !", peerDescription); //throw new ServletException("Malformed URL among CasSingleLogoutClusterFilter peers !", e); } } if (!StringUtils.hasText(this.clientHostName)) { CasSingleLogoutClusterFilter.LOG .warn("No client hostname configured the CasSingleLogoutClusterFilter may not works !"); } if (CollectionUtils.isEmpty(this.peers)) { CasSingleLogoutClusterFilter.LOG .warn("No valid peers URL configured the CasSingleLogoutClusterFilter will not works !"); } CasSingleLogoutClusterFilter.LOG.info("Client hostname: [{}]", this.clientHostName); CasSingleLogoutClusterFilter.LOG.info("SLO cluster peers: [{}]", peerList.toString()); }
From source file:org.infoscoop.googleapps.GoogleAppsOpenIDFilter.java
public void init(FilterConfig config) throws ServletException { excludePaths.add("/gapps_openid_login.jsp"); String excludePathStr = config.getInitParameter("excludePath"); if (excludePathStr != null) { String[] pathArray = excludePathStr.split(","); for (int i = 0; i < pathArray.length; i++) { String path = pathArray[i].trim(); if (path.endsWith("*")) { excludePaths.add(path.substring(0, path.length() - 1)); } else { excludePaths.add(path);/*from w w w . jav a2 s .c om*/ } } } String domainParam = config.getInitParameter("domain"); if (domainParam != null) { if (log.isInfoEnabled()) log.info("loginUrl is set to " + domainParam); this.domain = domainParam; } try { this.consumerHelper = createConsumerHelper(config); } catch (Throwable e) { e.printStackTrace(); throw new ServletException(e); } }
From source file:inet.common.jsf.request.FileUploadFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { boolean isAtLeastJSF22 = detectJSF22(); String uploader = filterConfig.getServletContext().getInitParameter("primefaces.UPLOADER"); if (uploader == null || uploader.equals("auto")) { bypass = isAtLeastJSF22;//from www. j a v a 2 s . c o m } else if (uploader.equals("native")) { bypass = true; } else if (uploader.equals("commons")) { bypass = false; } thresholdSize = filterConfig.getInitParameter(THRESHOLD_SIZE_PARAM); uploadDir = filterConfig.getInitParameter(UPLOAD_DIRECTORY_PARAM); }
From source file:esg.node.filters.UrlResolvingFilter.java
public void init(FilterConfig filterConfig) throws ServletException { System.out.println("Initializing filter: " + this.getClass().getName()); this.filterConfig = filterConfig; dbProperties = new Properties(); System.out.println("FilterConfig is : " + filterConfig); System.out.println("db.protocol is : " + filterConfig.getInitParameter("db.protocol")); dbProperties.put("db.protocol", filterConfig.getInitParameter("db.protocol")); dbProperties.put("db.host", filterConfig.getInitParameter("db.host")); dbProperties.put("db.port", filterConfig.getInitParameter("db.port")); dbProperties.put("db.database", filterConfig.getInitParameter("db.database")); dbProperties.put("db.user", filterConfig.getInitParameter("db.user")); dbProperties.put("db.password", filterConfig.getInitParameter("db.password")); log.trace("Database parameters: " + dbProperties); DatabaseResource.init(filterConfig.getInitParameter("db.driver")).setupDataSource(dbProperties); DatabaseResource.getInstance().showDriverStats(); urlResolvingDAO = new UrlResolvingDAO(DatabaseResource.getInstance().getDataSource()); String extensionsParam = filterConfig.getInitParameter("extensions"); if (extensionsParam == null) { extensionsParam = ""; } //defensive program against null for this param String[] extensions = (".nc," + extensionsParam.toString()).split(","); StringBuffer sb = new StringBuffer(); for (int i = 0; i < extensions.length; i++) { sb.append(extensions[i].trim()); if (i < extensions.length - 1) sb.append("|"); }//from ww w . j a v a 2 s .c o m System.out.println("looking for extensions: " + sb.toString()); String regex = "http.*(?:" + sb.toString() + ")$"; System.out.println("Regex = " + regex); urlPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); log.trace(urlResolvingDAO.toString()); }
From source file:com.logiclander.jaasmine.authentication.http.JaasLoginFilter.java
/** * {@inheritDoc}//from w w w . j a va 2 s . c o m * * Checks the given FilterConfig for the init-params named appName and * loginServletName. If these values are not in the FilterConfig, then * the default values are used. */ @Override public void init(FilterConfig filterConfig) throws ServletException { appName = filterConfig.getInitParameter("appName"); if (appName == null || appName.isEmpty()) { appName = AuthenticationService.DEFAULT_JAASMINE_LOGIN_CONFIG; } loginPath = filterConfig.getInitParameter("loginPath"); if (loginPath == null || loginPath.isEmpty()) { loginPath = EMPTY_STRING; } loginRedirect = filterConfig.getInitParameter("loginRedirect"); if (loginRedirect == null || loginRedirect.isEmpty()) { loginRedirect = EMPTY_STRING; } loginServletName = filterConfig.getInitParameter("loginServletName"); if (loginServletName == null || loginServletName.isEmpty()) { loginServletName = DEFAULT_NAMED_LOGIN_DISPATCHER; } String setRemoteUserOnLoginParam = filterConfig.getInitParameter("setRemoteUserOnLogin"); if (setRemoteUserOnLoginParam == null || setRemoteUserOnLoginParam.isEmpty()) { setRemoteUserOnLoginParam = DEFAULT_SET_REMOTE_USER_ON_LOGIN; } setRemoteUserOnLogin = Boolean.parseBoolean(setRemoteUserOnLoginParam); filterName = filterConfig.getFilterName(); isUsingBasicAuthentication = Boolean.valueOf(filterConfig.getInitParameter("setBasicAuth")); if (logger.isDebugEnabled()) { logger.debug(String.format("%s initialized", toString())); logger.debug(String.format("loginPath = %s", loginPath == EMPTY_STRING ? "Not set" : loginPath)); logger.debug( String.format("loginRedirect = %s", loginRedirect == EMPTY_STRING ? "Not set" : loginRedirect)); logger.debug(String.format("loginServletName = %s", loginServletName)); logger.debug(String.format("setRemoteUserOnLogin = %s", Boolean.toString(setRemoteUserOnLogin))); } }
From source file:org.sakaiproject.util.ResponseHeaderFilter.java
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { String webappName = filterConfig.getServletContext().getServletContextName(); // storing the header information in a local map for (Enumeration<String> paramNames = filterConfig.getInitParameterNames(); paramNames.hasMoreElements();) { String paramName = paramNames.nextElement(); String paramValue = filterConfig.getInitParameter(paramName); if (paramName != null && paramValue != null) { this.headerMap.put(paramName, paramValue); }//from w ww . j av a 2 s .c om } // adding the configured ones from sakai config ServerConfigurationService serverConfigurationService = org.sakaiproject.component.cover.ServerConfigurationService .getInstance(); if (serverConfigurationService != null) { String[] headerStrings = serverConfigurationService.getStrings("response.headers"); if (headerStrings != null) { for (String headerString : headerStrings) { if (headerString != null && !"".equals(headerString)) { int loc = headerString.indexOf("::"); if (loc <= 0) { log.warn("Invalid header string in sakai config (must contain '::', e.g. key::value): " + headerString); continue; } String name = headerString.substring(0, loc); if (name == null || "".equals(name)) { log.warn("Invalid header string in sakai config (name must not be empty): " + headerString); continue; } String value = null; if (headerString.length() > loc + 2) { value = headerString.substring(loc + 2); } addHeader(name, value); if (value == null) { log.info("Removing header (" + name + ") from all responses for current webapp: " + webappName); } else { log.info("Adding header (" + name + " -> " + value + ") to all responses for current webapp: " + webappName); } } } } } log.info("INIT: for webapp " + webappName); }
From source file:com.raissi.utils.CustomFileUploadFilter.java
public void init(FilterConfig filterConfig) throws ServletException { boolean isAtLeastJSF22 = detectJSF22(); String uploader = filterConfig.getServletContext().getInitParameter(Constants.ContextParams.UPLOADER); if (uploader == null || uploader.equals("auto")) bypass = isAtLeastJSF22 ? true : false; else if (uploader.equals("native")) bypass = true;/* ww w . j a v a 2 s . c o m*/ else if (uploader.equals("commons")) bypass = false; thresholdSize = filterConfig.getInitParameter(THRESHOLD_SIZE_PARAM); uploadDir = filterConfig.getInitParameter(UPLOAD_DIRECTORY_PARAM); logger.debug("FileUploadFilter initiated successfully"); }