List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:com.intuit.tank.util.RestSecurityFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (config.isRestSecurityEnabled()) { User user = getUser((HttpServletRequest) request); if (user == null) { // send 401 unauthorized and return HttpServletResponse resp = (HttpServletResponse) response; resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); return; // break filter chain, requested JSP/servlet will not be executed }//from w w w . ja v a 2s. com } chain.doFilter(request, response); }
From source file:com.microsoft.azure.oidc.filter.helper.impl.SimpleAuthenticationHelper.java
private void doExcludedAction(final FilterChain chain, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final Token token) throws IOException, ServletException { chain.doFilter(getSandboxWrapper(httpRequest, token), httpResponse); }
From source file:com.microsoft.azure.oidc.filter.helper.impl.SimpleAuthenticationHelper.java
private void doAuthenticatedAction(final FilterChain chain, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final Token token) throws IOException, ServletException { chain.doFilter(getAuthenticationWrapper(httpRequest, token), httpResponse); }
From source file:jenkins.security.ExceptionTranslationFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest)) { throw new ServletException("HttpServletRequest required"); }/*from ww w . j av a 2 s.co m*/ if (!(response instanceof HttpServletResponse)) { throw new ServletException("HttpServletResponse required"); } try { chain.doFilter(request, response); if (logger.isDebugEnabled()) { logger.debug("Chain processed normally"); } } catch (AuthenticationException ex) { handleException(request, response, chain, ex); } catch (AccessDeniedException ex) { handleException(request, response, chain, ex); } catch (ServletException ex) { if (ex.getRootCause() instanceof AuthenticationException || ex.getRootCause() instanceof AccessDeniedException) { handleException(request, response, chain, (AcegiSecurityException) ex.getRootCause()); } else { throw ex; } } catch (IOException ex) { throw ex; } }
From source file:com.devicehive.auth.rest.SimpleCORSFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { final HttpServletResponse resp = (HttpServletResponse) servletResponse; resp.setHeader("Access-Control-Allow-Credentials", "true"); resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PUT, DELETE, HEAD"); resp.setHeader("Access-Control-Max-Age", "0"); resp.setHeader("Access-Control-Allow-Headers", "Origin, Authorization, Accept, Content-Type, Auth-DeviceID, Auth-DeviceKey"); filterChain.doFilter(servletRequest, resp); }
From source file:org.tsm.concharto.web.filter.NotificationFilter.java
public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; //Ignore URLs like embedded maps String ignore = filterConfig.getInitParameter(CONFIG_IGNORE); if (!StringUtils.contains(request.getRequestURI(), ignore)) { String username = AuthHelper.getUsername(); if (notificationDao.notificationsExist(username)) { WebUtils.setSessionAttribute(request, SESSION_MESSAGES_PENDING, "yes"); }//from w ww .j av a2s . c om } chain.doFilter(request, response); }
From source file:net.sourceforge.fenixedu.presentationTier.servlets.filters.AnnualTeachingCreditsDocumentFilter.java
protected ByteArrayOutputStream getAnnualTeacherCreditsDocument(ServletRequest arg0, ServletResponse arg1, FilterChain arg2, Teacher teacher, ExecutionYear executionYear, RoleType role) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) arg0; ResponseWrapper response = (ResponseWrapper) arg1; request.setAttribute("teacher", teacher); request.setAttribute("executionYear", executionYear); arg2.doFilter(arg0, arg1); String responseHtml = clean(response.getContent()); DocumentBuilder builder;//from w ww.j a v a2 s .c om try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } Document doc; try { doc = builder.parse(new ByteArrayInputStream(responseHtml.getBytes())); } catch (SAXException e) { throw new IOException(e.getMessage()); } patchLinks(doc, request); ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(doc, ""); renderer.layout(); ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); try { renderer.createPDF(pdfStream); } catch (DocumentException e) { throw new IOException(e.getMessage()); } return pdfStream; }
From source file:net.roecky.grails.plugins.shiroProtectAny.filters.ShiroAnyUrlProtectionFilter.java
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Invoked filter for '" + req.getRequestURL()); }// www.j av a 2 s . co m // each (!) filtered call requires a valid authentication and permissions if (shiroAnyUrlProtection.accessControl(req, res, req.getSession())) { // found valid permission, continue the request chain.doFilter(request, response); } }
From source file:org.trustedanalytics.user.invite.MockedAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Authentication authenticationMock = mock(Authentication.class); doReturn(ImmutableList.of((GrantedAuthority) () -> "console.admin")).when(authenticationMock) .getAuthorities();//from w ww . j av a 2 s.c om doReturn((Principal) () -> "admin").when(authenticationMock).getPrincipal(); doReturn(true).when(authenticationMock).isAuthenticated(); doReturn("admin").when(authenticationMock).getName(); SecurityContextHolder.getContext().setAuthentication(authenticationMock); chain.doFilter(request, response); }