Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/filter/GGInAFilter.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | b1580e4d342a |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
89 * @param req request to servlet | 89 * @param req request to servlet |
90 * @param resp response of servlet | 90 * @param resp response of servlet |
91 * @param chain the filter chain | 91 * @param chain the filter chain |
92 */ | 92 */ |
93 @Override | 93 @Override |
94 public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) | 94 public void doFilter( |
95 ServletRequest req, | |
96 ServletResponse resp, | |
97 FilterChain chain | |
98 ) | |
95 throws IOException, ServletException | 99 throws IOException, ServletException |
96 { | 100 { |
97 if (this.deactivate) { | 101 if (this.deactivate) { |
98 log.debug("GGinAFilter is deactivated"); | 102 log.debug("GGinAFilter is deactivated"); |
99 chain.doFilter(req, resp); | 103 chain.doFilter(req, resp); |
102 | 106 |
103 HttpServletRequest sreq = (HttpServletRequest) req; | 107 HttpServletRequest sreq = (HttpServletRequest) req; |
104 | 108 |
105 String requesturi = sreq.getRequestURI(); | 109 String requesturi = sreq.getRequestURI(); |
106 if (log.isDebugEnabled()) { | 110 if (log.isDebugEnabled()) { |
107 for (Enumeration e = req.getAttributeNames() ; e.hasMoreElements() ;) { | 111 for (Enumeration e = req.getAttributeNames(); |
112 e.hasMoreElements(); | |
113 ) { | |
108 log.debug(e.nextElement()); | 114 log.debug(e.nextElement()); |
109 } | 115 } |
110 } | 116 } |
111 | 117 |
112 log.debug("Request for: " + requesturi); | 118 log.debug("Request for: " + requesturi); |
128 || requesturi.equals(path + SAML_SERVLET) | 134 || requesturi.equals(path + SAML_SERVLET) |
129 || requesturi.equals(path + FLYS_CSS)) { | 135 || requesturi.equals(path + FLYS_CSS)) { |
130 log.debug("Request for login " + requesturi); | 136 log.debug("Request for login " + requesturi); |
131 if (loginDisabled && requesturi.equals(path + LOGIN_JSP)) { | 137 if (loginDisabled && requesturi.equals(path + LOGIN_JSP)) { |
132 log.debug("Login disabled. Redirecting."); | 138 log.debug("Login disabled. Redirecting."); |
133 if (noAuthRedir.equals(LOGIN_JSP) || noAuthRedir.equals(path + LOGIN_JSP)) { | 139 if (noAuthRedir.equals(LOGIN_JSP) |
134 handleResponse(resp, false); /* Dont redirect to the same page */ | 140 || noAuthRedir.equals(path + LOGIN_JSP) |
141 ) { | |
142 handleResponse(resp, false); | |
143 /* Dont redirect to the same page */ | |
135 } else { | 144 } else { |
136 handleResponse(resp, true); | 145 handleResponse(resp, true); |
137 } | 146 } |
138 return; | 147 return; |
139 } | 148 } |
140 chain.doFilter(req, resp); | 149 chain.doFilter(req, resp); |
141 return; | 150 return; |
191 if (noAuthRedir.startsWith("http")) { | 200 if (noAuthRedir.startsWith("http")) { |
192 log.debug("Redirect to external page: " + noAuthRedir); | 201 log.debug("Redirect to external page: " + noAuthRedir); |
193 ((HttpServletResponse) resp).sendRedirect(noAuthRedir); | 202 ((HttpServletResponse) resp).sendRedirect(noAuthRedir); |
194 } else { | 203 } else { |
195 log.debug("Redirect to: " + noAuthRedir); | 204 log.debug("Redirect to: " + noAuthRedir); |
196 ((HttpServletResponse) resp).sendRedirect(this.sc.getContextPath() + | 205 ((HttpServletResponse) resp).sendRedirect( |
197 noAuthRedir); | 206 this.sc.getContextPath() + noAuthRedir); |
198 | |
199 } | 207 } |
200 } | 208 } |
201 | 209 |
202 private void sendNotAuthenticated(ServletResponse resp) throws IOException { | 210 private void sendNotAuthenticated(ServletResponse resp) throws IOException { |
203 log.debug("Send not authenticated"); | 211 log.debug("Send not authenticated"); |
204 ((HttpServletResponse)resp).sendError(HttpServletResponse.SC_FORBIDDEN, "User not authenticated"); | 212 ((HttpServletResponse)resp).sendError( |
205 } | 213 HttpServletResponse.SC_FORBIDDEN, "User not authenticated"); |
206 | 214 } |
207 private void handleResponse(ServletResponse resp, boolean redirect) throws IOException { | 215 |
216 private void handleResponse( | |
217 ServletResponse resp, | |
218 boolean redirect | |
219 ) throws IOException { | |
208 if (redirect) { | 220 if (redirect) { |
209 this.redirect(resp); | 221 this.redirect(resp); |
210 } | 222 } |
211 else { | 223 else { |
212 this.sendNotAuthenticated(resp); | 224 this.sendNotAuthenticated(resp); |
221 public void destroy() { | 233 public void destroy() { |
222 } | 234 } |
223 | 235 |
224 private Authentication auth(User user, String encoding) | 236 private Authentication auth(User user, String encoding) |
225 throws AuthenticationException, IOException { | 237 throws AuthenticationException, IOException { |
226 Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE); | 238 Features features = (Features)sc.getAttribute( |
239 Features.CONTEXT_ATTRIBUTE); | |
227 return AuthenticationFactory.getInstance(this.authmethod).auth( | 240 return AuthenticationFactory.getInstance(this.authmethod).auth( |
228 user.getName(), user.getPassword(), encoding, features, sc); | 241 user.getName(), user.getPassword(), encoding, features, sc); |
229 } | 242 } |
230 | 243 |
231 /** | 244 /** |