Always use 'this.' when accessing fields
Apply an Eclipse cleanup rules to ensure that fields are always accessed using `this.`. This aligns with the style used by Spring Framework and helps users quickly see the difference between a local and member variable. Issue gh-8945
This commit is contained in:
@@ -50,8 +50,8 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
|
||||
String redirectUrl = calculateRedirectUrl(request.getContextPath(), url);
|
||||
redirectUrl = response.encodeRedirectURL(redirectUrl);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Redirecting to '" + redirectUrl + "'");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Redirecting to '" + redirectUrl + "'");
|
||||
}
|
||||
|
||||
response.sendRedirect(redirectUrl);
|
||||
@@ -102,7 +102,7 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
|
||||
* protocol and context path (defaults to <tt>false</tt>).
|
||||
*/
|
||||
protected boolean isContextRelative() {
|
||||
return contextRelative;
|
||||
return this.contextRelative;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,20 +52,20 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
|
||||
}
|
||||
|
||||
public RequestMatcher getRequestMatcher() {
|
||||
return requestMatcher;
|
||||
return this.requestMatcher;
|
||||
}
|
||||
|
||||
public List<Filter> getFilters() {
|
||||
return filters;
|
||||
return this.filters;
|
||||
}
|
||||
|
||||
public boolean matches(HttpServletRequest request) {
|
||||
return requestMatcher.matches(request);
|
||||
return this.requestMatcher.matches(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[ " + requestMatcher + ", " + filters + "]";
|
||||
return "[ " + this.requestMatcher + ", " + this.filters + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
filterChainValidator.validate(this);
|
||||
this.filterChainValidator.validate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,8 +194,8 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
private void doFilterInternal(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
FirewalledRequest fwRequest = firewall.getFirewalledRequest((HttpServletRequest) request);
|
||||
HttpServletResponse fwResponse = firewall.getFirewalledResponse((HttpServletResponse) response);
|
||||
FirewalledRequest fwRequest = this.firewall.getFirewalledRequest((HttpServletRequest) request);
|
||||
HttpServletResponse fwResponse = this.firewall.getFirewalledResponse((HttpServletResponse) response);
|
||||
|
||||
List<Filter> filters = getFilters(fwRequest);
|
||||
|
||||
@@ -222,7 +222,7 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
* @return an ordered array of Filters defining the filter chain
|
||||
*/
|
||||
private List<Filter> getFilters(HttpServletRequest request) {
|
||||
for (SecurityFilterChain chain : filterChains) {
|
||||
for (SecurityFilterChain chain : this.filterChains) {
|
||||
if (chain.matches(request)) {
|
||||
return chain.getFilters();
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
* @return matching filter list
|
||||
*/
|
||||
public List<Filter> getFilters(String url) {
|
||||
return getFilters(firewall.getFirewalledRequest((new FilterInvocation(url, "GET").getRequest())));
|
||||
return getFilters(this.firewall.getFirewalledRequest((new FilterInvocation(url, "GET").getRequest())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +245,7 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
* applied to incoming requests.
|
||||
*/
|
||||
public List<SecurityFilterChain> getFilterChains() {
|
||||
return Collections.unmodifiableList(filterChains);
|
||||
return Collections.unmodifiableList(this.filterChains);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +284,7 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("FilterChainProxy[");
|
||||
sb.append("Filter Chains: ");
|
||||
sb.append(filterChains);
|
||||
sb.append(this.filterChains);
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
@@ -316,26 +316,27 @@ public class FilterChainProxy extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
if (currentPosition == size) {
|
||||
if (this.currentPosition == this.size) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(UrlUtils.buildRequestUrl(firewalledRequest)
|
||||
logger.debug(UrlUtils.buildRequestUrl(this.firewalledRequest)
|
||||
+ " reached end of additional filter chain; proceeding with original chain");
|
||||
}
|
||||
|
||||
// Deactivate path stripping as we exit the security filter chain
|
||||
this.firewalledRequest.reset();
|
||||
|
||||
originalChain.doFilter(request, response);
|
||||
this.originalChain.doFilter(request, response);
|
||||
}
|
||||
else {
|
||||
currentPosition++;
|
||||
this.currentPosition++;
|
||||
|
||||
Filter nextFilter = additionalFilters.get(currentPosition - 1);
|
||||
Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(UrlUtils.buildRequestUrl(firewalledRequest) + " at position " + currentPosition
|
||||
+ " of " + size + " in additional filter chain; firing Filter: '"
|
||||
+ nextFilter.getClass().getSimpleName() + "'");
|
||||
logger.debug(
|
||||
UrlUtils.buildRequestUrl(this.firewalledRequest) + " at position " + this.currentPosition
|
||||
+ " of " + this.size + " in additional filter chain; firing Filter: '"
|
||||
+ nextFilter.getClass().getSimpleName() + "'");
|
||||
}
|
||||
|
||||
nextFilter.doFilter(request, response, this);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PortResolverImpl implements PortResolver {
|
||||
private PortMapper portMapper = new PortMapperImpl();
|
||||
|
||||
public PortMapper getPortMapper() {
|
||||
return portMapper;
|
||||
return this.portMapper;
|
||||
}
|
||||
|
||||
public int getServerPort(ServletRequest request) {
|
||||
@@ -49,11 +49,11 @@ public class PortResolverImpl implements PortResolver {
|
||||
String scheme = request.getScheme().toLowerCase();
|
||||
|
||||
if ("http".equals(scheme)) {
|
||||
portLookup = portMapper.lookupHttpPort(serverPort);
|
||||
portLookup = this.portMapper.lookupHttpPort(serverPort);
|
||||
|
||||
}
|
||||
else if ("https".equals(scheme)) {
|
||||
portLookup = portMapper.lookupHttpsPort(serverPort);
|
||||
portLookup = this.portMapper.lookupHttpsPort(serverPort);
|
||||
}
|
||||
|
||||
if (portLookup != null) {
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response,
|
||||
AccessDeniedException accessDeniedException) throws IOException, ServletException {
|
||||
if (!response.isCommitted()) {
|
||||
if (errorPage != null) {
|
||||
if (this.errorPage != null) {
|
||||
// Put exception into request scope (perhaps of use to a view)
|
||||
request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
|
||||
response.setStatus(HttpStatus.FORBIDDEN.value());
|
||||
|
||||
// forward to error page.
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage);
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher(this.errorPage);
|
||||
dispatcher.forward(request, response);
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-3
@@ -82,10 +82,10 @@ public class DefaultWebInvocationPrivilegeEvaluator implements WebInvocationPriv
|
||||
Assert.notNull(uri, "uri parameter is required");
|
||||
|
||||
FilterInvocation fi = new FilterInvocation(contextPath, uri, method);
|
||||
Collection<ConfigAttribute> attrs = securityInterceptor.obtainSecurityMetadataSource().getAttributes(fi);
|
||||
Collection<ConfigAttribute> attrs = this.securityInterceptor.obtainSecurityMetadataSource().getAttributes(fi);
|
||||
|
||||
if (attrs == null) {
|
||||
if (securityInterceptor.isRejectPublicInvocations()) {
|
||||
if (this.securityInterceptor.isRejectPublicInvocations()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class DefaultWebInvocationPrivilegeEvaluator implements WebInvocationPriv
|
||||
}
|
||||
|
||||
try {
|
||||
securityInterceptor.getAccessDecisionManager().decide(authentication, fi, attrs);
|
||||
this.securityInterceptor.getAccessDecisionManager().decide(authentication, fi, attrs);
|
||||
}
|
||||
catch (AccessDeniedException unauthorized) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public final class DelegatingAccessDeniedHandler implements AccessDeniedHandler
|
||||
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response,
|
||||
AccessDeniedException accessDeniedException) throws IOException, ServletException {
|
||||
for (Entry<Class<? extends AccessDeniedException>, AccessDeniedHandler> entry : handlers.entrySet()) {
|
||||
for (Entry<Class<? extends AccessDeniedException>, AccessDeniedHandler> entry : this.handlers.entrySet()) {
|
||||
Class<? extends AccessDeniedException> handlerClass = entry.getKey();
|
||||
if (handlerClass.isAssignableFrom(accessDeniedException.getClass())) {
|
||||
AccessDeniedHandler handler = entry.getValue();
|
||||
@@ -68,7 +68,7 @@ public final class DelegatingAccessDeniedHandler implements AccessDeniedHandler
|
||||
return;
|
||||
}
|
||||
}
|
||||
defaultHandler.handle(request, response, accessDeniedException);
|
||||
this.defaultHandler.handle(request, response, accessDeniedException);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-19
@@ -102,7 +102,7 @@ public class ExceptionTranslationFilter extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint must be specified");
|
||||
Assert.notNull(this.authenticationEntryPoint, "authenticationEntryPoint must be specified");
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
|
||||
@@ -113,20 +113,20 @@ public class ExceptionTranslationFilter extends GenericFilterBean {
|
||||
try {
|
||||
chain.doFilter(request, response);
|
||||
|
||||
logger.debug("Chain processed normally");
|
||||
this.logger.debug("Chain processed normally");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Try to extract a SpringSecurityException from the stacktrace
|
||||
Throwable[] causeChain = throwableAnalyzer.determineCauseChain(ex);
|
||||
RuntimeException ase = (AuthenticationException) throwableAnalyzer
|
||||
Throwable[] causeChain = this.throwableAnalyzer.determineCauseChain(ex);
|
||||
RuntimeException ase = (AuthenticationException) this.throwableAnalyzer
|
||||
.getFirstThrowableOfType(AuthenticationException.class, causeChain);
|
||||
|
||||
if (ase == null) {
|
||||
ase = (AccessDeniedException) throwableAnalyzer.getFirstThrowableOfType(AccessDeniedException.class,
|
||||
causeChain);
|
||||
ase = (AccessDeniedException) this.throwableAnalyzer
|
||||
.getFirstThrowableOfType(AccessDeniedException.class, causeChain);
|
||||
}
|
||||
|
||||
if (ase != null) {
|
||||
@@ -154,37 +154,41 @@ public class ExceptionTranslationFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
public AuthenticationEntryPoint getAuthenticationEntryPoint() {
|
||||
return authenticationEntryPoint;
|
||||
return this.authenticationEntryPoint;
|
||||
}
|
||||
|
||||
protected AuthenticationTrustResolver getAuthenticationTrustResolver() {
|
||||
return authenticationTrustResolver;
|
||||
return this.authenticationTrustResolver;
|
||||
}
|
||||
|
||||
private void handleSpringSecurityException(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain chain, RuntimeException exception) throws IOException, ServletException {
|
||||
if (exception instanceof AuthenticationException) {
|
||||
logger.debug("Authentication exception occurred; redirecting to authentication entry point", exception);
|
||||
this.logger.debug("Authentication exception occurred; redirecting to authentication entry point",
|
||||
exception);
|
||||
|
||||
sendStartAuthentication(request, response, chain, (AuthenticationException) exception);
|
||||
}
|
||||
else if (exception instanceof AccessDeniedException) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authenticationTrustResolver.isAnonymous(authentication)
|
||||
|| authenticationTrustResolver.isRememberMe(authentication)) {
|
||||
logger.debug("Access is denied (user is " + (authenticationTrustResolver.isAnonymous(authentication)
|
||||
? "anonymous" : "not fully authenticated") + "); redirecting to authentication entry point",
|
||||
if (this.authenticationTrustResolver.isAnonymous(authentication)
|
||||
|| this.authenticationTrustResolver.isRememberMe(authentication)) {
|
||||
this.logger.debug(
|
||||
"Access is denied (user is " + (this.authenticationTrustResolver.isAnonymous(authentication)
|
||||
? "anonymous" : "not fully authenticated")
|
||||
+ "); redirecting to authentication entry point",
|
||||
exception);
|
||||
|
||||
sendStartAuthentication(request, response, chain,
|
||||
new InsufficientAuthenticationException(
|
||||
messages.getMessage("ExceptionTranslationFilter.insufficientAuthentication",
|
||||
this.messages.getMessage("ExceptionTranslationFilter.insufficientAuthentication",
|
||||
"Full authentication is required to access this resource")));
|
||||
}
|
||||
else {
|
||||
logger.debug("Access is denied (user is not anonymous); delegating to AccessDeniedHandler", exception);
|
||||
this.logger.debug("Access is denied (user is not anonymous); delegating to AccessDeniedHandler",
|
||||
exception);
|
||||
|
||||
accessDeniedHandler.handle(request, response, (AccessDeniedException) exception);
|
||||
this.accessDeniedHandler.handle(request, response, (AccessDeniedException) exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,9 +198,9 @@ public class ExceptionTranslationFilter extends GenericFilterBean {
|
||||
// SEC-112: Clear the SecurityContextHolder's Authentication, as the
|
||||
// existing Authentication is no longer considered valid
|
||||
SecurityContextHolder.getContext().setAuthentication(null);
|
||||
requestCache.saveRequest(request, response);
|
||||
logger.debug("Calling Authentication entry point.");
|
||||
authenticationEntryPoint.commence(request, response, reason);
|
||||
this.requestCache.saveRequest(request, response);
|
||||
this.logger.debug("Calling Authentication entry point.");
|
||||
this.authenticationEntryPoint.commence(request, response, reason);
|
||||
}
|
||||
|
||||
public void setAccessDeniedHandler(AccessDeniedHandler accessDeniedHandler) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public final class RequestMatcherDelegatingAccessDeniedHandler implements Access
|
||||
return;
|
||||
}
|
||||
}
|
||||
defaultHandler.handle(request, response, accessDeniedException);
|
||||
this.defaultHandler.handle(request, response, accessDeniedException);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-9
@@ -59,26 +59,27 @@ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint {
|
||||
String queryString = request.getQueryString();
|
||||
String redirectUrl = request.getRequestURI() + ((queryString == null) ? "" : ("?" + queryString));
|
||||
|
||||
Integer currentPort = portResolver.getServerPort(request);
|
||||
Integer currentPort = this.portResolver.getServerPort(request);
|
||||
Integer redirectPort = getMappedPort(currentPort);
|
||||
|
||||
if (redirectPort != null) {
|
||||
boolean includePort = redirectPort != standardPort;
|
||||
boolean includePort = redirectPort != this.standardPort;
|
||||
|
||||
redirectUrl = scheme + request.getServerName() + ((includePort) ? (":" + redirectPort) : "") + redirectUrl;
|
||||
redirectUrl = this.scheme + request.getServerName() + ((includePort) ? (":" + redirectPort) : "")
|
||||
+ redirectUrl;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Redirecting to: " + redirectUrl);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Redirecting to: " + redirectUrl);
|
||||
}
|
||||
|
||||
redirectStrategy.sendRedirect(request, response, redirectUrl);
|
||||
this.redirectStrategy.sendRedirect(request, response, redirectUrl);
|
||||
}
|
||||
|
||||
protected abstract Integer getMappedPort(Integer mapFromPort);
|
||||
|
||||
protected final PortMapper getPortMapper() {
|
||||
return portMapper;
|
||||
return this.portMapper;
|
||||
}
|
||||
|
||||
public void setPortMapper(PortMapper portMapper) {
|
||||
@@ -92,7 +93,7 @@ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint {
|
||||
}
|
||||
|
||||
protected final PortResolver getPortResolver() {
|
||||
return portResolver;
|
||||
return this.portResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +107,7 @@ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint {
|
||||
}
|
||||
|
||||
protected final RedirectStrategy getRedirectStrategy() {
|
||||
return redirectStrategy;
|
||||
return this.redirectStrategy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -52,7 +52,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, Initi
|
||||
private List<ChannelProcessor> channelProcessors;
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notEmpty(channelProcessors, "A list of ChannelProcessors is required");
|
||||
Assert.notEmpty(this.channelProcessors, "A list of ChannelProcessors is required");
|
||||
}
|
||||
|
||||
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config)
|
||||
@@ -63,7 +63,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, Initi
|
||||
}
|
||||
}
|
||||
|
||||
for (ChannelProcessor processor : channelProcessors) {
|
||||
for (ChannelProcessor processor : this.channelProcessors) {
|
||||
processor.decide(invocation, config);
|
||||
|
||||
if (invocation.getResponse().isCommitted()) {
|
||||
@@ -79,12 +79,12 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, Initi
|
||||
@SuppressWarnings("cast")
|
||||
public void setChannelProcessors(List<?> newList) {
|
||||
Assert.notEmpty(newList, "A list of ChannelProcessors is required");
|
||||
channelProcessors = new ArrayList<>(newList.size());
|
||||
this.channelProcessors = new ArrayList<>(newList.size());
|
||||
|
||||
for (Object currentObject : newList) {
|
||||
Assert.isInstanceOf(ChannelProcessor.class, currentObject, () -> "ChannelProcessor "
|
||||
+ currentObject.getClass().getName() + " must implement ChannelProcessor");
|
||||
channelProcessors.add((ChannelProcessor) currentObject);
|
||||
this.channelProcessors.add((ChannelProcessor) currentObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, Initi
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ChannelProcessor processor : channelProcessors) {
|
||||
for (ChannelProcessor processor : this.channelProcessors) {
|
||||
if (processor.supports(attribute)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+5
-5
@@ -47,8 +47,8 @@ public class InsecureChannelProcessor implements InitializingBean, ChannelProces
|
||||
private String insecureKeyword = "REQUIRES_INSECURE_CHANNEL";
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.hasLength(insecureKeyword, "insecureKeyword required");
|
||||
Assert.notNull(entryPoint, "entryPoint required");
|
||||
Assert.hasLength(this.insecureKeyword, "insecureKeyword required");
|
||||
Assert.notNull(this.entryPoint, "entryPoint required");
|
||||
}
|
||||
|
||||
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config)
|
||||
@@ -60,18 +60,18 @@ public class InsecureChannelProcessor implements InitializingBean, ChannelProces
|
||||
for (ConfigAttribute attribute : config) {
|
||||
if (supports(attribute)) {
|
||||
if (invocation.getHttpRequest().isSecure()) {
|
||||
entryPoint.commence(invocation.getRequest(), invocation.getResponse());
|
||||
this.entryPoint.commence(invocation.getRequest(), invocation.getResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelEntryPoint getEntryPoint() {
|
||||
return entryPoint;
|
||||
return this.entryPoint;
|
||||
}
|
||||
|
||||
public String getInsecureKeyword() {
|
||||
return insecureKeyword;
|
||||
return this.insecureKeyword;
|
||||
}
|
||||
|
||||
public void setEntryPoint(ChannelEntryPoint entryPoint) {
|
||||
|
||||
+5
-5
@@ -47,8 +47,8 @@ public class SecureChannelProcessor implements InitializingBean, ChannelProcesso
|
||||
private String secureKeyword = "REQUIRES_SECURE_CHANNEL";
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.hasLength(secureKeyword, "secureKeyword required");
|
||||
Assert.notNull(entryPoint, "entryPoint required");
|
||||
Assert.hasLength(this.secureKeyword, "secureKeyword required");
|
||||
Assert.notNull(this.entryPoint, "entryPoint required");
|
||||
}
|
||||
|
||||
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config)
|
||||
@@ -58,18 +58,18 @@ public class SecureChannelProcessor implements InitializingBean, ChannelProcesso
|
||||
for (ConfigAttribute attribute : config) {
|
||||
if (supports(attribute)) {
|
||||
if (!invocation.getHttpRequest().isSecure()) {
|
||||
entryPoint.commence(invocation.getRequest(), invocation.getResponse());
|
||||
this.entryPoint.commence(invocation.getRequest(), invocation.getResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelEntryPoint getEntryPoint() {
|
||||
return entryPoint;
|
||||
return this.entryPoint;
|
||||
}
|
||||
|
||||
public String getSecureKeyword() {
|
||||
return secureKeyword;
|
||||
return this.secureKeyword;
|
||||
}
|
||||
|
||||
public void setEntryPoint(ChannelEntryPoint entryPoint) {
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class DefaultWebSecurityExpressionHandler extends AbstractSecurityExpress
|
||||
FilterInvocation fi) {
|
||||
WebSecurityExpressionRoot root = new WebSecurityExpressionRoot(authentication, fi);
|
||||
root.setPermissionEvaluator(getPermissionEvaluator());
|
||||
root.setTrustResolver(trustResolver);
|
||||
root.setTrustResolver(this.trustResolver);
|
||||
root.setRoleHierarchy(getRoleHierarchy());
|
||||
root.setDefaultRolePrefix(this.defaultRolePrefix);
|
||||
return root;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class WebExpressionVoter implements AccessDecisionVoter<FilterInvocation>
|
||||
return ACCESS_ABSTAIN;
|
||||
}
|
||||
|
||||
EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication, fi);
|
||||
EvaluationContext ctx = this.expressionHandler.createEvaluationContext(authentication, fi);
|
||||
ctx = weca.postProcess(ctx, fi);
|
||||
|
||||
return ExpressionUtils.evaluateAsBoolean(weca.getAuthorizeExpression(), ctx) ? ACCESS_GRANTED : ACCESS_DENIED;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class WebSecurityExpressionRoot extends SecurityExpressionRoot {
|
||||
* @return true if the IP address of the current request is in the required range.
|
||||
*/
|
||||
public boolean hasIpAddress(String ipAddress) {
|
||||
return (new IpAddressMatcher(ipAddress).matches(request));
|
||||
return (new IpAddressMatcher(ipAddress).matches(this.request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ public class DefaultFilterInvocationSecurityMetadataSource implements FilterInvo
|
||||
public Collection<ConfigAttribute> getAllConfigAttributes() {
|
||||
Set<ConfigAttribute> allAttributes = new HashSet<>();
|
||||
|
||||
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : requestMap.entrySet()) {
|
||||
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : this.requestMap.entrySet()) {
|
||||
allAttributes.addAll(entry.getValue());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DefaultFilterInvocationSecurityMetadataSource implements FilterInvo
|
||||
|
||||
public Collection<ConfigAttribute> getAttributes(Object object) {
|
||||
final HttpServletRequest request = ((FilterInvocation) object).getRequest();
|
||||
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : requestMap.entrySet()) {
|
||||
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : this.requestMap.entrySet()) {
|
||||
if (entry.getKey().matches(request)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
+3
-3
@@ -97,14 +97,14 @@ public class FilterSecurityInterceptor extends AbstractSecurityInterceptor imple
|
||||
|
||||
public void invoke(FilterInvocation fi) throws IOException, ServletException {
|
||||
if ((fi.getRequest() != null) && (fi.getRequest().getAttribute(FILTER_APPLIED) != null)
|
||||
&& observeOncePerRequest) {
|
||||
&& this.observeOncePerRequest) {
|
||||
// filter already applied to this request and user wants us to observe
|
||||
// once-per-request handling, so don't re-do security checking
|
||||
fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
|
||||
}
|
||||
else {
|
||||
// first time this request being called, so perform security checking
|
||||
if (fi.getRequest() != null && observeOncePerRequest) {
|
||||
if (fi.getRequest() != null && this.observeOncePerRequest) {
|
||||
fi.getRequest().setAttribute(FILTER_APPLIED, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class FilterSecurityInterceptor extends AbstractSecurityInterceptor imple
|
||||
* authorizations for each and every fragment of the HTTP request.
|
||||
*/
|
||||
public boolean isObserveOncePerRequest() {
|
||||
return observeOncePerRequest;
|
||||
return this.observeOncePerRequest;
|
||||
}
|
||||
|
||||
public void setObserveOncePerRequest(boolean observeOncePerRequest) {
|
||||
|
||||
@@ -38,11 +38,11 @@ public class RequestKey {
|
||||
}
|
||||
|
||||
String getUrl() {
|
||||
return url;
|
||||
return this.url;
|
||||
}
|
||||
|
||||
String getMethod() {
|
||||
return method;
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,25 +60,25 @@ public class RequestKey {
|
||||
|
||||
RequestKey key = (RequestKey) obj;
|
||||
|
||||
if (!url.equals(key.url)) {
|
||||
if (!this.url.equals(key.url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (method == null) {
|
||||
if (this.method == null) {
|
||||
return key.method == null;
|
||||
}
|
||||
|
||||
return method.equals(key.method);
|
||||
return this.method.equals(key.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(url.length() + 7);
|
||||
StringBuilder sb = new StringBuilder(this.url.length() + 7);
|
||||
sb.append("[");
|
||||
if (method != null) {
|
||||
sb.append(method).append(",");
|
||||
if (this.method != null) {
|
||||
sb.append(this.method).append(",");
|
||||
}
|
||||
sb.append(url);
|
||||
sb.append(this.url);
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
|
||||
+23
-23
@@ -178,7 +178,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(authenticationManager, "authenticationManager must be specified");
|
||||
Assert.notNull(this.authenticationManager, "authenticationManager must be specified");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,8 +217,8 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Request is to process authentication");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Request is to process authentication");
|
||||
}
|
||||
|
||||
Authentication authResult;
|
||||
@@ -230,10 +230,10 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
// authentication
|
||||
return;
|
||||
}
|
||||
sessionStrategy.onAuthentication(authResult, request, response);
|
||||
this.sessionStrategy.onAuthentication(authResult, request, response);
|
||||
}
|
||||
catch (InternalAuthenticationServiceException failed) {
|
||||
logger.error("An internal error occurred while trying to authenticate the user.", failed);
|
||||
this.logger.error("An internal error occurred while trying to authenticate the user.", failed);
|
||||
unsuccessfulAuthentication(request, response, failed);
|
||||
|
||||
return;
|
||||
@@ -246,7 +246,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
}
|
||||
|
||||
// Authentication success
|
||||
if (continueChainBeforeSuccessfulAuthentication) {
|
||||
if (this.continueChainBeforeSuccessfulAuthentication) {
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) {
|
||||
return requiresAuthenticationRequestMatcher.matches(request);
|
||||
return this.requiresAuthenticationRequestMatcher.matches(request);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,20 +316,20 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
|
||||
Authentication authResult) throws IOException, ServletException {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication success. Updating SecurityContextHolder to contain: " + authResult);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Authentication success. Updating SecurityContextHolder to contain: " + authResult);
|
||||
}
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(authResult);
|
||||
|
||||
rememberMeServices.loginSuccess(request, response, authResult);
|
||||
this.rememberMeServices.loginSuccess(request, response, authResult);
|
||||
|
||||
// Fire event
|
||||
if (this.eventPublisher != null) {
|
||||
eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
|
||||
this.eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
|
||||
}
|
||||
|
||||
successHandler.onAuthenticationSuccess(request, response, authResult);
|
||||
this.successHandler.onAuthenticationSuccess(request, response, authResult);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,19 +347,19 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
AuthenticationException failed) throws IOException, ServletException {
|
||||
SecurityContextHolder.clearContext();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication request failed: " + failed.toString(), failed);
|
||||
logger.debug("Updated SecurityContextHolder to contain null Authentication");
|
||||
logger.debug("Delegating to authentication failure handler " + failureHandler);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Authentication request failed: " + failed.toString(), failed);
|
||||
this.logger.debug("Updated SecurityContextHolder to contain null Authentication");
|
||||
this.logger.debug("Delegating to authentication failure handler " + this.failureHandler);
|
||||
}
|
||||
|
||||
rememberMeServices.loginFail(request, response);
|
||||
this.rememberMeServices.loginFail(request, response);
|
||||
|
||||
failureHandler.onAuthenticationFailure(request, response, failed);
|
||||
this.failureHandler.onAuthenticationFailure(request, response, failed);
|
||||
}
|
||||
|
||||
protected AuthenticationManager getAuthenticationManager() {
|
||||
return authenticationManager;
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
|
||||
@@ -380,7 +380,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
}
|
||||
|
||||
public RememberMeServices getRememberMeServices() {
|
||||
return rememberMeServices;
|
||||
return this.rememberMeServices;
|
||||
}
|
||||
|
||||
public void setRememberMeServices(RememberMeServices rememberMeServices) {
|
||||
@@ -413,7 +413,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
}
|
||||
|
||||
protected boolean getAllowSessionCreation() {
|
||||
return allowSessionCreation;
|
||||
return this.allowSessionCreation;
|
||||
}
|
||||
|
||||
public void setAllowSessionCreation(boolean allowSessionCreation) {
|
||||
@@ -447,11 +447,11 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
}
|
||||
|
||||
protected AuthenticationSuccessHandler getSuccessHandler() {
|
||||
return successHandler;
|
||||
return this.successHandler;
|
||||
}
|
||||
|
||||
protected AuthenticationFailureHandler getFailureHandler() {
|
||||
return failureHandler;
|
||||
return this.failureHandler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-14
@@ -85,11 +85,11 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
String targetUrl = determineTargetUrl(request, response, authentication);
|
||||
|
||||
if (response.isCommitted()) {
|
||||
logger.debug("Response has already been committed. Unable to redirect to " + targetUrl);
|
||||
this.logger.debug("Response has already been committed. Unable to redirect to " + targetUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
redirectStrategy.sendRedirect(request, response, targetUrl);
|
||||
this.redirectStrategy.sendRedirect(request, response, targetUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,30 +107,30 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
*/
|
||||
protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (isAlwaysUseDefaultTargetUrl()) {
|
||||
return defaultTargetUrl;
|
||||
return this.defaultTargetUrl;
|
||||
}
|
||||
|
||||
// Check for the parameter and use that if available
|
||||
String targetUrl = null;
|
||||
|
||||
if (targetUrlParameter != null) {
|
||||
targetUrl = request.getParameter(targetUrlParameter);
|
||||
if (this.targetUrlParameter != null) {
|
||||
targetUrl = request.getParameter(this.targetUrlParameter);
|
||||
|
||||
if (StringUtils.hasText(targetUrl)) {
|
||||
logger.debug("Found targetUrlParameter in request: " + targetUrl);
|
||||
this.logger.debug("Found targetUrlParameter in request: " + targetUrl);
|
||||
|
||||
return targetUrl;
|
||||
}
|
||||
}
|
||||
|
||||
if (useReferer && !StringUtils.hasLength(targetUrl)) {
|
||||
if (this.useReferer && !StringUtils.hasLength(targetUrl)) {
|
||||
targetUrl = request.getHeader("Referer");
|
||||
logger.debug("Using Referer header: " + targetUrl);
|
||||
this.logger.debug("Using Referer header: " + targetUrl);
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(targetUrl)) {
|
||||
targetUrl = defaultTargetUrl;
|
||||
logger.debug("Using default Url: " + targetUrl);
|
||||
targetUrl = this.defaultTargetUrl;
|
||||
this.logger.debug("Using default Url: " + targetUrl);
|
||||
}
|
||||
|
||||
return targetUrl;
|
||||
@@ -143,7 +143,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
* @return the defaultTargetUrl property
|
||||
*/
|
||||
protected final String getDefaultTargetUrl() {
|
||||
return defaultTargetUrl;
|
||||
return this.defaultTargetUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
}
|
||||
|
||||
protected boolean isAlwaysUseDefaultTargetUrl() {
|
||||
return alwaysUseDefaultTargetUrl;
|
||||
return this.alwaysUseDefaultTargetUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
}
|
||||
|
||||
protected String getTargetUrlParameter() {
|
||||
return targetUrlParameter;
|
||||
return this.targetUrlParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||
}
|
||||
|
||||
protected RedirectStrategy getRedirectStrategy() {
|
||||
return redirectStrategy;
|
||||
return this.redirectStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+12
-11
@@ -77,9 +77,9 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.hasLength(key, "key must have length");
|
||||
Assert.notNull(principal, "Anonymous authentication principal must be set");
|
||||
Assert.notNull(authorities, "Anonymous authorities must be set");
|
||||
Assert.hasLength(this.key, "key must have length");
|
||||
Assert.notNull(this.principal, "Anonymous authentication principal must be set");
|
||||
Assert.notNull(this.authorities, "Anonymous authorities must be set");
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
|
||||
@@ -88,14 +88,14 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
|
||||
if (SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||
SecurityContextHolder.getContext().setAuthentication(createAuthentication((HttpServletRequest) req));
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Populated SecurityContextHolder with anonymous token: '"
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Populated SecurityContextHolder with anonymous token: '"
|
||||
+ SecurityContextHolder.getContext().getAuthentication() + "'");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContextHolder not populated with anonymous token, as it already contained: '"
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("SecurityContextHolder not populated with anonymous token, as it already contained: '"
|
||||
+ SecurityContextHolder.getContext().getAuthentication() + "'");
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,9 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
|
||||
}
|
||||
|
||||
protected Authentication createAuthentication(HttpServletRequest request) {
|
||||
AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(key, principal, authorities);
|
||||
auth.setDetails(authenticationDetailsSource.buildDetails(request));
|
||||
AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(this.key, this.principal,
|
||||
this.authorities);
|
||||
auth.setDetails(this.authenticationDetailsSource.buildDetails(request));
|
||||
|
||||
return auth;
|
||||
}
|
||||
@@ -117,11 +118,11 @@ public class AnonymousAuthenticationFilter extends GenericFilterBean implements
|
||||
}
|
||||
|
||||
public Object getPrincipal() {
|
||||
return principal;
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
public List<GrantedAuthority> getAuthorities() {
|
||||
return authorities;
|
||||
return this.authorities;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-11
@@ -74,26 +74,26 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException, ServletException {
|
||||
|
||||
for (RequestMatcher requestMatcher : entryPoints.keySet()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Trying to match using " + requestMatcher);
|
||||
for (RequestMatcher requestMatcher : this.entryPoints.keySet()) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Trying to match using " + requestMatcher);
|
||||
}
|
||||
if (requestMatcher.matches(request)) {
|
||||
AuthenticationEntryPoint entryPoint = entryPoints.get(requestMatcher);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Match found! Executing " + entryPoint);
|
||||
AuthenticationEntryPoint entryPoint = this.entryPoints.get(requestMatcher);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Match found! Executing " + entryPoint);
|
||||
}
|
||||
entryPoint.commence(request, response, authException);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No match found. Using default entry point " + defaultEntryPoint);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("No match found. Using default entry point " + this.defaultEntryPoint);
|
||||
}
|
||||
|
||||
// No EntryPoint matched, use defaultEntryPoint
|
||||
defaultEntryPoint.commence(request, response, authException);
|
||||
this.defaultEntryPoint.commence(request, response, authException);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,8 +104,8 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notEmpty(entryPoints, "entryPoints must be specified");
|
||||
Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified");
|
||||
Assert.notEmpty(this.entryPoints, "entryPoints must be specified");
|
||||
Assert.notNull(this.defaultEntryPoint, "defaultEntryPoint must be specified");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@ public class DelegatingAuthenticationFailureHandler implements AuthenticationFai
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException, ServletException {
|
||||
for (Map.Entry<Class<? extends AuthenticationException>, AuthenticationFailureHandler> entry : handlers
|
||||
for (Map.Entry<Class<? extends AuthenticationException>, AuthenticationFailureHandler> entry : this.handlers
|
||||
.entrySet()) {
|
||||
Class<? extends AuthenticationException> handlerMappedExceptionClass = entry.getKey();
|
||||
if (handlerMappedExceptionClass.isAssignableFrom(exception.getClass())) {
|
||||
@@ -76,7 +76,7 @@ public class DelegatingAuthenticationFailureHandler implements AuthenticationFai
|
||||
return;
|
||||
}
|
||||
}
|
||||
defaultHandler.onAuthenticationFailure(request, response, exception);
|
||||
this.defaultHandler.onAuthenticationFailure(request, response, exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ExceptionMappingAuthenticationFailureHandler extends SimpleUrlAuthe
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException, ServletException {
|
||||
String url = failureUrlMap.get(exception.getClass().getName());
|
||||
String url = this.failureUrlMap.get(exception.getClass().getName());
|
||||
|
||||
if (url != null) {
|
||||
getRedirectStrategy().sendRedirect(request, response, url);
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class ForwardAuthenticationFailureHandler implements AuthenticationFailur
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException, ServletException {
|
||||
request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
|
||||
request.getRequestDispatcher(forwardUrl).forward(request, response);
|
||||
request.getRequestDispatcher(this.forwardUrl).forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class ForwardAuthenticationSuccessHandler implements AuthenticationSucces
|
||||
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authentication) throws IOException, ServletException {
|
||||
request.getRequestDispatcher(forwardUrl).forward(request, response);
|
||||
request.getRequestDispatcher(this.forwardUrl).forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class HttpStatusEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) {
|
||||
response.setStatus(httpStatus.value());
|
||||
response.setStatus(this.httpStatus.value());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-17
@@ -90,13 +90,13 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.isTrue(StringUtils.hasText(loginFormUrl) && UrlUtils.isValidRedirectUrl(loginFormUrl),
|
||||
Assert.isTrue(StringUtils.hasText(this.loginFormUrl) && UrlUtils.isValidRedirectUrl(this.loginFormUrl),
|
||||
"loginFormUrl must be specified and must be a valid redirect URL");
|
||||
if (useForward && UrlUtils.isAbsoluteUrl(loginFormUrl)) {
|
||||
if (this.useForward && UrlUtils.isAbsoluteUrl(this.loginFormUrl)) {
|
||||
throw new IllegalArgumentException("useForward must be false if using an absolute loginFormURL");
|
||||
}
|
||||
Assert.notNull(portMapper, "portMapper must be specified");
|
||||
Assert.notNull(portResolver, "portResolver must be specified");
|
||||
Assert.notNull(this.portMapper, "portMapper must be specified");
|
||||
Assert.notNull(this.portResolver, "portResolver must be specified");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,9 +121,9 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
|
||||
String redirectUrl = null;
|
||||
|
||||
if (useForward) {
|
||||
if (this.useForward) {
|
||||
|
||||
if (forceHttps && "http".equals(request.getScheme())) {
|
||||
if (this.forceHttps && "http".equals(request.getScheme())) {
|
||||
// First redirect the current request to HTTPS.
|
||||
// When that request is received, the forward to the login page will be
|
||||
// used.
|
||||
@@ -151,7 +151,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
|
||||
}
|
||||
|
||||
redirectStrategy.sendRedirect(request, response, redirectUrl);
|
||||
this.redirectStrategy.sendRedirect(request, response, redirectUrl);
|
||||
}
|
||||
|
||||
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response,
|
||||
@@ -163,7 +163,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
return loginForm;
|
||||
}
|
||||
|
||||
int serverPort = portResolver.getServerPort(request);
|
||||
int serverPort = this.portResolver.getServerPort(request);
|
||||
String scheme = request.getScheme();
|
||||
|
||||
RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();
|
||||
@@ -174,8 +174,8 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
urlBuilder.setContextPath(request.getContextPath());
|
||||
urlBuilder.setPathInfo(loginForm);
|
||||
|
||||
if (forceHttps && "http".equals(scheme)) {
|
||||
Integer httpsPort = portMapper.lookupHttpsPort(serverPort);
|
||||
if (this.forceHttps && "http".equals(scheme)) {
|
||||
Integer httpsPort = this.portMapper.lookupHttpsPort(serverPort);
|
||||
|
||||
if (httpsPort != null) {
|
||||
// Overwrite scheme and port in the redirect URL
|
||||
@@ -196,8 +196,8 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
*/
|
||||
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) throws IOException, ServletException {
|
||||
|
||||
int serverPort = portResolver.getServerPort(request);
|
||||
Integer httpsPort = portMapper.lookupHttpsPort(serverPort);
|
||||
int serverPort = this.portResolver.getServerPort(request);
|
||||
Integer httpsPort = this.portMapper.lookupHttpsPort(serverPort);
|
||||
|
||||
if (httpsPort != null) {
|
||||
RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();
|
||||
@@ -230,11 +230,11 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
}
|
||||
|
||||
protected boolean isForceHttps() {
|
||||
return forceHttps;
|
||||
return this.forceHttps;
|
||||
}
|
||||
|
||||
public String getLoginFormUrl() {
|
||||
return loginFormUrl;
|
||||
return this.loginFormUrl;
|
||||
}
|
||||
|
||||
public void setPortMapper(PortMapper portMapper) {
|
||||
@@ -243,7 +243,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
}
|
||||
|
||||
protected PortMapper getPortMapper() {
|
||||
return portMapper;
|
||||
return this.portMapper;
|
||||
}
|
||||
|
||||
public void setPortResolver(PortResolver portResolver) {
|
||||
@@ -252,7 +252,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
}
|
||||
|
||||
protected PortResolver getPortResolver() {
|
||||
return portResolver;
|
||||
return this.portResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,7 +266,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
|
||||
}
|
||||
|
||||
protected boolean isUseForward() {
|
||||
return useForward;
|
||||
return this.useForward;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ public class SavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuth
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authentication) throws ServletException, IOException {
|
||||
SavedRequest savedRequest = requestCache.getRequest(request, response);
|
||||
SavedRequest savedRequest = this.requestCache.getRequest(request, response);
|
||||
|
||||
if (savedRequest == null) {
|
||||
super.onAuthenticationSuccess(request, response, authentication);
|
||||
@@ -82,7 +82,7 @@ public class SavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuth
|
||||
String targetUrlParameter = getTargetUrlParameter();
|
||||
if (isAlwaysUseDefaultTargetUrl()
|
||||
|| (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
|
||||
requestCache.removeRequest(request, response);
|
||||
this.requestCache.removeRequest(request, response);
|
||||
super.onAuthenticationSuccess(request, response, authentication);
|
||||
|
||||
return;
|
||||
@@ -92,7 +92,7 @@ public class SavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuth
|
||||
|
||||
// Use the DefaultSavedRequest URL
|
||||
String targetUrl = savedRequest.getRedirectUrl();
|
||||
logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
|
||||
this.logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
|
||||
getRedirectStrategy().sendRedirect(request, response, targetUrl);
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -75,22 +75,22 @@ public class SimpleUrlAuthenticationFailureHandler implements AuthenticationFail
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException, ServletException {
|
||||
|
||||
if (defaultFailureUrl == null) {
|
||||
logger.debug("No failure URL set, sending 401 Unauthorized error");
|
||||
if (this.defaultFailureUrl == null) {
|
||||
this.logger.debug("No failure URL set, sending 401 Unauthorized error");
|
||||
|
||||
response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
||||
}
|
||||
else {
|
||||
saveException(request, exception);
|
||||
|
||||
if (forwardToDestination) {
|
||||
logger.debug("Forwarding to " + defaultFailureUrl);
|
||||
if (this.forwardToDestination) {
|
||||
this.logger.debug("Forwarding to " + this.defaultFailureUrl);
|
||||
|
||||
request.getRequestDispatcher(defaultFailureUrl).forward(request, response);
|
||||
request.getRequestDispatcher(this.defaultFailureUrl).forward(request, response);
|
||||
}
|
||||
else {
|
||||
logger.debug("Redirecting to " + defaultFailureUrl);
|
||||
redirectStrategy.sendRedirect(request, response, defaultFailureUrl);
|
||||
this.logger.debug("Redirecting to " + this.defaultFailureUrl);
|
||||
this.redirectStrategy.sendRedirect(request, response, this.defaultFailureUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,13 +104,13 @@ public class SimpleUrlAuthenticationFailureHandler implements AuthenticationFail
|
||||
* Otherwise the exception will not be stored.
|
||||
*/
|
||||
protected final void saveException(HttpServletRequest request, AuthenticationException exception) {
|
||||
if (forwardToDestination) {
|
||||
if (this.forwardToDestination) {
|
||||
request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
|
||||
}
|
||||
else {
|
||||
HttpSession session = request.getSession(false);
|
||||
|
||||
if (session != null || allowSessionCreation) {
|
||||
if (session != null || this.allowSessionCreation) {
|
||||
request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class SimpleUrlAuthenticationFailureHandler implements AuthenticationFail
|
||||
}
|
||||
|
||||
protected boolean isUseForward() {
|
||||
return forwardToDestination;
|
||||
return this.forwardToDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,11 +146,11 @@ public class SimpleUrlAuthenticationFailureHandler implements AuthenticationFail
|
||||
}
|
||||
|
||||
protected RedirectStrategy getRedirectStrategy() {
|
||||
return redirectStrategy;
|
||||
return this.redirectStrategy;
|
||||
}
|
||||
|
||||
protected boolean isAllowSessionCreation() {
|
||||
return allowSessionCreation;
|
||||
return this.allowSessionCreation;
|
||||
}
|
||||
|
||||
public void setAllowSessionCreation(boolean allowSessionCreation) {
|
||||
|
||||
+6
-6
@@ -70,7 +70,7 @@ public class UsernamePasswordAuthenticationFilter extends AbstractAuthentication
|
||||
|
||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
|
||||
throws AuthenticationException {
|
||||
if (postOnly && !request.getMethod().equals("POST")) {
|
||||
if (this.postOnly && !request.getMethod().equals("POST")) {
|
||||
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class UsernamePasswordAuthenticationFilter extends AbstractAuthentication
|
||||
*/
|
||||
@Nullable
|
||||
protected String obtainPassword(HttpServletRequest request) {
|
||||
return request.getParameter(passwordParameter);
|
||||
return request.getParameter(this.passwordParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ public class UsernamePasswordAuthenticationFilter extends AbstractAuthentication
|
||||
*/
|
||||
@Nullable
|
||||
protected String obtainUsername(HttpServletRequest request) {
|
||||
return request.getParameter(usernameParameter);
|
||||
return request.getParameter(this.usernameParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ public class UsernamePasswordAuthenticationFilter extends AbstractAuthentication
|
||||
* set
|
||||
*/
|
||||
protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) {
|
||||
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
|
||||
authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,11 +170,11 @@ public class UsernamePasswordAuthenticationFilter extends AbstractAuthentication
|
||||
}
|
||||
|
||||
public final String getUsernameParameter() {
|
||||
return usernameParameter;
|
||||
return this.usernameParameter;
|
||||
}
|
||||
|
||||
public final String getPasswordParameter() {
|
||||
return passwordParameter;
|
||||
return this.passwordParameter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-10
@@ -64,30 +64,30 @@ public class WebAuthenticationDetails implements Serializable {
|
||||
if (obj instanceof WebAuthenticationDetails) {
|
||||
WebAuthenticationDetails rhs = (WebAuthenticationDetails) obj;
|
||||
|
||||
if ((remoteAddress == null) && (rhs.getRemoteAddress() != null)) {
|
||||
if ((this.remoteAddress == null) && (rhs.getRemoteAddress() != null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((remoteAddress != null) && (rhs.getRemoteAddress() == null)) {
|
||||
if ((this.remoteAddress != null) && (rhs.getRemoteAddress() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (remoteAddress != null) {
|
||||
if (!remoteAddress.equals(rhs.getRemoteAddress())) {
|
||||
if (this.remoteAddress != null) {
|
||||
if (!this.remoteAddress.equals(rhs.getRemoteAddress())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((sessionId == null) && (rhs.getSessionId() != null)) {
|
||||
if ((this.sessionId == null) && (rhs.getSessionId() != null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((sessionId != null) && (rhs.getSessionId() == null)) {
|
||||
if ((this.sessionId != null) && (rhs.getSessionId() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sessionId != null) {
|
||||
if (!sessionId.equals(rhs.getSessionId())) {
|
||||
if (this.sessionId != null) {
|
||||
if (!this.sessionId.equals(rhs.getSessionId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class WebAuthenticationDetails implements Serializable {
|
||||
* @return the address
|
||||
*/
|
||||
public String getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
return this.remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ public class WebAuthenticationDetails implements Serializable {
|
||||
* @return the session ID
|
||||
*/
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public final class CookieClearingLogoutHandler implements LogoutHandler {
|
||||
}
|
||||
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
cookiesToClear.forEach(f -> response.addCookie(f.apply(request)));
|
||||
this.cookiesToClear.forEach(f -> response.addCookie(f.apply(request)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -78,7 +78,7 @@ public class LogoutFilter extends GenericFilterBean {
|
||||
if (StringUtils.hasText(logoutSuccessUrl)) {
|
||||
urlLogoutSuccessHandler.setDefaultTargetUrl(logoutSuccessUrl);
|
||||
}
|
||||
logoutSuccessHandler = urlLogoutSuccessHandler;
|
||||
this.logoutSuccessHandler = urlLogoutSuccessHandler;
|
||||
setFilterProcessesUrl("/logout");
|
||||
}
|
||||
|
||||
@@ -90,13 +90,13 @@ public class LogoutFilter extends GenericFilterBean {
|
||||
if (requiresLogout(request, response)) {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Logging out user '" + auth + "' and transferring to logout destination");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Logging out user '" + auth + "' and transferring to logout destination");
|
||||
}
|
||||
|
||||
this.handler.logout(request, response, auth);
|
||||
|
||||
logoutSuccessHandler.onLogoutSuccess(request, response, auth);
|
||||
this.logoutSuccessHandler.onLogoutSuccess(request, response, auth);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class LogoutFilter extends GenericFilterBean {
|
||||
* @return <code>true</code> if logout should occur, <code>false</code> otherwise
|
||||
*/
|
||||
protected boolean requiresLogout(HttpServletRequest request, HttpServletResponse response) {
|
||||
return logoutRequestMatcher.matches(request);
|
||||
return this.logoutRequestMatcher.matches(request);
|
||||
}
|
||||
|
||||
public void setLogoutRequestMatcher(RequestMatcher logoutRequestMatcher) {
|
||||
|
||||
+2
-2
@@ -36,13 +36,13 @@ public final class LogoutSuccessEventPublishingLogoutHandler implements LogoutHa
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
if (eventPublisher == null) {
|
||||
if (this.eventPublisher == null) {
|
||||
return;
|
||||
}
|
||||
if (authentication == null) {
|
||||
return;
|
||||
}
|
||||
eventPublisher.publishEvent(new LogoutSuccessEvent(authentication));
|
||||
this.eventPublisher.publishEvent(new LogoutSuccessEvent(authentication));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -57,15 +57,15 @@ public class SecurityContextLogoutHandler implements LogoutHandler {
|
||||
*/
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
Assert.notNull(request, "HttpServletRequest required");
|
||||
if (invalidateHttpSession) {
|
||||
if (this.invalidateHttpSession) {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
logger.debug("Invalidating session: " + session.getId());
|
||||
this.logger.debug("Invalidating session: " + session.getId());
|
||||
session.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (clearAuthentication) {
|
||||
if (this.clearAuthentication) {
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
context.setAuthentication(null);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class SecurityContextLogoutHandler implements LogoutHandler {
|
||||
}
|
||||
|
||||
public boolean isInvalidateHttpSession() {
|
||||
return invalidateHttpSession;
|
||||
return this.invalidateHttpSession;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+31
-28
@@ -113,7 +113,7 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
// convert to RuntimeException for passivity on afterPropertiesSet signature
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Assert.notNull(authenticationManager, "An AuthenticationManager must be set");
|
||||
Assert.notNull(this.authenticationManager, "An AuthenticationManager must be set");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,11 +123,12 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Checking secure context token: " + SecurityContextHolder.getContext().getAuthentication());
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger
|
||||
.debug("Checking secure context token: " + SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
if (requiresAuthenticationRequestMatcher.matches((HttpServletRequest) request)) {
|
||||
if (this.requiresAuthenticationRequestMatcher.matches((HttpServletRequest) request)) {
|
||||
doAuthenticate((HttpServletRequest) request, (HttpServletResponse) response);
|
||||
}
|
||||
|
||||
@@ -164,8 +165,9 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
return false;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Pre-authenticated principal has changed to " + principal + " and will be reauthenticated");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger
|
||||
.debug("Pre-authenticated principal has changed to " + principal + " and will be reauthenticated");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -181,28 +183,28 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
Object credentials = getPreAuthenticatedCredentials(request);
|
||||
|
||||
if (principal == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No pre-authenticated principal found in request");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("No pre-authenticated principal found in request");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("preAuthenticatedPrincipal = " + principal + ", trying to authenticate");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("preAuthenticatedPrincipal = " + principal + ", trying to authenticate");
|
||||
}
|
||||
|
||||
try {
|
||||
PreAuthenticatedAuthenticationToken authRequest = new PreAuthenticatedAuthenticationToken(principal,
|
||||
credentials);
|
||||
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
|
||||
authResult = authenticationManager.authenticate(authRequest);
|
||||
authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
|
||||
authResult = this.authenticationManager.authenticate(authRequest);
|
||||
successfulAuthentication(request, response, authResult);
|
||||
}
|
||||
catch (AuthenticationException failed) {
|
||||
unsuccessfulAuthentication(request, response, failed);
|
||||
|
||||
if (!continueFilterChainOnUnsuccessfulAuthentication) {
|
||||
if (!this.continueFilterChainOnUnsuccessfulAuthentication) {
|
||||
throw failed;
|
||||
}
|
||||
}
|
||||
@@ -214,17 +216,17 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
*/
|
||||
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authResult) throws IOException, ServletException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication success: " + authResult);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Authentication success: " + authResult);
|
||||
}
|
||||
SecurityContextHolder.getContext().setAuthentication(authResult);
|
||||
// Fire event
|
||||
if (this.eventPublisher != null) {
|
||||
eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
|
||||
this.eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
|
||||
}
|
||||
|
||||
if (authenticationSuccessHandler != null) {
|
||||
authenticationSuccessHandler.onAuthenticationSuccess(request, response, authResult);
|
||||
if (this.authenticationSuccessHandler != null) {
|
||||
this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,13 +240,13 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
AuthenticationException failed) throws IOException, ServletException {
|
||||
SecurityContextHolder.clearContext();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Cleared security context due to exception", failed);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Cleared security context due to exception", failed);
|
||||
}
|
||||
request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, failed);
|
||||
|
||||
if (authenticationFailureHandler != null) {
|
||||
authenticationFailureHandler.onAuthenticationFailure(request, response, failed);
|
||||
if (this.authenticationFailureHandler != null) {
|
||||
this.authenticationFailureHandler.onAuthenticationFailure(request, response, failed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +267,7 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
}
|
||||
|
||||
protected AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
|
||||
return authenticationDetailsSource;
|
||||
return this.authenticationDetailsSource;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +286,7 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
* failed authentication.
|
||||
*/
|
||||
public void setContinueFilterChainOnUnsuccessfulAuthentication(boolean shouldContinue) {
|
||||
continueFilterChainOnUnsuccessfulAuthentication = shouldContinue;
|
||||
this.continueFilterChainOnUnsuccessfulAuthentication = shouldContinue;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +359,7 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!checkForPrincipalChanges) {
|
||||
if (!AbstractPreAuthenticatedProcessingFilter.this.checkForPrincipalChanges) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -365,15 +367,16 @@ public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFi
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.debug("Pre-authenticated principal has changed and will be reauthenticated");
|
||||
AbstractPreAuthenticatedProcessingFilter.this.logger
|
||||
.debug("Pre-authenticated principal has changed and will be reauthenticated");
|
||||
|
||||
if (invalidateSessionOnPrincipalChange) {
|
||||
if (AbstractPreAuthenticatedProcessingFilter.this.invalidateSessionOnPrincipalChange) {
|
||||
SecurityContextHolder.clearContext();
|
||||
|
||||
HttpSession session = request.getSession(false);
|
||||
|
||||
if (session != null) {
|
||||
logger.debug("Invalidating existing session");
|
||||
AbstractPreAuthenticatedProcessingFilter.this.logger.debug("Invalidating existing session");
|
||||
session.invalidate();
|
||||
request.getSession();
|
||||
}
|
||||
|
||||
+7
-7
@@ -61,7 +61,7 @@ public class PreAuthenticatedAuthenticationProvider implements AuthenticationPro
|
||||
* Check whether all required properties have been set.
|
||||
*/
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(preAuthenticatedUserDetailsService, "An AuthenticationUserDetailsService must be set");
|
||||
Assert.notNull(this.preAuthenticatedUserDetailsService, "An AuthenticationUserDetailsService must be set");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ public class PreAuthenticatedAuthenticationProvider implements AuthenticationPro
|
||||
if (authentication.getPrincipal() == null) {
|
||||
logger.debug("No pre-authenticated principal found in request.");
|
||||
|
||||
if (throwExceptionWhenTokenRejected) {
|
||||
if (this.throwExceptionWhenTokenRejected) {
|
||||
throw new BadCredentialsException("No pre-authenticated principal found in request.");
|
||||
}
|
||||
return null;
|
||||
@@ -91,16 +91,16 @@ public class PreAuthenticatedAuthenticationProvider implements AuthenticationPro
|
||||
if (authentication.getCredentials() == null) {
|
||||
logger.debug("No pre-authenticated credentials found in request.");
|
||||
|
||||
if (throwExceptionWhenTokenRejected) {
|
||||
if (this.throwExceptionWhenTokenRejected) {
|
||||
throw new BadCredentialsException("No pre-authenticated credentials found in request.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
UserDetails ud = preAuthenticatedUserDetailsService
|
||||
UserDetails ud = this.preAuthenticatedUserDetailsService
|
||||
.loadUserDetails((PreAuthenticatedAuthenticationToken) authentication);
|
||||
|
||||
userDetailsChecker.check(ud);
|
||||
this.userDetailsChecker.check(ud);
|
||||
|
||||
PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(ud,
|
||||
authentication.getCredentials(), ud.getAuthorities());
|
||||
@@ -147,11 +147,11 @@ public class PreAuthenticatedAuthenticationProvider implements AuthenticationPro
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public void setOrder(int i) {
|
||||
order = i;
|
||||
this.order = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,14 +53,14 @@ public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails extends
|
||||
|
||||
@Override
|
||||
public List<GrantedAuthority> getGrantedAuthorities() {
|
||||
return authorities;
|
||||
return this.authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.toString()).append("; ");
|
||||
sb.append(authorities);
|
||||
sb.append(this.authorities);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -56,11 +56,11 @@ public class RequestAttributeAuthenticationFilter extends AbstractPreAuthenticat
|
||||
* missing and {@code exceptionIfVariableMissing} is set to {@code true}.
|
||||
*/
|
||||
protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
|
||||
String principal = (String) request.getAttribute(principalEnvironmentVariable);
|
||||
String principal = (String) request.getAttribute(this.principalEnvironmentVariable);
|
||||
|
||||
if (principal == null && exceptionIfVariableMissing) {
|
||||
if (principal == null && this.exceptionIfVariableMissing) {
|
||||
throw new PreAuthenticatedCredentialsNotFoundException(
|
||||
principalEnvironmentVariable + " variable not found in request.");
|
||||
this.principalEnvironmentVariable + " variable not found in request.");
|
||||
}
|
||||
|
||||
return principal;
|
||||
@@ -72,8 +72,8 @@ public class RequestAttributeAuthenticationFilter extends AbstractPreAuthenticat
|
||||
* credentials value. Otherwise a dummy value will be used.
|
||||
*/
|
||||
protected Object getPreAuthenticatedCredentials(HttpServletRequest request) {
|
||||
if (credentialsEnvironmentVariable != null) {
|
||||
return request.getAttribute(credentialsEnvironmentVariable);
|
||||
if (this.credentialsEnvironmentVariable != null) {
|
||||
return request.getAttribute(this.credentialsEnvironmentVariable);
|
||||
}
|
||||
|
||||
return "N/A";
|
||||
|
||||
+5
-5
@@ -57,11 +57,11 @@ public class RequestHeaderAuthenticationFilter extends AbstractPreAuthenticatedP
|
||||
* {@code exceptionIfHeaderMissing} is set to {@code true}.
|
||||
*/
|
||||
protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
|
||||
String principal = request.getHeader(principalRequestHeader);
|
||||
String principal = request.getHeader(this.principalRequestHeader);
|
||||
|
||||
if (principal == null && exceptionIfHeaderMissing) {
|
||||
if (principal == null && this.exceptionIfHeaderMissing) {
|
||||
throw new PreAuthenticatedCredentialsNotFoundException(
|
||||
principalRequestHeader + " header not found in request.");
|
||||
this.principalRequestHeader + " header not found in request.");
|
||||
}
|
||||
|
||||
return principal;
|
||||
@@ -73,8 +73,8 @@ public class RequestHeaderAuthenticationFilter extends AbstractPreAuthenticatedP
|
||||
* will be used.
|
||||
*/
|
||||
protected Object getPreAuthenticatedCredentials(HttpServletRequest request) {
|
||||
if (credentialsRequestHeader != null) {
|
||||
return request.getHeader(credentialsRequestHeader);
|
||||
if (this.credentialsRequestHeader != null) {
|
||||
return request.getHeader(this.credentialsRequestHeader);
|
||||
}
|
||||
|
||||
return "N/A";
|
||||
|
||||
+7
-7
@@ -59,8 +59,8 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
* Check that all required properties have been set.
|
||||
*/
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(j2eeMappableRoles, "No mappable roles available");
|
||||
Assert.notNull(j2eeUserRoles2GrantedAuthoritiesMapper, "Roles to granted authorities mapper not set");
|
||||
Assert.notNull(this.j2eeMappableRoles, "No mappable roles available");
|
||||
Assert.notNull(this.j2eeUserRoles2GrantedAuthoritiesMapper, "Roles to granted authorities mapper not set");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
protected Collection<String> getUserRoles(HttpServletRequest request) {
|
||||
ArrayList<String> j2eeUserRolesList = new ArrayList<>();
|
||||
|
||||
for (String role : j2eeMappableRoles) {
|
||||
for (String role : this.j2eeMappableRoles) {
|
||||
if (request.isUserInRole(role)) {
|
||||
j2eeUserRolesList.add(role);
|
||||
}
|
||||
@@ -92,11 +92,11 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
public PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails buildDetails(HttpServletRequest context) {
|
||||
|
||||
Collection<String> j2eeUserRoles = getUserRoles(context);
|
||||
Collection<? extends GrantedAuthority> userGas = j2eeUserRoles2GrantedAuthoritiesMapper
|
||||
Collection<? extends GrantedAuthority> userGas = this.j2eeUserRoles2GrantedAuthoritiesMapper
|
||||
.getGrantedAuthorities(j2eeUserRoles);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("J2EE roles [" + j2eeUserRoles + "] mapped to Granted Authorities: [" + userGas + "]");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("J2EE roles [" + j2eeUserRoles + "] mapped to Granted Authorities: [" + userGas + "]");
|
||||
}
|
||||
|
||||
PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails result = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(
|
||||
@@ -116,7 +116,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
* @param mapper The Attributes2GrantedAuthoritiesMapper to use
|
||||
*/
|
||||
public void setUserRoles2GrantedAuthoritiesMapper(Attributes2GrantedAuthoritiesMapper mapper) {
|
||||
j2eeUserRoles2GrantedAuthoritiesMapper = mapper;
|
||||
this.j2eeUserRoles2GrantedAuthoritiesMapper = mapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ public class J2eePreAuthenticatedProcessingFilter extends AbstractPreAuthenticat
|
||||
*/
|
||||
protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) {
|
||||
Object principal = httpRequest.getUserPrincipal() == null ? null : httpRequest.getUserPrincipal().getName();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("PreAuthenticated J2EE principal: " + principal);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("PreAuthenticated J2EE principal: " + principal);
|
||||
}
|
||||
return principal;
|
||||
}
|
||||
|
||||
+6
-6
@@ -66,7 +66,7 @@ public class WebXmlMappableAttributesRetriever
|
||||
}
|
||||
|
||||
public Set<String> getMappableAttributes() {
|
||||
return mappableAttributes;
|
||||
return this.mappableAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ public class WebXmlMappableAttributesRetriever
|
||||
*/
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Resource webXml = resourceLoader.getResource("/WEB-INF/web.xml");
|
||||
Resource webXml = this.resourceLoader.getResource("/WEB-INF/web.xml");
|
||||
Document doc = getDocument(webXml.getInputStream());
|
||||
NodeList webApp = doc.getElementsByTagName("web-app");
|
||||
if (webApp.getLength() != 1) {
|
||||
@@ -92,14 +92,14 @@ public class WebXmlMappableAttributesRetriever
|
||||
if (roles.getLength() > 0) {
|
||||
String roleName = roles.item(0).getTextContent().trim();
|
||||
roleNames.add(roleName);
|
||||
logger.info("Retrieved role-name '" + roleName + "' from web.xml");
|
||||
this.logger.info("Retrieved role-name '" + roleName + "' from web.xml");
|
||||
}
|
||||
else {
|
||||
logger.info("No security-role elements found in " + webXml);
|
||||
this.logger.info("No security-role elements found in " + webXml);
|
||||
}
|
||||
}
|
||||
|
||||
mappableAttributes = Collections.unmodifiableSet(new HashSet<>(roleNames));
|
||||
this.mappableAttributes = Collections.unmodifiableSet(new HashSet<>(roleNames));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ public class WebXmlMappableAttributesRetriever
|
||||
aStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.warn("Failed to close input stream for web.xml", e);
|
||||
this.logger.warn("Failed to close input stream for web.xml", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -48,9 +48,9 @@ public class WebSpherePreAuthenticatedProcessingFilter extends AbstractPreAuthen
|
||||
* Return the WebSphere user name.
|
||||
*/
|
||||
protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) {
|
||||
Object principal = wasHelper.getCurrentUserName();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("PreAuthenticated WebSphere principal: " + principal);
|
||||
Object principal = this.wasHelper.getCurrentUserName();
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("PreAuthenticated WebSphere principal: " + principal);
|
||||
}
|
||||
return principal;
|
||||
}
|
||||
|
||||
+5
-5
@@ -63,11 +63,11 @@ public class WebSpherePreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
* @return authorities mapped from the user's WebSphere groups.
|
||||
*/
|
||||
private Collection<? extends GrantedAuthority> getWebSphereGroupsBasedGrantedAuthorities() {
|
||||
List<String> webSphereGroups = wasHelper.getGroupsForCurrentUser();
|
||||
Collection<? extends GrantedAuthority> userGas = webSphereGroups2GrantedAuthoritiesMapper
|
||||
List<String> webSphereGroups = this.wasHelper.getGroupsForCurrentUser();
|
||||
Collection<? extends GrantedAuthority> userGas = this.webSphereGroups2GrantedAuthoritiesMapper
|
||||
.getGrantedAuthorities(webSphereGroups);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("WebSphere groups: " + webSphereGroups + " mapped to Granted Authorities: " + userGas);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("WebSphere groups: " + webSphereGroups + " mapped to Granted Authorities: " + userGas);
|
||||
}
|
||||
return userGas;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class WebSpherePreAuthenticatedWebAuthenticationDetailsSource implements
|
||||
* groups to authorities
|
||||
*/
|
||||
public void setWebSphereGroups2GrantedAuthoritiesMapper(Attributes2GrantedAuthoritiesMapper mapper) {
|
||||
webSphereGroups2GrantedAuthoritiesMapper = mapper;
|
||||
this.webSphereGroups2GrantedAuthoritiesMapper = mapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -57,12 +57,12 @@ public class SubjectDnX509PrincipalExtractor implements X509PrincipalExtractor {
|
||||
// String subjectDN = clientCert.getSubjectX500Principal().getName();
|
||||
String subjectDN = clientCert.getSubjectDN().getName();
|
||||
|
||||
logger.debug("Subject DN is '" + subjectDN + "'");
|
||||
this.logger.debug("Subject DN is '" + subjectDN + "'");
|
||||
|
||||
Matcher matcher = subjectDnPattern.matcher(subjectDN);
|
||||
Matcher matcher = this.subjectDnPattern.matcher(subjectDN);
|
||||
|
||||
if (!matcher.find()) {
|
||||
throw new BadCredentialsException(messages.getMessage("SubjectDnX509PrincipalExtractor.noMatching",
|
||||
throw new BadCredentialsException(this.messages.getMessage("SubjectDnX509PrincipalExtractor.noMatching",
|
||||
new Object[] { subjectDN }, "No matching pattern was found in subject DN: {0}"));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SubjectDnX509PrincipalExtractor implements X509PrincipalExtractor {
|
||||
|
||||
String username = matcher.group(1);
|
||||
|
||||
logger.debug("Extracted Principal name is '" + username + "'");
|
||||
this.logger.debug("Extracted Principal name is '" + username + "'");
|
||||
|
||||
return username;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class SubjectDnX509PrincipalExtractor implements X509PrincipalExtractor {
|
||||
*/
|
||||
public void setSubjectDnRegex(String subjectDnRegex) {
|
||||
Assert.hasText(subjectDnRegex, "Regular expression may not be null or empty");
|
||||
subjectDnPattern = Pattern.compile(subjectDnRegex, Pattern.CASE_INSENSITIVE);
|
||||
this.subjectDnPattern = Pattern.compile(subjectDnRegex, Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
public void setMessageSource(MessageSource messageSource) {
|
||||
|
||||
+5
-5
@@ -35,7 +35,7 @@ public class X509AuthenticationFilter extends AbstractPreAuthenticatedProcessing
|
||||
return null;
|
||||
}
|
||||
|
||||
return principalExtractor.extractPrincipal(cert);
|
||||
return this.principalExtractor.extractPrincipal(cert);
|
||||
}
|
||||
|
||||
protected Object getPreAuthenticatedCredentials(HttpServletRequest request) {
|
||||
@@ -46,15 +46,15 @@ public class X509AuthenticationFilter extends AbstractPreAuthenticatedProcessing
|
||||
X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");
|
||||
|
||||
if (certs != null && certs.length > 0) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("X.509 client authentication certificate:" + certs[0]);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("X.509 client authentication certificate:" + certs[0]);
|
||||
}
|
||||
|
||||
return certs[0];
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No client certificate found in request.");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("No client certificate found in request.");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+41
-41
@@ -102,8 +102,8 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.hasLength(key, "key cannot be empty or null");
|
||||
Assert.notNull(userDetailsService, "A UserDetailsService is required");
|
||||
Assert.hasLength(this.key, "key cannot be empty or null");
|
||||
Assert.notNull(this.userDetailsService, "A UserDetailsService is required");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,10 +122,10 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.debug("Remember-me cookie detected");
|
||||
this.logger.debug("Remember-me cookie detected");
|
||||
|
||||
if (rememberMeCookie.length() == 0) {
|
||||
logger.debug("Cookie was empty");
|
||||
this.logger.debug("Cookie was empty");
|
||||
cancelCookie(request, response);
|
||||
return null;
|
||||
}
|
||||
@@ -135,9 +135,9 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
try {
|
||||
String[] cookieTokens = decodeCookie(rememberMeCookie);
|
||||
user = processAutoLoginCookie(cookieTokens, request, response);
|
||||
userDetailsChecker.check(user);
|
||||
this.userDetailsChecker.check(user);
|
||||
|
||||
logger.debug("Remember-me cookie accepted");
|
||||
this.logger.debug("Remember-me cookie accepted");
|
||||
|
||||
return createSuccessfulAuthentication(request, user);
|
||||
}
|
||||
@@ -146,16 +146,16 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
throw cte;
|
||||
}
|
||||
catch (UsernameNotFoundException noUser) {
|
||||
logger.debug("Remember-me login was valid but corresponding user not found.", noUser);
|
||||
this.logger.debug("Remember-me login was valid but corresponding user not found.", noUser);
|
||||
}
|
||||
catch (InvalidCookieException invalidCookie) {
|
||||
logger.debug("Invalid remember-me cookie: " + invalidCookie.getMessage());
|
||||
this.logger.debug("Invalid remember-me cookie: " + invalidCookie.getMessage());
|
||||
}
|
||||
catch (AccountStatusException statusInvalid) {
|
||||
logger.debug("Invalid UserDetails: " + statusInvalid.getMessage());
|
||||
this.logger.debug("Invalid UserDetails: " + statusInvalid.getMessage());
|
||||
}
|
||||
catch (RememberMeAuthenticationException e) {
|
||||
logger.debug(e.getMessage());
|
||||
this.logger.debug(e.getMessage());
|
||||
}
|
||||
|
||||
cancelCookie(request, response);
|
||||
@@ -177,7 +177,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
|
||||
for (Cookie cookie : cookies) {
|
||||
if (cookieName.equals(cookie.getName())) {
|
||||
if (this.cookieName.equals(cookie.getName())) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
@@ -198,9 +198,9 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
* @return the <tt>Authentication</tt> for the remember-me authenticated user
|
||||
*/
|
||||
protected Authentication createSuccessfulAuthentication(HttpServletRequest request, UserDetails user) {
|
||||
RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(key, user,
|
||||
authoritiesMapper.mapAuthorities(user.getAuthorities()));
|
||||
auth.setDetails(authenticationDetailsSource.buildDetails(request));
|
||||
RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(this.key, user,
|
||||
this.authoritiesMapper.mapAuthorities(user.getAuthorities()));
|
||||
auth.setDetails(this.authenticationDetailsSource.buildDetails(request));
|
||||
return auth;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
tokens[i] = URLDecoder.decode(tokens[i], StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
this.logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
sb.append(URLEncoder.encode(cookieTokens[i], StandardCharsets.UTF_8.toString()));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
this.logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (i < cookieTokens.length - 1) {
|
||||
@@ -272,7 +272,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
|
||||
@Override
|
||||
public final void loginFail(HttpServletRequest request, HttpServletResponse response) {
|
||||
logger.debug("Interactive login attempt was unsuccessful.");
|
||||
this.logger.debug("Interactive login attempt was unsuccessful.");
|
||||
cancelCookie(request, response);
|
||||
onLoginFail(request, response);
|
||||
}
|
||||
@@ -293,8 +293,8 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
public final void loginSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication successfulAuthentication) {
|
||||
|
||||
if (!rememberMeRequested(request, parameter)) {
|
||||
logger.debug("Remember-me login not requested.");
|
||||
if (!rememberMeRequested(request, this.parameter)) {
|
||||
this.logger.debug("Remember-me login not requested.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
* has been requested.
|
||||
*/
|
||||
protected boolean rememberMeRequested(HttpServletRequest request, String parameter) {
|
||||
if (alwaysRemember) {
|
||||
if (this.alwaysRemember) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -333,8 +333,8 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Did not send remember-me cookie (principal did not set parameter '" + parameter + "')");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Did not send remember-me cookie (principal did not set parameter '" + parameter + "')");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -362,18 +362,18 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
* logins.
|
||||
*/
|
||||
protected void cancelCookie(HttpServletRequest request, HttpServletResponse response) {
|
||||
logger.debug("Cancelling cookie");
|
||||
Cookie cookie = new Cookie(cookieName, null);
|
||||
this.logger.debug("Cancelling cookie");
|
||||
Cookie cookie = new Cookie(this.cookieName, null);
|
||||
cookie.setMaxAge(0);
|
||||
cookie.setPath(getCookiePath(request));
|
||||
if (cookieDomain != null) {
|
||||
cookie.setDomain(cookieDomain);
|
||||
if (this.cookieDomain != null) {
|
||||
cookie.setDomain(this.cookieDomain);
|
||||
}
|
||||
if (useSecureCookie == null) {
|
||||
if (this.useSecureCookie == null) {
|
||||
cookie.setSecure(request.isSecure());
|
||||
}
|
||||
else {
|
||||
cookie.setSecure(useSecureCookie);
|
||||
cookie.setSecure(this.useSecureCookie);
|
||||
}
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
@@ -392,21 +392,21 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
*/
|
||||
protected void setCookie(String[] tokens, int maxAge, HttpServletRequest request, HttpServletResponse response) {
|
||||
String cookieValue = encodeCookie(tokens);
|
||||
Cookie cookie = new Cookie(cookieName, cookieValue);
|
||||
Cookie cookie = new Cookie(this.cookieName, cookieValue);
|
||||
cookie.setMaxAge(maxAge);
|
||||
cookie.setPath(getCookiePath(request));
|
||||
if (cookieDomain != null) {
|
||||
cookie.setDomain(cookieDomain);
|
||||
if (this.cookieDomain != null) {
|
||||
cookie.setDomain(this.cookieDomain);
|
||||
}
|
||||
if (maxAge < 1) {
|
||||
cookie.setVersion(1);
|
||||
}
|
||||
|
||||
if (useSecureCookie == null) {
|
||||
if (this.useSecureCookie == null) {
|
||||
cookie.setSecure(request.isSecure());
|
||||
}
|
||||
else {
|
||||
cookie.setSecure(useSecureCookie);
|
||||
cookie.setSecure(this.useSecureCookie);
|
||||
}
|
||||
|
||||
cookie.setHttpOnly(true);
|
||||
@@ -425,8 +425,8 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
*/
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName()));
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName()));
|
||||
}
|
||||
cancelCookie(request, response);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
|
||||
protected String getCookieName() {
|
||||
return cookieName;
|
||||
return this.cookieName;
|
||||
}
|
||||
|
||||
public void setAlwaysRemember(boolean alwaysRemember) {
|
||||
@@ -461,15 +461,15 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
protected UserDetailsService getUserDetailsService() {
|
||||
return userDetailsService;
|
||||
return this.userDetailsService;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setTokenValiditySeconds(int tokenValiditySeconds) {
|
||||
@@ -477,7 +477,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
|
||||
protected int getTokenValiditySeconds() {
|
||||
return tokenValiditySeconds;
|
||||
return this.tokenValiditySeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +496,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
|
||||
}
|
||||
|
||||
protected AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
|
||||
return authenticationDetailsSource;
|
||||
return this.authenticationDetailsSource;
|
||||
}
|
||||
|
||||
public void setAuthenticationDetailsSource(
|
||||
|
||||
+6
-6
@@ -33,13 +33,13 @@ public class InMemoryTokenRepositoryImpl implements PersistentTokenRepository {
|
||||
private final Map<String, PersistentRememberMeToken> seriesTokens = new HashMap<>();
|
||||
|
||||
public synchronized void createNewToken(PersistentRememberMeToken token) {
|
||||
PersistentRememberMeToken current = seriesTokens.get(token.getSeries());
|
||||
PersistentRememberMeToken current = this.seriesTokens.get(token.getSeries());
|
||||
|
||||
if (current != null) {
|
||||
throw new DataIntegrityViolationException("Series Id '" + token.getSeries() + "' already exists!");
|
||||
}
|
||||
|
||||
seriesTokens.put(token.getSeries(), token);
|
||||
this.seriesTokens.put(token.getSeries(), token);
|
||||
}
|
||||
|
||||
public synchronized void updateToken(String series, String tokenValue, Date lastUsed) {
|
||||
@@ -49,20 +49,20 @@ public class InMemoryTokenRepositoryImpl implements PersistentTokenRepository {
|
||||
new Date());
|
||||
|
||||
// Store it, overwriting the existing one.
|
||||
seriesTokens.put(series, newToken);
|
||||
this.seriesTokens.put(series, newToken);
|
||||
}
|
||||
|
||||
public synchronized PersistentRememberMeToken getTokenForSeries(String seriesId) {
|
||||
return seriesTokens.get(seriesId);
|
||||
return this.seriesTokens.get(seriesId);
|
||||
}
|
||||
|
||||
public synchronized void removeUserTokens(String username) {
|
||||
Iterator<String> series = seriesTokens.keySet().iterator();
|
||||
Iterator<String> series = this.seriesTokens.keySet().iterator();
|
||||
|
||||
while (series.hasNext()) {
|
||||
String seriesId = series.next();
|
||||
|
||||
PersistentRememberMeToken token = seriesTokens.get(seriesId);
|
||||
PersistentRememberMeToken token = this.seriesTokens.get(seriesId);
|
||||
|
||||
if (username.equals(token.getUsername())) {
|
||||
series.remove();
|
||||
|
||||
+9
-9
@@ -57,18 +57,18 @@ public class JdbcTokenRepositoryImpl extends JdbcDaoSupport implements Persisten
|
||||
private boolean createTableOnStartup;
|
||||
|
||||
protected void initDao() {
|
||||
if (createTableOnStartup) {
|
||||
if (this.createTableOnStartup) {
|
||||
getJdbcTemplate().execute(CREATE_TABLE_SQL);
|
||||
}
|
||||
}
|
||||
|
||||
public void createNewToken(PersistentRememberMeToken token) {
|
||||
getJdbcTemplate().update(insertTokenSql, token.getUsername(), token.getSeries(), token.getTokenValue(),
|
||||
getJdbcTemplate().update(this.insertTokenSql, token.getUsername(), token.getSeries(), token.getTokenValue(),
|
||||
token.getDate());
|
||||
}
|
||||
|
||||
public void updateToken(String series, String tokenValue, Date lastUsed) {
|
||||
getJdbcTemplate().update(updateTokenSql, tokenValue, lastUsed, series);
|
||||
getJdbcTemplate().update(this.updateTokenSql, tokenValue, lastUsed, series);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,29 +82,29 @@ public class JdbcTokenRepositoryImpl extends JdbcDaoSupport implements Persisten
|
||||
*/
|
||||
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
|
||||
try {
|
||||
return getJdbcTemplate().queryForObject(tokensBySeriesSql,
|
||||
return getJdbcTemplate().queryForObject(this.tokensBySeriesSql,
|
||||
(rs, rowNum) -> new PersistentRememberMeToken(rs.getString(1), rs.getString(2), rs.getString(3),
|
||||
rs.getTimestamp(4)),
|
||||
seriesId);
|
||||
}
|
||||
catch (EmptyResultDataAccessException zeroResults) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Querying token for series '" + seriesId + "' returned no results.", zeroResults);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Querying token for series '" + seriesId + "' returned no results.", zeroResults);
|
||||
}
|
||||
}
|
||||
catch (IncorrectResultSizeDataAccessException moreThanOne) {
|
||||
logger.error("Querying token for series '" + seriesId + "' returned more than one value. Series"
|
||||
this.logger.error("Querying token for series '" + seriesId + "' returned more than one value. Series"
|
||||
+ " should be unique");
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
logger.error("Failed to load token for series " + seriesId, e);
|
||||
this.logger.error("Failed to load token for series " + seriesId, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeUserTokens(String username) {
|
||||
getJdbcTemplate().update(removeUserTokensSql, username);
|
||||
getJdbcTemplate().update(this.removeUserTokensSql, username);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -38,19 +38,19 @@ public class PersistentRememberMeToken {
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getSeries() {
|
||||
return series;
|
||||
return this.series;
|
||||
}
|
||||
|
||||
public String getTokenValue() {
|
||||
return tokenValue;
|
||||
return this.tokenValue;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
return this.date;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-16
@@ -73,7 +73,7 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
public PersistentTokenBasedRememberMeServices(String key, UserDetailsService userDetailsService,
|
||||
PersistentTokenRepository tokenRepository) {
|
||||
super(key, userDetailsService);
|
||||
random = new SecureRandom();
|
||||
this.random = new SecureRandom();
|
||||
this.tokenRepository = tokenRepository;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
final String presentedSeries = cookieTokens[0];
|
||||
final String presentedToken = cookieTokens[1];
|
||||
|
||||
PersistentRememberMeToken token = tokenRepository.getTokenForSeries(presentedSeries);
|
||||
PersistentRememberMeToken token = this.tokenRepository.getTokenForSeries(presentedSeries);
|
||||
|
||||
if (token == null) {
|
||||
// No series match, so we can't authenticate using this cookie
|
||||
@@ -111,9 +111,10 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
if (!presentedToken.equals(token.getTokenValue())) {
|
||||
// Token doesn't match series value. Delete all logins for this user and throw
|
||||
// an exception to warn them.
|
||||
tokenRepository.removeUserTokens(token.getUsername());
|
||||
this.tokenRepository.removeUserTokens(token.getUsername());
|
||||
|
||||
throw new CookieTheftException(messages.getMessage("PersistentTokenBasedRememberMeServices.cookieStolen",
|
||||
throw new CookieTheftException(this.messages.getMessage(
|
||||
"PersistentTokenBasedRememberMeServices.cookieStolen",
|
||||
"Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack."));
|
||||
}
|
||||
|
||||
@@ -123,8 +124,8 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
|
||||
// Token also matches, so login is valid. Update the token value, keeping the
|
||||
// *same* series number.
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Refreshing persistent login token for user '" + token.getUsername() + "', series '"
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Refreshing persistent login token for user '" + token.getUsername() + "', series '"
|
||||
+ token.getSeries() + "'");
|
||||
}
|
||||
|
||||
@@ -132,11 +133,11 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
generateTokenData(), new Date());
|
||||
|
||||
try {
|
||||
tokenRepository.updateToken(newToken.getSeries(), newToken.getTokenValue(), newToken.getDate());
|
||||
this.tokenRepository.updateToken(newToken.getSeries(), newToken.getTokenValue(), newToken.getDate());
|
||||
addCookie(newToken, request, response);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Failed to update token: ", e);
|
||||
this.logger.error("Failed to update token: ", e);
|
||||
throw new RememberMeAuthenticationException("Autologin failed due to data access problem");
|
||||
}
|
||||
|
||||
@@ -152,16 +153,16 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
Authentication successfulAuthentication) {
|
||||
String username = successfulAuthentication.getName();
|
||||
|
||||
logger.debug("Creating new persistent login for user " + username);
|
||||
this.logger.debug("Creating new persistent login for user " + username);
|
||||
|
||||
PersistentRememberMeToken persistentToken = new PersistentRememberMeToken(username, generateSeriesData(),
|
||||
generateTokenData(), new Date());
|
||||
try {
|
||||
tokenRepository.createNewToken(persistentToken);
|
||||
this.tokenRepository.createNewToken(persistentToken);
|
||||
addCookie(persistentToken, request, response);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Failed to save persistent token ", e);
|
||||
this.logger.error("Failed to save persistent token ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,19 +171,19 @@ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeSe
|
||||
super.logout(request, response, authentication);
|
||||
|
||||
if (authentication != null) {
|
||||
tokenRepository.removeUserTokens(authentication.getName());
|
||||
this.tokenRepository.removeUserTokens(authentication.getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected String generateSeriesData() {
|
||||
byte[] newSeries = new byte[seriesLength];
|
||||
random.nextBytes(newSeries);
|
||||
byte[] newSeries = new byte[this.seriesLength];
|
||||
this.random.nextBytes(newSeries);
|
||||
return new String(Base64.getEncoder().encode(newSeries));
|
||||
}
|
||||
|
||||
protected String generateTokenData() {
|
||||
byte[] newToken = new byte[tokenLength];
|
||||
random.nextBytes(newToken);
|
||||
byte[] newToken = new byte[this.tokenLength];
|
||||
this.random.nextBytes(newToken);
|
||||
return new String(Base64.getEncoder().encode(newToken));
|
||||
}
|
||||
|
||||
|
||||
+17
-16
@@ -81,8 +81,8 @@ public class RememberMeAuthenticationFilter extends GenericFilterBean implements
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(authenticationManager, "authenticationManager must be specified");
|
||||
Assert.notNull(rememberMeServices, "rememberMeServices must be specified");
|
||||
Assert.notNull(this.authenticationManager, "authenticationManager must be specified");
|
||||
Assert.notNull(this.rememberMeServices, "rememberMeServices must be specified");
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
|
||||
@@ -91,44 +91,44 @@ public class RememberMeAuthenticationFilter extends GenericFilterBean implements
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
|
||||
if (SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||
Authentication rememberMeAuth = rememberMeServices.autoLogin(request, response);
|
||||
Authentication rememberMeAuth = this.rememberMeServices.autoLogin(request, response);
|
||||
|
||||
if (rememberMeAuth != null) {
|
||||
// Attempt authenticaton via AuthenticationManager
|
||||
try {
|
||||
rememberMeAuth = authenticationManager.authenticate(rememberMeAuth);
|
||||
rememberMeAuth = this.authenticationManager.authenticate(rememberMeAuth);
|
||||
|
||||
// Store to SecurityContextHolder
|
||||
SecurityContextHolder.getContext().setAuthentication(rememberMeAuth);
|
||||
|
||||
onSuccessfulAuthentication(request, response, rememberMeAuth);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContextHolder populated with remember-me token: '"
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("SecurityContextHolder populated with remember-me token: '"
|
||||
+ SecurityContextHolder.getContext().getAuthentication() + "'");
|
||||
}
|
||||
|
||||
// Fire event
|
||||
if (this.eventPublisher != null) {
|
||||
eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(
|
||||
this.eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(
|
||||
SecurityContextHolder.getContext().getAuthentication(), this.getClass()));
|
||||
}
|
||||
|
||||
if (successHandler != null) {
|
||||
successHandler.onAuthenticationSuccess(request, response, rememberMeAuth);
|
||||
if (this.successHandler != null) {
|
||||
this.successHandler.onAuthenticationSuccess(request, response, rememberMeAuth);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
catch (AuthenticationException authenticationException) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContextHolder not populated with remember-me token, as "
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("SecurityContextHolder not populated with remember-me token, as "
|
||||
+ "AuthenticationManager rejected Authentication returned by RememberMeServices: '"
|
||||
+ rememberMeAuth + "'; invalidating remember-me token", authenticationException);
|
||||
}
|
||||
|
||||
rememberMeServices.loginFail(request, response);
|
||||
this.rememberMeServices.loginFail(request, response);
|
||||
|
||||
onUnsuccessfulAuthentication(request, response, authenticationException);
|
||||
}
|
||||
@@ -137,9 +137,10 @@ public class RememberMeAuthenticationFilter extends GenericFilterBean implements
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContextHolder not populated with remember-me token, as it already contained: '"
|
||||
+ SecurityContextHolder.getContext().getAuthentication() + "'");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger
|
||||
.debug("SecurityContextHolder not populated with remember-me token, as it already contained: '"
|
||||
+ SecurityContextHolder.getContext().getAuthentication() + "'");
|
||||
}
|
||||
|
||||
chain.doFilter(request, response);
|
||||
@@ -166,7 +167,7 @@ public class RememberMeAuthenticationFilter extends GenericFilterBean implements
|
||||
}
|
||||
|
||||
public RememberMeServices getRememberMeServices() {
|
||||
return rememberMeServices;
|
||||
return this.rememberMeServices;
|
||||
}
|
||||
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) {
|
||||
|
||||
+4
-4
@@ -170,7 +170,7 @@ public class TokenBasedRememberMeServices extends AbstractRememberMeServices {
|
||||
// TokenBasedRememberMeServices is
|
||||
// unable to construct a valid token in this case.
|
||||
if (!StringUtils.hasLength(username)) {
|
||||
logger.debug("Unable to retrieve username");
|
||||
this.logger.debug("Unable to retrieve username");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class TokenBasedRememberMeServices extends AbstractRememberMeServices {
|
||||
password = user.getPassword();
|
||||
|
||||
if (!StringUtils.hasLength(password)) {
|
||||
logger.debug("Unable to obtain password for user: " + username);
|
||||
this.logger.debug("Unable to obtain password for user: " + username);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -194,8 +194,8 @@ public class TokenBasedRememberMeServices extends AbstractRememberMeServices {
|
||||
setCookie(new String[] { username, Long.toString(expiryTime), signatureValue }, tokenLifetime, request,
|
||||
response);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(
|
||||
"Added remember-me cookie for user '" + username + "', expiry: '" + new Date(expiryTime) + "'");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -69,7 +69,7 @@ abstract class AbstractSessionFixationProtectionStrategy
|
||||
HttpServletResponse response) {
|
||||
boolean hadSessionAlready = request.getSession(false) != null;
|
||||
|
||||
if (!hadSessionAlready && !alwaysCreateSession) {
|
||||
if (!hadSessionAlready && !this.alwaysCreateSession) {
|
||||
// Session fixation isn't a problem if there's no session
|
||||
|
||||
return;
|
||||
@@ -92,7 +92,7 @@ abstract class AbstractSessionFixationProtectionStrategy
|
||||
}
|
||||
|
||||
if (originalSessionId.equals(newSessionId)) {
|
||||
logger.warn(
|
||||
this.logger.warn(
|
||||
"Your servlet container did not change the session ID when a new session was created. You will"
|
||||
+ " not be adequately protected against session-fixation attacks");
|
||||
}
|
||||
@@ -124,7 +124,7 @@ abstract class AbstractSessionFixationProtectionStrategy
|
||||
* @param auth the token for the newly authenticated principal
|
||||
*/
|
||||
protected void onSessionChange(String originalSessionId, HttpSession newSession, Authentication auth) {
|
||||
applicationEventPublisher
|
||||
this.applicationEventPublisher
|
||||
.publishEvent(new SessionFixationProtectionEvent(auth, originalSessionId, newSession.getId()));
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -93,7 +93,8 @@ public class ConcurrentSessionControlAuthenticationStrategy
|
||||
public void onAuthentication(Authentication authentication, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
final List<SessionInformation> sessions = sessionRegistry.getAllSessions(authentication.getPrincipal(), false);
|
||||
final List<SessionInformation> sessions = this.sessionRegistry.getAllSessions(authentication.getPrincipal(),
|
||||
false);
|
||||
|
||||
int sessionCount = sessions.size();
|
||||
int allowedSessions = getMaximumSessionsForThisUser(authentication);
|
||||
@@ -124,7 +125,7 @@ public class ConcurrentSessionControlAuthenticationStrategy
|
||||
// exceeding the allowed number
|
||||
}
|
||||
|
||||
allowableSessionsExceeded(sessions, allowedSessions, sessionRegistry);
|
||||
allowableSessionsExceeded(sessions, allowedSessions, this.sessionRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +136,7 @@ public class ConcurrentSessionControlAuthenticationStrategy
|
||||
* @return either -1 meaning unlimited, or a positive integer to limit (never zero)
|
||||
*/
|
||||
protected int getMaximumSessionsForThisUser(Authentication authentication) {
|
||||
return maximumSessions;
|
||||
return this.maximumSessions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,9 +150,9 @@ public class ConcurrentSessionControlAuthenticationStrategy
|
||||
*/
|
||||
protected void allowableSessionsExceeded(List<SessionInformation> sessions, int allowableSessions,
|
||||
SessionRegistry registry) throws SessionAuthenticationException {
|
||||
if (exceptionIfMaximumExceeded || (sessions == null)) {
|
||||
if (this.exceptionIfMaximumExceeded || (sessions == null)) {
|
||||
throw new SessionAuthenticationException(
|
||||
messages.getMessage("ConcurrentSessionControlAuthenticationStrategy.exceededAllowed",
|
||||
this.messages.getMessage("ConcurrentSessionControlAuthenticationStrategy.exceededAllowed",
|
||||
new Object[] { allowableSessions }, "Maximum sessions of {0} for this principal exceeded"));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class RegisterSessionAuthenticationStrategy implements SessionAuthenticat
|
||||
*/
|
||||
public void onAuthentication(Authentication authentication, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
sessionRegistry.registerNewSession(request.getSession().getId(), authentication.getPrincipal());
|
||||
this.sessionRegistry.registerNewSession(request.getSession().getId(), authentication.getPrincipal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -82,9 +82,9 @@ public class SessionFixationProtectionStrategy extends AbstractSessionFixationPr
|
||||
final HttpSession applySessionFixation(HttpServletRequest request) {
|
||||
HttpSession session = request.getSession();
|
||||
String originalSessionId = session.getId();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalidating session with Id '" + originalSessionId + "' "
|
||||
+ (migrateSessionAttributes ? "and" : "without") + " migrating attributes.");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Invalidating session with Id '" + originalSessionId + "' "
|
||||
+ (this.migrateSessionAttributes ? "and" : "without") + " migrating attributes.");
|
||||
}
|
||||
|
||||
Map<String, Object> attributesToMigrate = extractAttributes(session);
|
||||
@@ -93,12 +93,12 @@ public class SessionFixationProtectionStrategy extends AbstractSessionFixationPr
|
||||
session.invalidate();
|
||||
session = request.getSession(true); // we now have a new session
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Started new session: " + session.getId());
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Started new session: " + session.getId());
|
||||
}
|
||||
|
||||
transferAttributes(attributesToMigrate, session);
|
||||
if (migrateSessionAttributes) {
|
||||
if (this.migrateSessionAttributes) {
|
||||
session.setMaxInactiveInterval(maxInactiveIntervalToMigrate);
|
||||
}
|
||||
return session;
|
||||
@@ -125,7 +125,7 @@ public class SessionFixationProtectionStrategy extends AbstractSessionFixationPr
|
||||
|
||||
while (enumer.hasMoreElements()) {
|
||||
String key = (String) enumer.nextElement();
|
||||
if (!migrateSessionAttributes && !key.startsWith("SPRING_SECURITY_")) {
|
||||
if (!this.migrateSessionAttributes && !key.startsWith("SPRING_SECURITY_")) {
|
||||
// Only retain Spring Security attributes
|
||||
continue;
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class AuthenticationSwitchUserEvent extends AbstractAuthenticationEvent {
|
||||
}
|
||||
|
||||
public UserDetails getTargetUser() {
|
||||
return targetUser;
|
||||
return this.targetUser;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -51,12 +51,12 @@ public final class SwitchUserGrantedAuthority implements GrantedAuthority {
|
||||
* @return The original <code>Authentication</code> object of the switched user.
|
||||
*/
|
||||
public Authentication getSource() {
|
||||
return source;
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return role;
|
||||
return this.role;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,7 +82,7 @@ public final class SwitchUserGrantedAuthority implements GrantedAuthority {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Switch User Authority [" + role + "," + source + "]";
|
||||
return "Switch User Authority [" + this.role + "," + this.source + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-16
@@ -111,21 +111,22 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
this.logoutSuccessUrl = DEFAULT_LOGIN_PAGE_URL + "?logout";
|
||||
this.failureUrl = DEFAULT_LOGIN_PAGE_URL + "?" + ERROR_PARAMETER_NAME;
|
||||
if (authFilter != null) {
|
||||
formLoginEnabled = true;
|
||||
usernameParameter = authFilter.getUsernameParameter();
|
||||
passwordParameter = authFilter.getPasswordParameter();
|
||||
this.formLoginEnabled = true;
|
||||
this.usernameParameter = authFilter.getUsernameParameter();
|
||||
this.passwordParameter = authFilter.getPasswordParameter();
|
||||
|
||||
if (authFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
|
||||
rememberMeParameter = ((AbstractRememberMeServices) authFilter.getRememberMeServices()).getParameter();
|
||||
this.rememberMeParameter = ((AbstractRememberMeServices) authFilter.getRememberMeServices())
|
||||
.getParameter();
|
||||
}
|
||||
}
|
||||
|
||||
if (openIDFilter != null) {
|
||||
openIdEnabled = true;
|
||||
openIDusernameParameter = "openid_identifier";
|
||||
this.openIdEnabled = true;
|
||||
this.openIDusernameParameter = "openid_identifier";
|
||||
|
||||
if (openIDFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
|
||||
openIDrememberMeParameter = ((AbstractRememberMeServices) openIDFilter.getRememberMeServices())
|
||||
this.openIDrememberMeParameter = ((AbstractRememberMeServices) openIDFilter.getRememberMeServices())
|
||||
.getParameter();
|
||||
}
|
||||
}
|
||||
@@ -143,7 +144,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return formLoginEnabled || openIdEnabled || oauth2LoginEnabled || this.saml2LoginEnabled;
|
||||
return this.formLoginEnabled || this.openIdEnabled || this.oauth2LoginEnabled || this.saml2LoginEnabled;
|
||||
}
|
||||
|
||||
public void setLogoutSuccessUrl(String logoutSuccessUrl) {
|
||||
@@ -151,7 +152,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
public String getLoginPageUrl() {
|
||||
return loginPageUrl;
|
||||
return this.loginPageUrl;
|
||||
}
|
||||
|
||||
public void setLoginPageUrl(String loginPageUrl) {
|
||||
@@ -270,7 +271,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
+ " </form>\n");
|
||||
}
|
||||
|
||||
if (openIdEnabled) {
|
||||
if (this.openIdEnabled) {
|
||||
sb.append(" <form name=\"oidf\" class=\"form-signin\" method=\"post\" action=\"" + contextPath
|
||||
+ this.openIDauthenticationUrl + "\">\n"
|
||||
+ " <h2 class=\"form-signin-heading\">Login with OpenID Identity</h2>\n"
|
||||
@@ -283,12 +284,12 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
+ " </form>\n");
|
||||
}
|
||||
|
||||
if (oauth2LoginEnabled) {
|
||||
if (this.oauth2LoginEnabled) {
|
||||
sb.append("<h2 class=\"form-signin-heading\">Login with OAuth 2.0</h2>");
|
||||
sb.append(createError(loginError, errorMsg));
|
||||
sb.append(createLogoutSuccess(logoutSuccess));
|
||||
sb.append("<table class=\"table table-striped\">\n");
|
||||
for (Map.Entry<String, String> clientAuthenticationUrlToClientName : oauth2AuthenticationUrlToClientName
|
||||
for (Map.Entry<String, String> clientAuthenticationUrlToClientName : this.oauth2AuthenticationUrlToClientName
|
||||
.entrySet()) {
|
||||
sb.append(" <tr><td>");
|
||||
String url = clientAuthenticationUrlToClientName.getKey();
|
||||
@@ -306,7 +307,8 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
sb.append(createError(loginError, errorMsg));
|
||||
sb.append(createLogoutSuccess(logoutSuccess));
|
||||
sb.append("<table class=\"table table-striped\">\n");
|
||||
for (Map.Entry<String, String> relyingPartyUrlToName : saml2AuthenticationUrlToProviderName.entrySet()) {
|
||||
for (Map.Entry<String, String> relyingPartyUrlToName : this.saml2AuthenticationUrlToProviderName
|
||||
.entrySet()) {
|
||||
sb.append(" <tr><td>");
|
||||
String url = relyingPartyUrlToName.getKey();
|
||||
sb.append("<a href=\"").append(contextPath).append(url).append("\">");
|
||||
@@ -340,15 +342,15 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
private boolean isLogoutSuccess(HttpServletRequest request) {
|
||||
return logoutSuccessUrl != null && matches(request, logoutSuccessUrl);
|
||||
return this.logoutSuccessUrl != null && matches(request, this.logoutSuccessUrl);
|
||||
}
|
||||
|
||||
private boolean isLoginUrlRequest(HttpServletRequest request) {
|
||||
return matches(request, loginPageUrl);
|
||||
return matches(request, this.loginPageUrl);
|
||||
}
|
||||
|
||||
private boolean isErrorPage(HttpServletRequest request) {
|
||||
return matches(request, failureUrl);
|
||||
return matches(request, this.failureUrl);
|
||||
}
|
||||
|
||||
private static String createError(boolean isError, String message) {
|
||||
|
||||
+3
-3
@@ -45,17 +45,17 @@ public class BasicAuthenticationEntryPoint implements AuthenticationEntryPoint,
|
||||
private String realmName;
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.hasText(realmName, "realmName must be specified");
|
||||
Assert.hasText(this.realmName, "realmName must be specified");
|
||||
}
|
||||
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException {
|
||||
response.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\"");
|
||||
response.addHeader("WWW-Authenticate", "Basic realm=\"" + this.realmName + "\"");
|
||||
response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
||||
}
|
||||
|
||||
public String getRealmName() {
|
||||
return realmName;
|
||||
return this.realmName;
|
||||
}
|
||||
|
||||
public void setRealmName(String realmName) {
|
||||
|
||||
+2
-2
@@ -143,7 +143,7 @@ public class BasicAuthenticationFilter extends OncePerRequestFilter {
|
||||
throws IOException, ServletException {
|
||||
final boolean debug = this.logger.isDebugEnabled();
|
||||
try {
|
||||
UsernamePasswordAuthenticationToken authRequest = authenticationConverter.convert(request);
|
||||
UsernamePasswordAuthenticationToken authRequest = this.authenticationConverter.convert(request);
|
||||
if (authRequest == null) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@@ -254,7 +254,7 @@ public class BasicAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
public void setAuthenticationDetailsSource(
|
||||
AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
|
||||
authenticationConverter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||
this.authenticationConverter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||
}
|
||||
|
||||
public void setRememberMeServices(RememberMeServices rememberMeServices) {
|
||||
|
||||
+10
-10
@@ -58,7 +58,7 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
|
||||
private int order = Integer.MAX_VALUE; // ~ default
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
@@ -66,11 +66,11 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
if ((realmName == null) || "".equals(realmName)) {
|
||||
if ((this.realmName == null) || "".equals(this.realmName)) {
|
||||
throw new IllegalArgumentException("realmName must be specified");
|
||||
}
|
||||
|
||||
if ((key == null) || "".equals(key)) {
|
||||
if ((this.key == null) || "".equals(this.key)) {
|
||||
throw new IllegalArgumentException("key must be specified");
|
||||
}
|
||||
}
|
||||
@@ -82,16 +82,16 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
|
||||
// compute a nonce (do not use remote IP address due to proxy farms)
|
||||
// format of nonce is:
|
||||
// base64(expirationTime + ":" + md5Hex(expirationTime + ":" + key))
|
||||
long expiryTime = System.currentTimeMillis() + (nonceValiditySeconds * 1000);
|
||||
String signatureValue = DigestAuthUtils.md5Hex(expiryTime + ":" + key);
|
||||
long expiryTime = System.currentTimeMillis() + (this.nonceValiditySeconds * 1000);
|
||||
String signatureValue = DigestAuthUtils.md5Hex(expiryTime + ":" + this.key);
|
||||
String nonceValue = expiryTime + ":" + signatureValue;
|
||||
String nonceValueBase64 = new String(Base64.getEncoder().encode(nonceValue.getBytes()));
|
||||
|
||||
// qop is quality of protection, as defined by RFC 2617.
|
||||
// we do not use opaque due to IE violation of RFC 2617 in not
|
||||
// representing opaque on subsequent requests in same session.
|
||||
String authenticateHeader = "Digest realm=\"" + realmName + "\", " + "qop=\"auth\", nonce=\"" + nonceValueBase64
|
||||
+ "\"";
|
||||
String authenticateHeader = "Digest realm=\"" + this.realmName + "\", " + "qop=\"auth\", nonce=\""
|
||||
+ nonceValueBase64 + "\"";
|
||||
|
||||
if (authException instanceof NonceExpiredException) {
|
||||
authenticateHeader = authenticateHeader + ", stale=\"true\"";
|
||||
@@ -106,15 +106,15 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public int getNonceValiditySeconds() {
|
||||
return nonceValiditySeconds;
|
||||
return this.nonceValiditySeconds;
|
||||
}
|
||||
|
||||
public String getRealmName() {
|
||||
return realmName;
|
||||
return this.realmName;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ public final class HttpRequestResponseHolder {
|
||||
}
|
||||
|
||||
public HttpServletRequest getRequest() {
|
||||
return request;
|
||||
return this.request;
|
||||
}
|
||||
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
@@ -47,7 +47,7 @@ public final class HttpRequestResponseHolder {
|
||||
}
|
||||
|
||||
public HttpServletResponse getResponse() {
|
||||
return response;
|
||||
return this.response;
|
||||
}
|
||||
|
||||
public void setResponse(HttpServletResponse response) {
|
||||
|
||||
+46
-39
@@ -117,8 +117,8 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
SecurityContext context = readSecurityContextFromSession(httpSession);
|
||||
|
||||
if (context == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No SecurityContext was available from the HttpSession: " + httpSession + ". "
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("No SecurityContext was available from the HttpSession: " + httpSession + ". "
|
||||
+ "A new one will be created.");
|
||||
}
|
||||
context = generateNewContext();
|
||||
@@ -157,18 +157,18 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
return false;
|
||||
}
|
||||
|
||||
return session.getAttribute(springSecurityContextKey) != null;
|
||||
return session.getAttribute(this.springSecurityContextKey) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param httpSession the session obtained from the request.
|
||||
*/
|
||||
private SecurityContext readSecurityContextFromSession(HttpSession httpSession) {
|
||||
final boolean debug = logger.isDebugEnabled();
|
||||
final boolean debug = this.logger.isDebugEnabled();
|
||||
|
||||
if (httpSession == null) {
|
||||
if (debug) {
|
||||
logger.debug("No HttpSession currently exists");
|
||||
this.logger.debug("No HttpSession currently exists");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -176,11 +176,11 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
|
||||
// Session exists, so try to obtain a context from it.
|
||||
|
||||
Object contextFromSession = httpSession.getAttribute(springSecurityContextKey);
|
||||
Object contextFromSession = httpSession.getAttribute(this.springSecurityContextKey);
|
||||
|
||||
if (contextFromSession == null) {
|
||||
if (debug) {
|
||||
logger.debug("HttpSession returned null object for SPRING_SECURITY_CONTEXT");
|
||||
this.logger.debug("HttpSession returned null object for SPRING_SECURITY_CONTEXT");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -188,8 +188,8 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
|
||||
// We now have the security context object from the session.
|
||||
if (!(contextFromSession instanceof SecurityContext)) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(springSecurityContextKey + " did not contain a SecurityContext but contained: '"
|
||||
if (this.logger.isWarnEnabled()) {
|
||||
this.logger.warn(this.springSecurityContextKey + " did not contain a SecurityContext but contained: '"
|
||||
+ contextFromSession + "'; are you improperly modifying the HttpSession directly "
|
||||
+ "(you should always use SecurityContextHolder) or using the HttpSession attribute "
|
||||
+ "reserved for this class?");
|
||||
@@ -199,7 +199,7 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
logger.debug("Obtained a valid SecurityContext from " + springSecurityContextKey + ": '"
|
||||
this.logger.debug("Obtained a valid SecurityContext from " + this.springSecurityContextKey + ": '"
|
||||
+ contextFromSession + "'");
|
||||
}
|
||||
|
||||
@@ -264,14 +264,14 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync() {
|
||||
response.disableSaveOnResponseCommitted();
|
||||
this.response.disableSaveOnResponseCommitted();
|
||||
return super.startAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse)
|
||||
throws IllegalStateException {
|
||||
response.disableSaveOnResponseCommitted();
|
||||
this.response.disableSaveOnResponseCommitted();
|
||||
return super.startAsync(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
*/
|
||||
SaveToSessionResponseWrapper(HttpServletResponse response, HttpServletRequest request,
|
||||
boolean httpSessionExistedAtStartOfRequest, SecurityContext context) {
|
||||
super(response, disableUrlRewriting);
|
||||
super(response, HttpSessionSecurityContextRepository.this.disableUrlRewriting);
|
||||
this.request = request;
|
||||
this.httpSessionExistedAtStartOfRequest = httpSessionExistedAtStartOfRequest;
|
||||
this.contextBeforeExecution = context;
|
||||
@@ -329,19 +329,20 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
@Override
|
||||
protected void saveContext(SecurityContext context) {
|
||||
final Authentication authentication = context.getAuthentication();
|
||||
HttpSession httpSession = request.getSession(false);
|
||||
HttpSession httpSession = this.request.getSession(false);
|
||||
|
||||
// See SEC-776
|
||||
if (authentication == null || trustResolver.isAnonymous(authentication)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
if (authentication == null
|
||||
|| HttpSessionSecurityContextRepository.this.trustResolver.isAnonymous(authentication)) {
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger.debug(
|
||||
"SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.");
|
||||
}
|
||||
|
||||
if (httpSession != null && authBeforeExecution != null) {
|
||||
if (httpSession != null && this.authBeforeExecution != null) {
|
||||
// SEC-1587 A non-anonymous context may still be in the session
|
||||
// SEC-1735 remove if the contextBeforeExecution was not anonymous
|
||||
httpSession.removeAttribute(springSecurityContextKey);
|
||||
httpSession.removeAttribute(HttpSessionSecurityContextRepository.this.springSecurityContextKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -355,18 +356,21 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
if (httpSession != null) {
|
||||
// We may have a new session, so check also whether the context attribute
|
||||
// is set SEC-1561
|
||||
if (contextChanged(context) || httpSession.getAttribute(springSecurityContextKey) == null) {
|
||||
httpSession.setAttribute(springSecurityContextKey, context);
|
||||
if (contextChanged(context) || httpSession
|
||||
.getAttribute(HttpSessionSecurityContextRepository.this.springSecurityContextKey) == null) {
|
||||
httpSession.setAttribute(HttpSessionSecurityContextRepository.this.springSecurityContextKey,
|
||||
context);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContext '" + context + "' stored to HttpSession: '" + httpSession);
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger
|
||||
.debug("SecurityContext '" + context + "' stored to HttpSession: '" + httpSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contextChanged(SecurityContext context) {
|
||||
return context != contextBeforeExecution || context.getAuthentication() != authBeforeExecution;
|
||||
return context != this.contextBeforeExecution || context.getAuthentication() != this.authBeforeExecution;
|
||||
}
|
||||
|
||||
private HttpSession createNewSessionIfAllowed(SecurityContext context) {
|
||||
@@ -374,18 +378,19 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
return null;
|
||||
}
|
||||
|
||||
if (httpSessionExistedAtStartOfRequest) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("HttpSession is now null, but was not null at start of request; "
|
||||
+ "session was invalidated, so do not create a new session");
|
||||
if (this.httpSessionExistedAtStartOfRequest) {
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger
|
||||
.debug("HttpSession is now null, but was not null at start of request; "
|
||||
+ "session was invalidated, so do not create a new session");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!allowSessionCreation) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("The HttpSession is currently null, and the "
|
||||
if (!HttpSessionSecurityContextRepository.this.allowSessionCreation) {
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger.debug("The HttpSession is currently null, and the "
|
||||
+ HttpSessionSecurityContextRepository.class.getSimpleName()
|
||||
+ " is prohibited from creating an HttpSession "
|
||||
+ "(because the allowSessionCreation property is false) - SecurityContext thus not "
|
||||
@@ -396,9 +401,9 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
}
|
||||
// Generate a HttpSession only if we need to
|
||||
|
||||
if (contextObject.equals(context)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
if (HttpSessionSecurityContextRepository.this.contextObject.equals(context)) {
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger.debug(
|
||||
"HttpSession is null, but SecurityContext has not changed from default empty context: ' "
|
||||
+ context + "'; not creating HttpSession or storing SecurityContext");
|
||||
}
|
||||
@@ -406,18 +411,20 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||
return null;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("HttpSession being created as SecurityContext is non-default");
|
||||
if (HttpSessionSecurityContextRepository.this.logger.isDebugEnabled()) {
|
||||
HttpSessionSecurityContextRepository.this.logger
|
||||
.debug("HttpSession being created as SecurityContext is non-default");
|
||||
}
|
||||
|
||||
try {
|
||||
return request.getSession(true);
|
||||
return this.request.getSession(true);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// Response must already be committed, therefore can't create a new
|
||||
// session
|
||||
logger.warn("Failed to create a session, as response has been committed. Unable to store"
|
||||
+ " SecurityContext.");
|
||||
HttpSessionSecurityContextRepository.this.logger
|
||||
.warn("Failed to create a session, as response has been committed. Unable to store"
|
||||
+ " SecurityContext.");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+6
-6
@@ -83,20 +83,20 @@ public class SecurityContextPersistenceFilter extends GenericFilterBean {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean debug = logger.isDebugEnabled();
|
||||
final boolean debug = this.logger.isDebugEnabled();
|
||||
|
||||
request.setAttribute(FILTER_APPLIED, Boolean.TRUE);
|
||||
|
||||
if (forceEagerSessionCreation) {
|
||||
if (this.forceEagerSessionCreation) {
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
if (debug && session.isNew()) {
|
||||
logger.debug("Eagerly created session: " + session.getId());
|
||||
this.logger.debug("Eagerly created session: " + session.getId());
|
||||
}
|
||||
}
|
||||
|
||||
HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, response);
|
||||
SecurityContext contextBeforeChainExecution = repo.loadContext(holder);
|
||||
SecurityContext contextBeforeChainExecution = this.repo.loadContext(holder);
|
||||
|
||||
try {
|
||||
SecurityContextHolder.setContext(contextBeforeChainExecution);
|
||||
@@ -109,11 +109,11 @@ public class SecurityContextPersistenceFilter extends GenericFilterBean {
|
||||
// Crucial removal of SecurityContextHolder contents - do this before anything
|
||||
// else.
|
||||
SecurityContextHolder.clearContext();
|
||||
repo.saveContext(contextAfterChainExecution, holder.getRequest(), holder.getResponse());
|
||||
this.repo.saveContext(contextAfterChainExecution, holder.getRequest(), holder.getResponse());
|
||||
request.removeAttribute(FILTER_APPLIED);
|
||||
|
||||
if (debug) {
|
||||
logger.debug("SecurityContextHolder now cleared, as request processing completed");
|
||||
this.logger.debug("SecurityContextHolder now cleared, as request processing completed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -66,14 +66,14 @@ public final class SecurityContextCallableProcessingInterceptor extends Callable
|
||||
|
||||
@Override
|
||||
public <T> void beforeConcurrentHandling(NativeWebRequest request, Callable<T> task) {
|
||||
if (securityContext == null) {
|
||||
if (this.securityContext == null) {
|
||||
setSecurityContext(SecurityContextHolder.getContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void preProcess(NativeWebRequest request, Callable<T> task) {
|
||||
SecurityContextHolder.setContext(securityContext);
|
||||
SecurityContextHolder.setContext(this.securityContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -69,11 +69,11 @@ public final class CookieCsrfTokenRepository implements CsrfTokenRepository {
|
||||
public void saveToken(CsrfToken token, HttpServletRequest request, HttpServletResponse response) {
|
||||
String tokenValue = token == null ? "" : token.getToken();
|
||||
Cookie cookie = new Cookie(this.cookieName, tokenValue);
|
||||
if (secure == null) {
|
||||
if (this.secure == null) {
|
||||
cookie.setSecure(request.isSecure());
|
||||
}
|
||||
else {
|
||||
cookie.setSecure(secure);
|
||||
cookie.setSecure(this.secure);
|
||||
}
|
||||
|
||||
if (this.cookiePath != null && !this.cookiePath.isEmpty()) {
|
||||
@@ -88,7 +88,7 @@ public final class CookieCsrfTokenRepository implements CsrfTokenRepository {
|
||||
else {
|
||||
cookie.setMaxAge(-1);
|
||||
}
|
||||
cookie.setHttpOnly(cookieHttpOnly);
|
||||
cookie.setHttpOnly(this.cookieHttpOnly);
|
||||
if (this.cookieDomain != null && !this.cookieDomain.isEmpty()) {
|
||||
cookie.setDomain(this.cookieDomain);
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ public final class DebugFilter implements Filter {
|
||||
HttpServletResponse response = (HttpServletResponse) srvltResponse;
|
||||
|
||||
List<Filter> filters = getFilters(request);
|
||||
logger.info("Request received for " + request.getMethod() + " '" + UrlUtils.buildRequestUrl(request) + "':\n\n"
|
||||
+ request + "\n\n" + "servletPath:" + request.getServletPath() + "\n" + "pathInfo:"
|
||||
this.logger.info("Request received for " + request.getMethod() + " '" + UrlUtils.buildRequestUrl(request)
|
||||
+ "':\n\n" + request + "\n\n" + "servletPath:" + request.getServletPath() + "\n" + "pathInfo:"
|
||||
+ request.getPathInfo() + "\n" + "headers: \n" + formatHeaders(request) + "\n\n"
|
||||
+ formatFilters(filters));
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class DebugFilter implements Filter {
|
||||
invokeWithWrappedRequest(request, response, filterChain);
|
||||
}
|
||||
else {
|
||||
fcp.doFilter(request, response, filterChain);
|
||||
this.fcp.doFilter(request, response, filterChain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class DebugFilter implements Filter {
|
||||
request.setAttribute(ALREADY_FILTERED_ATTR_NAME, Boolean.TRUE);
|
||||
request = new DebugRequestWrapper(request);
|
||||
try {
|
||||
fcp.doFilter(request, response, filterChain);
|
||||
this.fcp.doFilter(request, response, filterChain);
|
||||
}
|
||||
finally {
|
||||
request.removeAttribute(ALREADY_FILTERED_ATTR_NAME);
|
||||
@@ -132,7 +132,7 @@ public final class DebugFilter implements Filter {
|
||||
}
|
||||
|
||||
private List<Filter> getFilters(HttpServletRequest request) {
|
||||
for (SecurityFilterChain chain : fcp.getFilterChains()) {
|
||||
for (SecurityFilterChain chain : this.fcp.getFilterChains()) {
|
||||
if (chain.matches(request)) {
|
||||
return chain.getFilters();
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class HttpStatusRequestRejectedHandler implements RequestRejectedHandler
|
||||
* Constructs an instance which uses {@code 400} as response code.
|
||||
*/
|
||||
public HttpStatusRequestRejectedHandler() {
|
||||
httpError = HttpServletResponse.SC_BAD_REQUEST;
|
||||
this.httpError = HttpServletResponse.SC_BAD_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ public class HttpStatusRequestRejectedHandler implements RequestRejectedHandler
|
||||
logger.debug("Rejecting request due to: " + requestRejectedException.getMessage(),
|
||||
requestRejectedException);
|
||||
}
|
||||
response.sendError(httpError);
|
||||
response.sendError(this.httpError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ final class RequestWrapper extends FirewalledRequest {
|
||||
|
||||
RequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
strippedServletPath = strip(request.getServletPath());
|
||||
this.strippedServletPath = strip(request.getServletPath());
|
||||
String pathInfo = strip(request.getPathInfo());
|
||||
if (pathInfo != null && pathInfo.length() == 0) {
|
||||
pathInfo = null;
|
||||
}
|
||||
strippedPathInfo = pathInfo;
|
||||
this.strippedPathInfo = pathInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,12 +112,12 @@ final class RequestWrapper extends FirewalledRequest {
|
||||
|
||||
@Override
|
||||
public String getPathInfo() {
|
||||
return stripPaths ? strippedPathInfo : super.getPathInfo();
|
||||
return this.stripPaths ? this.strippedPathInfo : super.getPathInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return stripPaths ? strippedServletPath : super.getServletPath();
|
||||
return this.stripPaths ? this.strippedServletPath : super.getServletPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,7 +158,7 @@ final class RequestWrapper extends FirewalledRequest {
|
||||
}
|
||||
|
||||
private RequestDispatcher getDelegateDispatcher() {
|
||||
return RequestWrapper.super.getRequestDispatcher(path);
|
||||
return RequestWrapper.super.getRequestDispatcher(this.path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-14
@@ -460,7 +460,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
return new FirewalledRequest(request) {
|
||||
@Override
|
||||
public long getDateHeader(String name) {
|
||||
if (!allowedHeaderNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the header name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
@Override
|
||||
public int getIntHeader(String name) {
|
||||
if (!allowedHeaderNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the header name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
@@ -478,12 +478,12 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (!allowedHeaderNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the header name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
String value = super.getHeader(name);
|
||||
if (value != null && !allowedHeaderValues.test(value)) {
|
||||
if (value != null && !StrictHttpFirewall.this.allowedHeaderValues.test(value)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the header value \"" + value + "\" is not allowed.");
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
if (!allowedHeaderNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the header name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
@@ -507,7 +507,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
@Override
|
||||
public String nextElement() {
|
||||
String value = valuesEnumeration.nextElement();
|
||||
if (!allowedHeaderValues.test(value)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderValues.test(value)) {
|
||||
throw new RequestRejectedException("The request was rejected because the header value \""
|
||||
+ value + "\" is not allowed.");
|
||||
}
|
||||
@@ -528,7 +528,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
@Override
|
||||
public String nextElement() {
|
||||
String name = namesEnumeration.nextElement();
|
||||
if (!allowedHeaderNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedHeaderNames.test(name)) {
|
||||
throw new RequestRejectedException("The request was rejected because the header name \""
|
||||
+ name + "\" is not allowed.");
|
||||
}
|
||||
@@ -539,12 +539,12 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
if (!allowedParameterNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the parameter name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
String value = super.getParameter(name);
|
||||
if (value != null && !allowedParameterValues.test(value)) {
|
||||
if (value != null && !StrictHttpFirewall.this.allowedParameterValues.test(value)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the parameter value \"" + value + "\" is not allowed.");
|
||||
}
|
||||
@@ -557,12 +557,12 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
String[] values = entry.getValue();
|
||||
if (!allowedParameterNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the parameter name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
for (String value : values) {
|
||||
if (!allowedParameterValues.test(value)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterValues.test(value)) {
|
||||
throw new RequestRejectedException("The request was rejected because the parameter value \""
|
||||
+ value + "\" is not allowed.");
|
||||
}
|
||||
@@ -583,7 +583,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
@Override
|
||||
public String nextElement() {
|
||||
String name = namesEnumeration.nextElement();
|
||||
if (!allowedParameterNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterNames.test(name)) {
|
||||
throw new RequestRejectedException("The request was rejected because the parameter name \""
|
||||
+ name + "\" is not allowed.");
|
||||
}
|
||||
@@ -594,14 +594,14 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
if (!allowedParameterNames.test(name)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterNames.test(name)) {
|
||||
throw new RequestRejectedException(
|
||||
"The request was rejected because the parameter name \"" + name + "\" is not allowed.");
|
||||
}
|
||||
String[] values = super.getParameterValues(name);
|
||||
if (values != null) {
|
||||
for (String value : values) {
|
||||
if (!allowedParameterValues.test(value)) {
|
||||
if (!StrictHttpFirewall.this.allowedParameterValues.test(value)) {
|
||||
throw new RequestRejectedException("The request was rejected because the parameter value \""
|
||||
+ value + "\" is not allowed.");
|
||||
}
|
||||
|
||||
@@ -79,12 +79,12 @@ public final class Header {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return headerName.hashCode() + headerValues.hashCode();
|
||||
return this.headerName.hashCode() + this.headerValues.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Header [name: " + headerName + ", values: " + headerValues + "]";
|
||||
return "Header [name: " + this.headerName + ", values: " + this.headerValues + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -76,8 +76,8 @@ public final class ClearSiteDataHeaderWriter implements HeaderWriter {
|
||||
response.setHeader(CLEAR_SITE_DATA_HEADER, this.headerValue);
|
||||
}
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Not injecting Clear-Site-Data header since it did not match the " + "requestMatcher "
|
||||
else if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Not injecting Clear-Site-Data header since it did not match the " + "requestMatcher "
|
||||
+ this.requestMatcher);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -116,9 +116,10 @@ public final class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
|
||||
*/
|
||||
@Override
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
String headerName = !reportOnly ? CONTENT_SECURITY_POLICY_HEADER : CONTENT_SECURITY_POLICY_REPORT_ONLY_HEADER;
|
||||
String headerName = !this.reportOnly ? CONTENT_SECURITY_POLICY_HEADER
|
||||
: CONTENT_SECURITY_POLICY_REPORT_ONLY_HEADER;
|
||||
if (!response.containsHeader(headerName)) {
|
||||
response.setHeader(headerName, policyDirectives);
|
||||
response.setHeader(headerName, this.policyDirectives);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +144,8 @@ public final class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + " [policyDirectives=" + policyDirectives + "; reportOnly=" + reportOnly + "]";
|
||||
return getClass().getName() + " [policyDirectives=" + this.policyDirectives + "; reportOnly=" + this.reportOnly
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-13
@@ -178,19 +178,19 @@ public final class HpkpHeaderWriter implements HeaderWriter {
|
||||
* .servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (requestMatcher.matches(request)) {
|
||||
if (!pins.isEmpty()) {
|
||||
String headerName = reportOnly ? HPKP_RO_HEADER_NAME : HPKP_HEADER_NAME;
|
||||
if (this.requestMatcher.matches(request)) {
|
||||
if (!this.pins.isEmpty()) {
|
||||
String headerName = this.reportOnly ? HPKP_RO_HEADER_NAME : HPKP_HEADER_NAME;
|
||||
if (!response.containsHeader(headerName)) {
|
||||
response.setHeader(headerName, hpkpHeaderValue);
|
||||
response.setHeader(headerName, this.hpkpHeaderValue);
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Not injecting HPKP header since there aren't any pins");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Not injecting HPKP header since there aren't any pins");
|
||||
}
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Not injecting HPKP header since it wasn't a secure connection");
|
||||
else if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Not injecting HPKP header since it wasn't a secure connection");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,14 +426,14 @@ public final class HpkpHeaderWriter implements HeaderWriter {
|
||||
}
|
||||
|
||||
private void updateHpkpHeaderValue() {
|
||||
String headerValue = "max-age=" + maxAgeInSeconds;
|
||||
for (Map.Entry<String, String> pin : pins.entrySet()) {
|
||||
String headerValue = "max-age=" + this.maxAgeInSeconds;
|
||||
for (Map.Entry<String, String> pin : this.pins.entrySet()) {
|
||||
headerValue += " ; pin-" + pin.getValue() + "=\"" + pin.getKey() + "\"";
|
||||
}
|
||||
if (reportUri != null) {
|
||||
headerValue += " ; report-uri=\"" + reportUri.toString() + "\"";
|
||||
if (this.reportUri != null) {
|
||||
headerValue += " ; report-uri=\"" + this.reportUri.toString() + "\"";
|
||||
}
|
||||
if (includeSubDomains) {
|
||||
if (this.includeSubDomains) {
|
||||
headerValue += " ; includeSubDomains";
|
||||
}
|
||||
this.hpkpHeaderValue = headerValue;
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class StaticHeadersWriter implements HeaderWriter {
|
||||
}
|
||||
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
for (Header header : headers) {
|
||||
for (Header header : this.headers) {
|
||||
if (!response.containsHeader(header.getName())) {
|
||||
for (String value : header.getValues()) {
|
||||
response.addHeader(header.getName(), value);
|
||||
@@ -67,7 +67,7 @@ public class StaticHeadersWriter implements HeaderWriter {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + " [headers=" + headers + "]";
|
||||
return getClass().getName() + " [headers=" + this.headers + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -50,7 +50,7 @@ public final class XXssProtectionHeaderWriter implements HeaderWriter {
|
||||
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (!response.containsHeader(XSS_PROTECTION_HEADER)) {
|
||||
response.setHeader(XSS_PROTECTION_HEADER, headerValue);
|
||||
response.setHeader(XSS_PROTECTION_HEADER, this.headerValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class XXssProtectionHeaderWriter implements HeaderWriter {
|
||||
* @param block the new value
|
||||
*/
|
||||
public void setBlock(boolean block) {
|
||||
if (!enabled && block) {
|
||||
if (!this.enabled && block) {
|
||||
throw new IllegalArgumentException("Cannot set block to true with enabled false");
|
||||
}
|
||||
this.block = block;
|
||||
@@ -98,19 +98,19 @@ public final class XXssProtectionHeaderWriter implements HeaderWriter {
|
||||
}
|
||||
|
||||
private void updateHeaderValue() {
|
||||
if (!enabled) {
|
||||
if (!this.enabled) {
|
||||
this.headerValue = "0";
|
||||
return;
|
||||
}
|
||||
this.headerValue = "1";
|
||||
if (block) {
|
||||
if (this.block) {
|
||||
this.headerValue += "; mode=block";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + " [headerValue=" + headerValue + "]";
|
||||
return getClass().getName() + " [headerValue=" + this.headerValue + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -46,9 +46,9 @@ abstract class AbstractRequestParameterAllowFromStrategy implements AllowFromStr
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
public String getAllowFromValue(HttpServletRequest request) {
|
||||
String allowFromOrigin = request.getParameter(allowFromParameterName);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Supplied origin '" + allowFromOrigin + "'");
|
||||
String allowFromOrigin = request.getParameter(this.allowFromParameterName);
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug("Supplied origin '" + allowFromOrigin + "'");
|
||||
}
|
||||
if (StringUtils.hasText(allowFromOrigin) && allowed(allowFromOrigin)) {
|
||||
return allowFromOrigin;
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public final class RegExpAllowFromStrategy extends AbstractRequestParameterAllow
|
||||
|
||||
@Override
|
||||
protected boolean allowed(String allowFromOrigin) {
|
||||
return pattern.matcher(allowFromOrigin).matches();
|
||||
return this.pattern.matcher(allowFromOrigin).matches();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public final class StaticAllowFromStrategy implements AllowFromStrategy {
|
||||
}
|
||||
|
||||
public String getAllowFromValue(HttpServletRequest request) {
|
||||
return uri.toString();
|
||||
return this.uri.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public final class WhiteListedAllowFromStrategy extends AbstractRequestParameter
|
||||
|
||||
@Override
|
||||
protected boolean allowed(String allowFromOrigin) {
|
||||
return allowed.contains(allowFromOrigin);
|
||||
return this.allowed.contains(allowFromOrigin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -84,7 +84,7 @@ public final class XFrameOptionsHeaderWriter implements HeaderWriter {
|
||||
* @param response the servlet response
|
||||
*/
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (XFrameOptionsMode.ALLOW_FROM.equals(frameOptionsMode)) {
|
||||
if (XFrameOptionsMode.ALLOW_FROM.equals(this.frameOptionsMode)) {
|
||||
String allowFromValue = this.allowFromStrategy.getAllowFromValue(request);
|
||||
if (XFrameOptionsMode.DENY.getMode().equals(allowFromValue)) {
|
||||
if (!response.containsHeader(XFRAME_OPTIONS_HEADER)) {
|
||||
@@ -99,7 +99,7 @@ public final class XFrameOptionsHeaderWriter implements HeaderWriter {
|
||||
}
|
||||
}
|
||||
else {
|
||||
response.setHeader(XFRAME_OPTIONS_HEADER, frameOptionsMode.getMode());
|
||||
response.setHeader(XFRAME_OPTIONS_HEADER, this.frameOptionsMode.getMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public final class XFrameOptionsHeaderWriter implements HeaderWriter {
|
||||
* @return the mode for the X-Frame-Options header value.
|
||||
*/
|
||||
private String getMode() {
|
||||
return mode;
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-9
@@ -72,16 +72,16 @@ public class JaasApiIntegrationFilter extends GenericFilterBean {
|
||||
throws ServletException, IOException {
|
||||
|
||||
Subject subject = obtainSubject(request);
|
||||
if (subject == null && createEmptySubject) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
if (subject == null && this.createEmptySubject) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(
|
||||
"Subject returned was null and createEmtpySubject is true; creating new empty subject to run as.");
|
||||
}
|
||||
subject = new Subject();
|
||||
}
|
||||
if (subject == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Subject is null continue running with no Subject.");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Subject is null continue running with no Subject.");
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@@ -91,8 +91,8 @@ public class JaasApiIntegrationFilter extends GenericFilterBean {
|
||||
return null;
|
||||
};
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Running as Subject " + subject);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Running as Subject " + subject);
|
||||
}
|
||||
try {
|
||||
Subject.doAs(subject, continueChain);
|
||||
@@ -119,8 +119,8 @@ public class JaasApiIntegrationFilter extends GenericFilterBean {
|
||||
*/
|
||||
protected Subject obtainSubject(ServletRequest request) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Attempting to obtainSubject using authentication : " + authentication);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Attempting to obtainSubject using authentication : " + authentication);
|
||||
}
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public final class AuthenticationPrincipalArgumentResolver implements HandlerMet
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setRootObject(principal);
|
||||
context.setVariable("this", principal);
|
||||
context.setBeanResolver(beanResolver);
|
||||
context.setBeanResolver(this.beanResolver);
|
||||
|
||||
Expression expression = this.parser.parseExpression(expressionToParse);
|
||||
principal = expression.getValue(context);
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class AuthenticationPrincipalArgumentResolver extends HandlerMethodArgume
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setRootObject(principal);
|
||||
context.setVariable("this", principal);
|
||||
context.setBeanResolver(beanResolver);
|
||||
context.setBeanResolver(this.beanResolver);
|
||||
|
||||
Expression expression = this.parser.parseExpression(expressionToParse);
|
||||
principal = expression.getValue(context);
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public class CurrentSecurityContextArgumentResolver extends HandlerMethodArgumen
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setRootObject(securityContext);
|
||||
context.setVariable("this", securityContext);
|
||||
context.setBeanResolver(beanResolver);
|
||||
context.setBeanResolver(this.beanResolver);
|
||||
|
||||
Expression expression = this.parser.parseExpression(expressionToParse);
|
||||
securityContextResult = expression.getValue(context);
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class CookieRequestCache implements RequestCache {
|
||||
|
||||
@Override
|
||||
public void saveRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (requestMatcher.matches(request)) {
|
||||
if (this.requestMatcher.matches(request)) {
|
||||
String redirectUrl = UrlUtils.buildFullRequestUrl(request);
|
||||
Cookie savedCookie = new Cookie(COOKIE_NAME, encodeCookie(redirectUrl));
|
||||
savedCookie.setMaxAge(COOKIE_MAX_AGE);
|
||||
@@ -65,7 +65,7 @@ public class CookieRequestCache implements RequestCache {
|
||||
response.addCookie(savedCookie);
|
||||
}
|
||||
else {
|
||||
logger.debug("Request not saved as configured RequestMatcher did not match");
|
||||
this.logger.debug("Request not saved as configured RequestMatcher did not match");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-22
@@ -166,11 +166,11 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
private void addCookie(Cookie cookie) {
|
||||
cookies.add(new SavedCookie(cookie));
|
||||
this.cookies.add(new SavedCookie(cookie));
|
||||
}
|
||||
|
||||
private void addHeader(String name, String value) {
|
||||
List<String> values = headers.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
List<String> values = this.headers.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
|
||||
values.add(value);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
private void addLocale(Locale locale) {
|
||||
locales.add(locale);
|
||||
this.locales.add(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +209,7 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
private void addParameter(String name, String[] values) {
|
||||
parameters.put(name, values);
|
||||
this.parameters.put(name, values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!"GET".equals(request.getMethod()) && "GET".equals(method)) {
|
||||
if (!"GET".equals(request.getMethod()) && "GET".equals(this.method)) {
|
||||
// A save GET should not match an incoming non-GET method
|
||||
return false;
|
||||
}
|
||||
@@ -264,14 +264,14 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
public String getContextPath() {
|
||||
return contextPath;
|
||||
return this.contextPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cookie> getCookies() {
|
||||
List<Cookie> cookieList = new ArrayList<>(cookies.size());
|
||||
List<Cookie> cookieList = new ArrayList<>(this.cookies.size());
|
||||
|
||||
for (SavedCookie savedCookie : cookies) {
|
||||
for (SavedCookie savedCookie : this.cookies) {
|
||||
cookieList.add(savedCookie.getCookie());
|
||||
}
|
||||
|
||||
@@ -284,17 +284,18 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
*/
|
||||
@Override
|
||||
public String getRedirectUrl() {
|
||||
return UrlUtils.buildFullRequestUrl(scheme, serverName, serverPort, requestURI, queryString);
|
||||
return UrlUtils.buildFullRequestUrl(this.scheme, this.serverName, this.serverPort, this.requestURI,
|
||||
this.queryString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getHeaderNames() {
|
||||
return headers.keySet();
|
||||
return this.headers.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaderValues(String name) {
|
||||
List<String> values = headers.get(name);
|
||||
List<String> values = this.headers.get(name);
|
||||
|
||||
if (values == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -305,30 +306,30 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
|
||||
@Override
|
||||
public List<Locale> getLocales() {
|
||||
return locales;
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return method;
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return parameters;
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public Collection<String> getParameterNames() {
|
||||
return parameters.keySet();
|
||||
return this.parameters.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
return parameters.get(name);
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
|
||||
public String getPathInfo() {
|
||||
return pathInfo;
|
||||
return this.pathInfo;
|
||||
}
|
||||
|
||||
public String getQueryString() {
|
||||
@@ -340,23 +341,23 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
public String getRequestURL() {
|
||||
return requestURL;
|
||||
return this.requestURL;
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return scheme;
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
return this.serverName;
|
||||
}
|
||||
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
return this.serverPort;
|
||||
}
|
||||
|
||||
public String getServletPath() {
|
||||
return servletPath;
|
||||
return this.servletPath;
|
||||
}
|
||||
|
||||
private boolean propertyEquals(String log, Object arg1, Object arg2) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Enumerator<T> implements Enumeration<T> {
|
||||
* one more element to provide, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean hasMoreElements() {
|
||||
return (iterator.hasNext());
|
||||
return (this.iterator.hasNext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ public class Enumerator<T> implements Enumeration<T> {
|
||||
* @exception NoSuchElementException if no more elements exist
|
||||
*/
|
||||
public T nextElement() throws NoSuchElementException {
|
||||
return (iterator.next());
|
||||
return (this.iterator.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -55,19 +55,19 @@ public class HttpSessionRequestCache implements RequestCache {
|
||||
* Stores the current request, provided the configuration properties allow it.
|
||||
*/
|
||||
public void saveRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
if (requestMatcher.matches(request)) {
|
||||
DefaultSavedRequest savedRequest = new DefaultSavedRequest(request, portResolver);
|
||||
if (this.requestMatcher.matches(request)) {
|
||||
DefaultSavedRequest savedRequest = new DefaultSavedRequest(request, this.portResolver);
|
||||
|
||||
if (createSessionAllowed || request.getSession(false) != null) {
|
||||
if (this.createSessionAllowed || request.getSession(false) != null) {
|
||||
// Store the HTTP request itself. Used by
|
||||
// AbstractAuthenticationProcessingFilter
|
||||
// for redirection after successful authentication (SEC-29)
|
||||
request.getSession().setAttribute(this.sessionAttrName, savedRequest);
|
||||
logger.debug("DefaultSavedRequest added to Session: " + savedRequest);
|
||||
this.logger.debug("DefaultSavedRequest added to Session: " + savedRequest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.debug("Request not saved as configured RequestMatcher did not match");
|
||||
this.logger.debug("Request not saved as configured RequestMatcher did not match");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class HttpSessionRequestCache implements RequestCache {
|
||||
HttpSession session = currentRequest.getSession(false);
|
||||
|
||||
if (session != null) {
|
||||
logger.debug("Removing DefaultSavedRequest from session if present");
|
||||
this.logger.debug("Removing DefaultSavedRequest from session if present");
|
||||
session.removeAttribute(this.sessionAttrName);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class HttpSessionRequestCache implements RequestCache {
|
||||
SavedRequest saved = getRequest(request, response);
|
||||
|
||||
if (!matchesSavedRequest(request, saved)) {
|
||||
logger.debug("saved request doesn't match");
|
||||
this.logger.debug("saved request doesn't match");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class RequestCacheAwareFilter extends GenericFilterBean {
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest wrappedSavedRequest = requestCache.getMatchingRequest((HttpServletRequest) request,
|
||||
HttpServletRequest wrappedSavedRequest = this.requestCache.getMatchingRequest((HttpServletRequest) request,
|
||||
(HttpServletResponse) response);
|
||||
|
||||
chain.doFilter(wrappedSavedRequest == null ? request : wrappedSavedRequest, response);
|
||||
|
||||
@@ -60,35 +60,35 @@ public class SavedCookie implements Serializable {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
public int getMaxAge() {
|
||||
return maxAge;
|
||||
return this.maxAge;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return secure;
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public Cookie getCookie() {
|
||||
|
||||
+17
-17
@@ -72,15 +72,15 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
SavedRequestAwareWrapper(SavedRequest saved, HttpServletRequest request) {
|
||||
super(request);
|
||||
savedRequest = saved;
|
||||
this.savedRequest = saved;
|
||||
|
||||
formats[0] = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
|
||||
formats[1] = new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US);
|
||||
formats[2] = new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US);
|
||||
this.formats[0] = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
|
||||
this.formats[1] = new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US);
|
||||
this.formats[2] = new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US);
|
||||
|
||||
formats[0].setTimeZone(GMT_ZONE);
|
||||
formats[1].setTimeZone(GMT_ZONE);
|
||||
formats[2].setTimeZone(GMT_ZONE);
|
||||
this.formats[0].setTimeZone(GMT_ZONE);
|
||||
this.formats[1].setTimeZone(GMT_ZONE);
|
||||
this.formats[2].setTimeZone(GMT_ZONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +92,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
}
|
||||
|
||||
// Attempt to convert the date header in a variety of formats
|
||||
long result = FastHttpDateFormat.parseDate(value, formats);
|
||||
long result = FastHttpDateFormat.parseDate(value, this.formats);
|
||||
|
||||
if (result != -1L) {
|
||||
return result;
|
||||
@@ -103,7 +103,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
List<String> values = savedRequest.getHeaderValues(name);
|
||||
List<String> values = this.savedRequest.getHeaderValues(name);
|
||||
|
||||
return values.isEmpty() ? null : values.get(0);
|
||||
}
|
||||
@@ -111,13 +111,13 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration getHeaderNames() {
|
||||
return new Enumerator<>(savedRequest.getHeaderNames());
|
||||
return new Enumerator<>(this.savedRequest.getHeaderNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration getHeaders(String name) {
|
||||
return new Enumerator<>(savedRequest.getHeaderValues(name));
|
||||
return new Enumerator<>(this.savedRequest.getHeaderValues(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +134,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
List<Locale> locales = savedRequest.getLocales();
|
||||
List<Locale> locales = this.savedRequest.getLocales();
|
||||
|
||||
return locales.isEmpty() ? Locale.getDefault() : locales.get(0);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration getLocales() {
|
||||
List<Locale> locales = savedRequest.getLocales();
|
||||
List<Locale> locales = this.savedRequest.getLocales();
|
||||
|
||||
if (locales.isEmpty()) {
|
||||
// Fall back to default locale
|
||||
@@ -155,7 +155,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return savedRequest.getMethod();
|
||||
return this.savedRequest.getMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
return value;
|
||||
}
|
||||
|
||||
String[] values = savedRequest.getParameterValues(name);
|
||||
String[] values = this.savedRequest.getParameterValues(name);
|
||||
|
||||
if (values == null || values.length == 0) {
|
||||
return null;
|
||||
@@ -202,7 +202,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
private Set<String> getCombinedParameterNames() {
|
||||
Set<String> names = new HashSet<>();
|
||||
names.addAll(super.getParameterMap().keySet());
|
||||
names.addAll(savedRequest.getParameterMap().keySet());
|
||||
names.addAll(this.savedRequest.getParameterMap().keySet());
|
||||
|
||||
return names;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] savedRequestParams = savedRequest.getParameterValues(name);
|
||||
String[] savedRequestParams = this.savedRequest.getParameterValues(name);
|
||||
String[] wrappedRequestParams = super.getParameterValues(name);
|
||||
|
||||
if (savedRequestParams == null) {
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class DelegatingServerAuthenticationEntryPoint implements ServerAuthentic
|
||||
}
|
||||
}).switchIfEmpty(Mono.just(this.defaultEntryPoint).doOnNext(it -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No match found. Using default entry point " + defaultEntryPoint);
|
||||
logger.debug("No match found. Using default entry point " + this.defaultEntryPoint);
|
||||
}
|
||||
})).flatMap(entryPoint -> entryPoint.commence(exchange, e));
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class MatcherSecurityWebFilterChain implements SecurityWebFilterChain {
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> matches(ServerWebExchange exchange) {
|
||||
return matcher.matches(exchange).map(m -> m.isMatch());
|
||||
return this.matcher.matches(exchange).map(m -> m.isMatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -95,7 +95,8 @@ public class AnonymousAuthenticationWebFilter implements WebFilter {
|
||||
}
|
||||
|
||||
protected Authentication createAuthentication(ServerWebExchange exchange) {
|
||||
AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(key, principal, authorities);
|
||||
AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(this.key, this.principal,
|
||||
this.authorities);
|
||||
return auth;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user