List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:br.com.insula.spring.security.janrain.JanrainAuthenticationFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String token = request.getParameter("token"); if (token != null && !token.isEmpty()) { try {/*from w ww. ja va 2 s. com*/ JanrainAuthenticationToken authentication = janrainService.authenticate(token); if (authentication != null) { return getAuthenticationManager().authenticate(authentication); } else { throw new AuthenticationServiceException( "Unable to parse authentication. Is your 'applicationName' correct?"); } } catch (Exception ex) { throw new ServletException(ex); } } return null; }
From source file:com.mirth.connect.server.servlets.MirthServlet.java
public boolean isUserAuthorizedForExtension(HttpServletRequest request, String extensionName, String operation, Map<String, Object> parameterMap) throws ServletException { try {/*w w w . ja v a 2s. c om*/ return authorizationController.isUserAuthorizedForExtension(getCurrentUserId(request), extensionName, operation, parameterMap, getRequestIpAddress(request)); } catch (ControllerException e) { throw new ServletException(e); } }
From source file:com.github.inspektr.error.web.ErrorLoggingFilter.java
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { try {//from ww w .j av a 2 s .co m filterChain.doFilter(request, response); } catch (final ServletException e) { this.errorLogManager.recordError(e); throw e; } catch (final IOException e) { this.errorLogManager.recordError(e); throw e; } catch (final Throwable t) { this.errorLogManager.recordError(t); throw new ServletException(t); } }
From source file:br.bireme.mlts.MoreLikeThatServlet.java
@Override public void init(final ServletConfig servletConfig) throws ServletException { final String sdir = servletConfig.getInitParameter("INDEX_DIR"); if (sdir == null) { throw new ServletException("missing index directory (INDEX_DIR) " + "parameter."); }//from ww w. j av a 2 s. c om final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_36); try { mlt = new MoreLikeThat(new File(sdir), analyzer); } catch (IOException ex) { throw new ServletException(ex); } final String maxHits = servletConfig.getInitParameter("MAX_HITS"); if (maxHits != null) { mlt.setMaxHits(Integer.parseInt(maxHits)); } final String minTermFreq = servletConfig.getInitParameter("MIN_TERM_FREQ"); if (minTermFreq != null) { mlt.setMinTermFreq(Integer.parseInt(minTermFreq)); } final String minDocFreq = servletConfig.getInitParameter("MIN_DOC_FREQ"); if (minDocFreq != null) { mlt.setMinDocFreq(Integer.parseInt(minDocFreq)); } final String maxDocFreq = servletConfig.getInitParameter("MAX_DOC_FREQ"); if (maxDocFreq != null) { mlt.setMaxDocFreq(Integer.parseInt(maxDocFreq)); } final String minWordLen = servletConfig.getInitParameter("MIN_WORD_LENGTH"); if (minWordLen != null) { mlt.setMinWordLen(Integer.parseInt(minWordLen)); } final String maxWordLen = servletConfig.getInitParameter("MAX_WORD_LENGTH"); if (maxWordLen != null) { mlt.setMaxWordLen(Integer.parseInt(maxWordLen)); } final String maxQueryTerms = servletConfig.getInitParameter("MAX_QUERY_TERMS"); if (maxQueryTerms != null) { mlt.setMaxQueryTerms(Integer.parseInt(maxQueryTerms)); } final String maxNumTokensParsed = servletConfig.getInitParameter("MAX_NUM_TOKENS_PARSED"); if (maxNumTokensParsed != null) { mlt.setMaxNumTokensParsed(Integer.parseInt(maxNumTokensParsed)); } final String minScore = servletConfig.getInitParameter("MIN_SCORE"); if (minScore != null) { mlt.setMinScore(Float.parseFloat(minScore)); } }
From source file:com.assignment4.security.ValidateSaltFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Assume its HTTP HttpServletRequest httpReq = (HttpServletRequest) request; // Get the salt sent with the request String salt = (String) httpReq.getParameter("randId"); // Validate that the salt is in the cache Cache<String, Boolean> csrfPreventionSaltCache = (Cache<String, Boolean>) httpReq.getSession() .getAttribute("csrfPreventionSaltCache"); if (csrfPreventionSaltCache != null && salt == null && (null != request.getParameter("activationtoken") || null != request.getParameter("crypt"))) { csrfPreventionSaltCache = CacheBuilder.newBuilder().maximumSize(5000) .expireAfterWrite(20, TimeUnit.MINUTES).build(); httpReq.getSession().setAttribute("csrfPreventionSaltCache", csrfPreventionSaltCache); // Generate the salt and store it in the users cache salt = RandomStringUtils.random(20, 0, 0, true, true, null, new SecureRandom()); csrfPreventionSaltCache.put(salt, Boolean.TRUE); // Add the salt to the current request so it can be used // by the page rendered in this request httpReq.setAttribute("randId", salt); }/*from www . j ava2 s .c o m*/ if (csrfPreventionSaltCache != null && salt != null && csrfPreventionSaltCache.getIfPresent(salt) != null) { // If the salt is in the cache, we move on chain.doFilter(request, response); } else { // Otherwise we throw an exception aborting the request flow throw new ServletException("Potential CSRF detected!! Inform a scary sysadmin ASAP."); } }
From source file:net.nikore.gozer.marathon.CallbackServlet.java
@Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { Map<String, Object> eventResponse = mapper.readValue(servletRequest.getInputStream(), new TypeReference<Map<String, Object>>() { });// ww w. ja v a 2s.c o m switch ((String) eventResponse.get("eventType")) { case "status_update_event": String taskStatus = (String) eventResponse.get("taskStatus"); if (!taskStatus.equals("TASK_STAGING") || !taskStatus.equals("TASK_STARTING")) { appCache.refreshClient((String) eventResponse.get("appId")); } break; case "api_post_event": Map<String, String> appDef = (Map<String, String>) eventResponse.get("appDefinition"); try { appCache.removeClient(appDef.get("id")); appCache.getClient(appDef.get("id")); } catch (ExecutionException e) { throw new ServletException(e); } break; case "app_terminated_event": appCache.removeClient((String) eventResponse.get("appId")); break; default: break; // } }
From source file:com.pocketgorilla.stripesem.TransactionFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (log.isDebugEnabled()) log.debug("filtering " + ((HttpServletRequest) request).getRequestURI()); try {//from w w w. j av a 2 s . c o m chain.doFilter(request, response); } catch (Exception ex) { try { EntityManager em = provider.getEntityManager(false); if (em != null) { EntityTransaction tx = em.getTransaction(); if (tx.isActive()) { tx.setRollbackOnly(); } } } finally { throw new ServletException(ex); } } finally { doAfter(); } }
From source file:com.esri.gpt.control.cart.XslBundler.java
/** * Processes the HTTP request./* w w w. ja v a2 s. c om*/ * @param request the HTTP request * @param response HTTP response * @param context request context * @throws Exception if an exception occurs */ @Override public void execute(HttpServletRequest request, HttpServletResponse response, RequestContext context) throws Exception { String[] keys = this.readKeys(request, context, true); String sXsltPath = Val.chkStr(request.getParameter("xslt")); String sMimeType = Val.chkStr(request.getParameter("mimeType")); String sContentDisposition = Val.chkStr(request.getParameter("contentDisposition")); if ((keys.length > 0) && (sXsltPath.length() > 0)) { if (!assertWhiteList(context, "catalog.cart.xslt.whitelist", sXsltPath)) { throw new ServletException("Invalid xslt parameter"); } XsltTemplate template = this.getCompiledTemplate(sXsltPath); ServletOutputStream out = response.getOutputStream(); if (sMimeType.length() == 0) { sMimeType = "text/plain"; } response.setContentType(StringEscapeUtils.escapeHtml4(Val.stripControls(sMimeType)) + ";charset=UTF-8"); if (sContentDisposition.length() > 0) { response.addHeader("Content-Disposition", StringEscapeUtils.escapeHtml4(Val.stripControls(sContentDisposition))); } try { for (String sKey : keys) { String sXml = this.readXml(request, context, sKey); String sResult = Val.chkStr(template.transform(sXml)); if (sResult.length() > 0) { byte[] bytes = sResult.getBytes("UTF-8"); out.write(bytes); out.flush(); } } } finally { out.flush(); out.close(); } } }
From source file:com.liusoft.dlog4j.servlet.DLOG_ActionServlet.java
/** * Globals.WEBAPP_PATH??access??????//from w w w .j a v a 2s .c o m */ public void init() throws ServletException { ServletContext context = getServletContext(); if (Globals.WEBAPP_PATH == null) Globals.WEBAPP_PATH = context.getRealPath(""); //? try { DLOGSecurityManager.init(context); } catch (IOException e) { throw new ServletException(e); } //??? try { DLOGUserManager.init(context); } catch (Exception e) { throw new ServletException(e); } //Struts? super.init(); encoding = getInitParameter("encoding"); if (encoding == null) encoding = Globals.ENC_UTF_8; }
From source file:eionet.rpcserver.servlets.XmlRpcRouter.java
/** * gets the service defs from the roster. *///from ww w . j a v a2s.c o m public void init(ServletConfig config) throws ServletException { super.init(config); xmlrpc = new XmlRpcServer(); try { HashMap services = UITServiceRoster.getServices(); Iterator iter = services.keySet().iterator(); while (iter.hasNext()) { String srvName = (String) iter.next(); xmlrpc.addHandler(srvName, new XmlRpcServiceHandler(srvName)); //Logger.log("** srv = " + srvName); } } catch (ServiceException se) { throw new ServletException(se); } catch (Exception e) { throw new ServletException(e); } }