From 25052214aea34a9819cea125cbde975a916feb2c Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 17 Oct 2017 00:17:55 +0900 Subject: [PATCH] Polish --- .../configurers/openid/OpenIDLoginConfigurer.java | 2 +- ...eactiveUserDetailsServiceResourceFactoryBean.java | 4 ++-- .../userdetails/UserDetailsResourceFactoryBean.java | 4 ++-- .../UserDetailsManagerResourceFactoryBean.java | 4 ++-- .../userinfo/OAuth2UserAuthenticationToken.java | 2 +- .../OidcClientAuthenticationToken.java | 2 +- .../authentication/OidcUserAuthenticationToken.java | 4 ++-- .../request/SecurityMockMvcRequestBuilders.java | 2 +- .../web/server/DefaultServerRedirectStrategy.java | 2 +- .../RedirectServerAuthenticationSuccessHandler.java | 2 +- .../server/DefaultServerRedirectStrategyTests.java | 12 ++++-------- ...elegatingServerAuthenticationEntryPointTests.java | 3 +-- .../RedirectServerAuthenticationEntryPointTests.java | 7 +++---- ...irectServerAuthenticationSuccessHandlerTests.java | 2 +- 14 files changed, 23 insertions(+), 29 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/openid/OpenIDLoginConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/openid/OpenIDLoginConfigurer.java index 604928bcb0..f8fa11a3e2 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/openid/OpenIDLoginConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/openid/OpenIDLoginConfigurer.java @@ -99,7 +99,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher; * diff --git a/config/src/main/java/org/springframework/security/config/core/userdetails/ReactiveUserDetailsServiceResourceFactoryBean.java b/config/src/main/java/org/springframework/security/config/core/userdetails/ReactiveUserDetailsServiceResourceFactoryBean.java index 5b3f6bd74c..254692055f 100644 --- a/config/src/main/java/org/springframework/security/config/core/userdetails/ReactiveUserDetailsServiceResourceFactoryBean.java +++ b/config/src/main/java/org/springframework/security/config/core/userdetails/ReactiveUserDetailsServiceResourceFactoryBean.java @@ -54,7 +54,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBean } /** - * Sets a the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resourceLocation the location of the properties file that contains the users (i.e. "classpath:users.properties") * @return the UserDetailsResourceFactoryBean @@ -64,7 +64,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBean } /** - * Sets a a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resource the Resource to use */ diff --git a/config/src/main/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBean.java b/config/src/main/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBean.java index 041978707d..f6496a8c91 100644 --- a/config/src/main/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBean.java +++ b/config/src/main/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBean.java @@ -101,7 +101,7 @@ public class UserDetailsResourceFactoryBean implements ResourceLoaderAware, Fact } /** - * Sets a the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resourceLocation the location of the properties file that contains the users (i.e. "classpath:users.properties") */ @@ -110,7 +110,7 @@ public class UserDetailsResourceFactoryBean implements ResourceLoaderAware, Fact } /** - * Sets a a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resource the Resource to use */ diff --git a/config/src/main/java/org/springframework/security/config/provisioning/UserDetailsManagerResourceFactoryBean.java b/config/src/main/java/org/springframework/security/config/provisioning/UserDetailsManagerResourceFactoryBean.java index 605595e0ca..abde185d7a 100644 --- a/config/src/main/java/org/springframework/security/config/provisioning/UserDetailsManagerResourceFactoryBean.java +++ b/config/src/main/java/org/springframework/security/config/provisioning/UserDetailsManagerResourceFactoryBean.java @@ -54,7 +54,7 @@ public class UserDetailsManagerResourceFactoryBean implements ResourceLoaderAwar } /** - * Sets a the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets the location of a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resourceLocation the location of the properties file that contains the users (i.e. "classpath:users.properties") * @return the UserDetailsResourceFactoryBean @@ -64,7 +64,7 @@ public class UserDetailsManagerResourceFactoryBean implements ResourceLoaderAwar } /** - * Sets a a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean} + * Sets a Resource that is a Properties file in the format defined in {@link UserDetailsResourceFactoryBean}. * * @param resource the Resource to use */ diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/userinfo/OAuth2UserAuthenticationToken.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/userinfo/OAuth2UserAuthenticationToken.java index a2011e9e87..7597ec0102 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/userinfo/OAuth2UserAuthenticationToken.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/userinfo/OAuth2UserAuthenticationToken.java @@ -31,7 +31,7 @@ import java.util.Collections; * that represents an OAuth 2.0 User {@link Authentication}. * *

- * This {@link Authentication} associates an {@link OAuth2User} principal to a + * This {@link Authentication} associates an {@link OAuth2User} principal to an * {@link OAuth2ClientAuthenticationToken} which represents the "Authorized Client". * * @author Joe Grandja diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcClientAuthenticationToken.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcClientAuthenticationToken.java index 23b01b19f4..173389b583 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcClientAuthenticationToken.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcClientAuthenticationToken.java @@ -23,7 +23,7 @@ import org.springframework.security.oauth2.oidc.core.IdToken; import org.springframework.util.Assert; /** - * A {@link OAuth2ClientAuthenticationToken} that represents an + * An {@link OAuth2ClientAuthenticationToken} that represents an * OpenID Connect 1.0 Client {@link Authentication}. * *

diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcUserAuthenticationToken.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcUserAuthenticationToken.java index fdf2e4fdf1..c476165fee 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcUserAuthenticationToken.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/oidc/client/authentication/OidcUserAuthenticationToken.java @@ -25,11 +25,11 @@ import java.util.Collection; import java.util.Collections; /** - * A {@link OAuth2UserAuthenticationToken} that represents an + * An {@link OAuth2UserAuthenticationToken} that represents an * OpenID Connect 1.0 User {@link Authentication}. * *

- * This {@link Authentication} associates an {@link OidcUser} principal to a + * This {@link Authentication} associates an {@link OidcUser} principal to an * {@link OidcClientAuthenticationToken} which represents the "Authorized Client". * * @author Joe Grandja diff --git a/test/src/main/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuilders.java b/test/src/main/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuilders.java index c11fe871c1..6012d899fb 100644 --- a/test/src/main/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuilders.java +++ b/test/src/main/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuilders.java @@ -217,7 +217,7 @@ public final class SecurityMockMvcRequestBuilders { } /** - * Specify a media type to to set as the Accept header in the request. + * Specify a media type to set as the Accept header in the request. * * @param acceptMediaType the {@link MediaType} to set the Accept header to. * Default is: MediaType.APPLICATION_FORM_URLENCODED diff --git a/webflux/src/main/java/org/springframework/security/web/server/DefaultServerRedirectStrategy.java b/webflux/src/main/java/org/springframework/security/web/server/DefaultServerRedirectStrategy.java index 4d78bd03ff..094b545780 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/DefaultServerRedirectStrategy.java +++ b/webflux/src/main/java/org/springframework/security/web/server/DefaultServerRedirectStrategy.java @@ -63,7 +63,7 @@ public class DefaultServerRedirectStrategy implements ServerRedirectStrategy { /** * Sets if the location is relative to the context. * @param contextRelative if redirects should be relative to the context. - Default is true. + * Default is true. */ public void setContextRelative(boolean contextRelative) { this.contextRelative = contextRelative; diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java index 9a54ae3810..3d29c8ce87 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java @@ -50,7 +50,7 @@ public class RedirectServerAuthenticationSuccessHandler } /** - * Where the user is redirected to upon AuthenticationSuccess + * Where the user is redirected to upon authentication success * @param location the location to redirect to. The default is "/" */ public void setLocation(URI location) { diff --git a/webflux/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java b/webflux/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java index b8f4008a30..4bf65714b2 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java @@ -23,8 +23,6 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.http.HttpStatus; import org.springframework.mock.http.server.reactive.MockServerHttpRequest; import org.springframework.mock.web.server.MockServerWebExchange; -import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; -import org.springframework.security.core.AuthenticationException; import org.springframework.web.server.ServerWebExchange; import java.net.URI; @@ -47,16 +45,14 @@ public class DefaultServerRedirectStrategyTests { private DefaultServerRedirectStrategy strategy = new DefaultServerRedirectStrategy(); - private AuthenticationException exception = new AuthenticationCredentialsNotFoundException("Authentication Required"); - @Test(expected = IllegalArgumentException.class) public void sendRedirectWhenLocationNullThenException() { - this.strategy.sendRedirect(this.exchange, (URI) null); + this.strategy.sendRedirect(this.exchange, null); } @Test(expected = IllegalArgumentException.class) public void sendRedirectWhenExchangeNullThenException() { - this.strategy.sendRedirect((ServerWebExchange) null, this.location); + this.strategy.sendRedirect(null, this.location); } @Test @@ -67,7 +63,7 @@ public class DefaultServerRedirectStrategyTests { } @Test - public void sendRedirectWhenNoContextThenStatusAndLocationSet() { + public void sendRedirectWhenNoContextPathThenStatusAndLocationSet() { this.exchange = exchange(MockServerHttpRequest.get("/")); this.strategy.sendRedirect(this.exchange, this.location).block(); @@ -122,7 +118,7 @@ public class DefaultServerRedirectStrategyTests { } @Test(expected = IllegalArgumentException.class) - public void setHttpStatusWhenNullLocationThenException() { + public void setHttpStatusWhenNullThenException() { this.strategy.setHttpStatus(null); } diff --git a/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java b/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java index d215bda6c0..9845d4d620 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java @@ -70,7 +70,6 @@ public class DelegatingServerAuthenticationEntryPointTests { Mono actualResult = this.entryPoint.commence(this.exchange, this.e); actualResult.block(); - assertThat(actualResult).isEqualTo(actualResult); verifyZeroInteractions(this.delegate1); verify(this.delegate2).commence(this.exchange, this.e); } @@ -86,6 +85,6 @@ public class DelegatingServerAuthenticationEntryPointTests { assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo( HttpStatus.UNAUTHORIZED); - verifyZeroInteractions(this.delegate1, this.delegate2); + verifyZeroInteractions(this.delegate1); } } diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java index 4d6a92e71e..a1f6e9e9aa 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java @@ -50,14 +50,14 @@ public class RedirectServerAuthenticationEntryPointTests { private String location = "/login"; private RedirectServerAuthenticationEntryPoint entryPoint = - new RedirectServerAuthenticationEntryPoint("/login"); + new RedirectServerAuthenticationEntryPoint(this.location); private AuthenticationException exception = new AuthenticationCredentialsNotFoundException("Authentication Required"); @Test(expected = IllegalArgumentException.class) public void constructorStringWhenNullLocationThenException() { - new RedirectServerAuthenticationEntryPoint((String) null); + new RedirectServerAuthenticationEntryPoint(null); } @Test @@ -80,10 +80,9 @@ public class RedirectServerAuthenticationEntryPointTests { } @Test - public void commenceWhenCustomStatusThenStatusSet() { + public void commenceWhenCustomServerRedirectStrategyThenCustomServerRedirectStrategyUsed() { Mono result = Mono.empty(); when(this.serverRedirectStrategy.sendRedirect(any(), any())).thenReturn(result); - HttpStatus status = HttpStatus.MOVED_PERMANENTLY; this.entryPoint.setServerRedirectStrategy(this.serverRedirectStrategy); this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").build()); diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java index 76480a6eab..6f6aedbbef 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java @@ -62,7 +62,7 @@ public class RedirectServerAuthenticationSuccessHandlerTests { @Test(expected = IllegalArgumentException.class) public void constructorStringWhenNullLocationThenException() { - new RedirectServerAuthenticationEntryPoint((String) null); + new RedirectServerAuthenticationEntryPoint(null); } @Test