Skip to content

Commit d157125

Browse files
committed
Polish AuthenticationFilter
Updated member variable references to be prefixed with "this.". Fixed typo in authentication manager resolver error message. Issue: gh-6506
1 parent 50adb6a commit d157125

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

web/src/main/java/org/springframework/security/web/authentication/AuthenticationFilter.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ public AuthenticationFilter(AuthenticationManager authenticationManager,
7878

7979
public AuthenticationFilter(AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver,
8080
AuthenticationConverter authenticationConverter) {
81-
Assert.notNull(authenticationManagerResolver, "authenticationResolverManager cannot be null");
81+
Assert.notNull(authenticationManagerResolver, "authenticationManagerResolver cannot be null");
8282
Assert.notNull(authenticationConverter, "authenticationConverter cannot be null");
8383

8484
this.authenticationManagerResolver = authenticationManagerResolver;
8585
this.authenticationConverter = authenticationConverter;
8686
}
8787

8888
public RequestMatcher getRequestMatcher() {
89-
return requestMatcher;
89+
return this.requestMatcher;
9090
}
9191

9292
public void setRequestMatcher(RequestMatcher requestMatcher) {
@@ -95,7 +95,7 @@ public void setRequestMatcher(RequestMatcher requestMatcher) {
9595
}
9696

9797
public AuthenticationConverter getAuthenticationConverter() {
98-
return authenticationConverter;
98+
return this.authenticationConverter;
9999
}
100100

101101
public void setAuthenticationConverter(AuthenticationConverter authenticationConverter) {
@@ -104,7 +104,7 @@ public void setAuthenticationConverter(AuthenticationConverter authenticationCon
104104
}
105105

106106
public AuthenticationSuccessHandler getSuccessHandler() {
107-
return successHandler;
107+
return this.successHandler;
108108
}
109109

110110
public void setSuccessHandler(AuthenticationSuccessHandler successHandler) {
@@ -113,7 +113,7 @@ public void setSuccessHandler(AuthenticationSuccessHandler successHandler) {
113113
}
114114

115115
public AuthenticationFailureHandler getFailureHandler() {
116-
return failureHandler;
116+
return this.failureHandler;
117117
}
118118

119119
public void setFailureHandler(AuthenticationFailureHandler failureHandler) {
@@ -122,7 +122,7 @@ public void setFailureHandler(AuthenticationFailureHandler failureHandler) {
122122
}
123123

124124
public AuthenticationManagerResolver<HttpServletRequest> getAuthenticationManagerResolver() {
125-
return authenticationManagerResolver;
125+
return this.authenticationManagerResolver;
126126
}
127127

128128
public void setAuthenticationManagerResolver(
@@ -134,7 +134,7 @@ public void setAuthenticationManagerResolver(
134134
@Override
135135
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
136136
throws ServletException, IOException {
137-
if (!requestMatcher.matches(request)) {
137+
if (!this.requestMatcher.matches(request)) {
138138
filterChain.doFilter(request, response);
139139
return;
140140
}
@@ -155,26 +155,25 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
155155
private void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
156156
AuthenticationException failed) throws IOException, ServletException {
157157
SecurityContextHolder.clearContext();
158-
failureHandler.onAuthenticationFailure(request, response, failed);
158+
this.failureHandler.onAuthenticationFailure(request, response, failed);
159159
}
160160

161161
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
162162
Authentication authentication) throws IOException, ServletException {
163163
SecurityContext context = SecurityContextHolder.createEmptyContext();
164164
context.setAuthentication(authentication);
165165
SecurityContextHolder.setContext(context);
166-
167-
successHandler.onAuthenticationSuccess(request, response, chain, authentication);
166+
this.successHandler.onAuthenticationSuccess(request, response, chain, authentication);
168167
}
169168

170169
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
171170
throws AuthenticationException, IOException, ServletException {
172-
Authentication authentication = authenticationConverter.convert(request);
171+
Authentication authentication = this.authenticationConverter.convert(request);
173172
if (authentication == null) {
174173
return null;
175174
}
176175

177-
AuthenticationManager authenticationManager = authenticationManagerResolver.resolve(request);
176+
AuthenticationManager authenticationManager = this.authenticationManagerResolver.resolve(request);
178177
Authentication authenticationResult = authenticationManager.authenticate(authentication);
179178
if (authenticationResult == null) {
180179
throw new ServletException("AuthenticationManager should not return null Authentication object.");

0 commit comments

Comments
 (0)