|
@@ -16,7 +16,6 @@
|
|
package org.springframework.security.web.authentication.rememberme;
|
|
package org.springframework.security.web.authentication.rememberme;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
-import java.lang.reflect.Method;
|
|
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
@@ -46,7 +45,6 @@ import org.springframework.security.web.authentication.RememberMeServices;
|
|
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
|
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
|
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
|
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
-import org.springframework.util.ReflectionUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -86,7 +84,6 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
|
private String key;
|
|
private String key;
|
|
private int tokenValiditySeconds = TWO_WEEKS_S;
|
|
private int tokenValiditySeconds = TWO_WEEKS_S;
|
|
private Boolean useSecureCookie = null;
|
|
private Boolean useSecureCookie = null;
|
|
- private Method setHttpOnlyMethod;
|
|
|
|
private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
|
|
private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
|
|
|
|
|
|
protected AbstractRememberMeServices(String key, UserDetailsService userDetailsService) {
|
|
protected AbstractRememberMeServices(String key, UserDetailsService userDetailsService) {
|
|
@@ -94,8 +91,6 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
|
Assert.notNull(userDetailsService, "UserDetailsService cannot be null");
|
|
Assert.notNull(userDetailsService, "UserDetailsService cannot be null");
|
|
this.key = key;
|
|
this.key = key;
|
|
this.userDetailsService = userDetailsService;
|
|
this.userDetailsService = userDetailsService;
|
|
- this.setHttpOnlyMethod = ReflectionUtils.findMethod(Cookie.class, "setHttpOnly",
|
|
|
|
- boolean.class);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -396,8 +391,8 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
|
*
|
|
*
|
|
* By default a secure cookie will be used if the connection is secure. You can set
|
|
* By default a secure cookie will be used if the connection is secure. You can set
|
|
* the {@code useSecureCookie} property to {@code false} to override this. If you set
|
|
* the {@code useSecureCookie} property to {@code false} to override this. If you set
|
|
- * it to {@code true}, the cookie will always be flagged as secure. If Servlet 3.0 is
|
|
|
|
- * used, the cookie will be marked as HttpOnly.
|
|
|
|
|
|
+ * it to {@code true}, the cookie will always be flagged as secure. By default the cookie
|
|
|
|
+ * will be marked as HttpOnly.
|
|
*
|
|
*
|
|
* @param tokens the tokens which will be encoded to make the cookie value.
|
|
* @param tokens the tokens which will be encoded to make the cookie value.
|
|
* @param maxAge the value passed to {@link Cookie#setMaxAge(int)}
|
|
* @param maxAge the value passed to {@link Cookie#setMaxAge(int)}
|
|
@@ -424,12 +419,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
|
cookie.setSecure(useSecureCookie);
|
|
cookie.setSecure(useSecureCookie);
|
|
}
|
|
}
|
|
|
|
|
|
- if (setHttpOnlyMethod != null) {
|
|
|
|
- ReflectionUtils.invokeMethod(setHttpOnlyMethod, cookie, Boolean.TRUE);
|
|
|
|
- }
|
|
|
|
- else if (logger.isDebugEnabled()) {
|
|
|
|
- logger.debug("Note: Cookie will not be marked as HttpOnly because you are not using Servlet 3.0 (Cookie#setHttpOnly(boolean) was not found).");
|
|
|
|
- }
|
|
|
|
|
|
+ cookie.setHttpOnly(true);
|
|
|
|
|
|
response.addCookie(cookie);
|
|
response.addCookie(cookie);
|
|
}
|
|
}
|