diff options
author | Vitaly Takmazov | 2017-04-06 00:03:39 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-04-06 00:03:39 +0300 |
commit | 1afe74766ec76850fa08d03581d8c50055277dde (patch) | |
tree | bd6ce42ac2f3111fe8f31e39431ad4781e651610 /juick-server/src/main/java | |
parent | 79317e4ca1d023019f9a30cf7bed7b0231b57b71 (diff) |
juick-server: refactor HashParamAuthenticationFilter using Spring WebUtils
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java b/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java index d1358a20..b384a8c8 100644 --- a/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java +++ b/juick-server/src/main/java/com/juick/server/security/HashParamAuthenticationFilter.java @@ -10,6 +10,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.RememberMeServices; import org.springframework.util.Assert; import org.springframework.web.filter.OncePerRequestFilter; +import org.springframework.web.util.WebUtils; import javax.servlet.FilterChain; import javax.servlet.ServletException; @@ -71,19 +72,12 @@ public class HashParamAuthenticationFilter extends OncePerRequestFilter { } private String getHashFromRequest(HttpServletRequest request) { - String hash = request.getHeader(PARAM_NAME); + String paramHash = request.getParameter(PARAM_NAME); + Cookie cookieHash = WebUtils.getCookie(request, PARAM_NAME); - if (hash == null) - hash = request.getParameter(PARAM_NAME); - - Cookie[] cookies = request.getCookies(); - - if (hash == null && cookies != null) - for (Cookie cookie : cookies) - if (PARAM_NAME.equals(cookie.getName())) { - hash = cookie.getValue(); - break; - } - return hash; + if (paramHash == null && cookieHash != null) { + return cookieHash.getValue(); + } + return paramHash; } } |