@Test public void testEndUserPage() throws Exception { String profilePage = "/XUI/#profile/"; String endUserPath = "/idm/EndUser"; HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse responseEndUser = mock(HttpServletResponse.class); FilterChain filterChain = mock(FilterChain.class); when(request.getRequestURI()).thenReturn(endUserPath); when(request.getQueryString()).thenReturn(null); filter.doFilter(request, responseEndUser, filterChain); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(responseEndUser).sendRedirect(captor.capture()); assertThat(captor.getValue()).isEqualTo(CONTEXT + profilePage); }
public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletResponse instanceof HttpServletResponse) || !(servletRequest instanceof HttpServletRequest)) { chain.doFilter(servletRequest, servletResponse); return; } HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest request = (HttpServletRequest) servletRequest; if (!initialized) { synchronized (this) { if (!initialized) { detectXUIMode(); } } } if (xuiEnabled && request.getRequestURI() != null) { String query = request.getQueryString(); if (query != null) { if (!query.startsWith("&")) { query = "&" + query; } } else { query = ""; } if (request.getRequestURI().contains("UI/Logout")) { response.sendRedirect(xuiLogoutPath + query); } else if (request.getRequestURI().contains("idm/EndUser")) { response.sendRedirect(profilePage + query); } else { response.sendRedirect(xuiLoginPath + query); } } else { chain.doFilter(servletRequest, servletResponse); } }
XUIFilter implements Filter, ServiceListener { public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletResponse instanceof HttpServletResponse) || !(servletRequest instanceof HttpServletRequest)) { chain.doFilter(servletRequest, servletResponse); return; } HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest request = (HttpServletRequest) servletRequest; if (!initialized) { synchronized (this) { if (!initialized) { detectXUIMode(); } } } if (xuiEnabled && request.getRequestURI() != null) { String query = request.getQueryString(); if (query != null) { if (!query.startsWith("&")) { query = "&" + query; } } else { query = ""; } if (request.getRequestURI().contains("UI/Logout")) { response.sendRedirect(xuiLogoutPath + query); } else if (request.getRequestURI().contains("idm/EndUser")) { response.sendRedirect(profilePage + query); } else { response.sendRedirect(xuiLoginPath + query); } } else { chain.doFilter(servletRequest, servletResponse); } } }
XUIFilter implements Filter, ServiceListener { public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletResponse instanceof HttpServletResponse) || !(servletRequest instanceof HttpServletRequest)) { chain.doFilter(servletRequest, servletResponse); return; } HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest request = (HttpServletRequest) servletRequest; if (!initialized) { synchronized (this) { if (!initialized) { detectXUIMode(); } } } if (xuiEnabled && request.getRequestURI() != null) { String query = request.getQueryString(); if (query != null) { if (!query.startsWith("&")) { query = "&" + query; } } else { query = ""; } if (request.getRequestURI().contains("UI/Logout")) { response.sendRedirect(xuiLogoutPath + query); } else if (request.getRequestURI().contains("idm/EndUser")) { response.sendRedirect(profilePage + query); } else { response.sendRedirect(xuiLoginPath + query); } } else { chain.doFilter(servletRequest, servletResponse); } }  }
XUIFilter implements Filter, ServiceListener { public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletResponse instanceof HttpServletResponse) || !(servletRequest instanceof HttpServletRequest)) { chain.doFilter(servletRequest, servletResponse); return; } HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest request = (HttpServletRequest) servletRequest; if (!initialized) { synchronized (this) { if (!initialized) { detectXUIMode(); } } } if (xuiEnabled && request.getRequestURI() != null) { String query = request.getQueryString(); if (query != null) { if (!query.startsWith("&")) { query = "&" + query; } } else { query = ""; } if (request.getRequestURI().contains("UI/Logout")) { response.sendRedirect(xuiLogoutPath + query); } else if (request.getRequestURI().contains("idm/EndUser")) { response.sendRedirect(profilePage + query); } else { response.sendRedirect(xuiLoginPath + query); } } else { chain.doFilter(servletRequest, servletResponse); } }  void init(FilterConfig filterConfig); void doFilter(
            ServletRequest servletRequest,
            ServletResponse servletResponse,
            FilterChain chain); void destroy(); void organizationConfigChanged(String serviceName, String version,
                                          String orgName, String groupName, String serviceComponent,
                                          int type); void globalConfigChanged(String serviceName, String version,
                                    String groupName, String serviceComponent, int type); void schemaChanged(String serviceName, String version); }
XUIFilter implements Filter, ServiceListener { public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletResponse instanceof HttpServletResponse) || !(servletRequest instanceof HttpServletRequest)) { chain.doFilter(servletRequest, servletResponse); return; } HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest request = (HttpServletRequest) servletRequest; if (!initialized) { synchronized (this) { if (!initialized) { detectXUIMode(); } } } if (xuiEnabled && request.getRequestURI() != null) { String query = request.getQueryString(); if (query != null) { if (!query.startsWith("&")) { query = "&" + query; } } else { query = ""; } if (request.getRequestURI().contains("UI/Logout")) { response.sendRedirect(xuiLogoutPath + query); } else if (request.getRequestURI().contains("idm/EndUser")) { response.sendRedirect(profilePage + query); } else { response.sendRedirect(xuiLoginPath + query); } } else { chain.doFilter(servletRequest, servletResponse); } }  void init(FilterConfig filterConfig); void doFilter(
            ServletRequest servletRequest,
            ServletResponse servletResponse,
            FilterChain chain); void destroy(); void organizationConfigChanged(String serviceName, String version,
                                          String orgName, String groupName, String serviceComponent,
                                          int type); void globalConfigChanged(String serviceName, String version,
                                    String groupName, String serviceComponent, int type); void schemaChanged(String serviceName, String version);  }