Apply Checkstyle WhitespaceAfterCheck module

This commit is contained in:
Johnny Lim 2017-11-16 06:19:44 +09:00 committed by Rob Winch
parent 523332d51f
commit b6895e6359
88 changed files with 811 additions and 808 deletions

View File

@ -495,7 +495,7 @@ public class AclImplTests {
assertThat(acl.isSidLoaded(Arrays.asList(new GrantedAuthoritySid("ROLE_IGNORED"), assertThat(acl.isSidLoaded(Arrays.asList(new GrantedAuthoritySid("ROLE_IGNORED"),
new PrincipalSid("ben")))) new PrincipalSid("ben"))))
.isTrue(); .isTrue();
assertThat(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid( assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid(
"ROLE_IGNORED")))) "ROLE_IGNORED"))))
.isTrue(); .isTrue();
assertThat(acl.isSidLoaded(BEN)).isTrue(); assertThat(acl.isSidLoaded(BEN)).isTrue();
@ -507,7 +507,7 @@ public class AclImplTests {
assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid( assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid(
"ROLE_GENERAL"), new GrantedAuthoritySid("ROLE_IGNORED")))) "ROLE_GENERAL"), new GrantedAuthoritySid("ROLE_IGNORED"))))
.isFalse(); .isFalse();
assertThat(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid( assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid(
"ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_GENERAL")))) "ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_GENERAL"))))
.isFalse(); .isFalse();
} }

View File

@ -124,7 +124,7 @@ public class CasAuthenticationTokenMixinTests {
@Test @Test
public void deserializeCasAuthenticationTestAfterEraseCredentialInvoked() throws Exception { public void deserializeCasAuthenticationTestAfterEraseCredentialInvoked() throws Exception {
CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_CLEARED_JSON, CasAuthenticationToken.class); CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_CLEARED_JSON, CasAuthenticationToken.class);
assertThat(((UserDetails)token.getPrincipal()).getPassword()).isNull(); assertThat(((UserDetails) token.getPrincipal()).getPassword()).isNull();
} }
@Test @Test

View File

@ -64,7 +64,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
private String groupSearchFilter = "(uniqueMember={0})"; private String groupSearchFilter = "(uniqueMember={0})";
private String rolePrefix = "ROLE_"; private String rolePrefix = "ROLE_";
private String userSearchBase = ""; // only for search private String userSearchBase = ""; // only for search
private String userSearchFilter = null;// "uid={0}"; // only for search private String userSearchFilter = null; // "uid={0}"; // only for search
private String[] userDnPatterns; private String[] userDnPatterns;
private BaseLdapPathContextSource contextSource; private BaseLdapPathContextSource contextSource;
private ContextSourceBuilder contextSourceBuilder = new ContextSourceBuilder(); private ContextSourceBuilder contextSourceBuilder = new ContextSourceBuilder();

View File

@ -50,7 +50,7 @@ class MethodSecurityMetadataSourceAdvisorRegistrar implements
advisor.addConstructorArgReference("methodSecurityMetadataSource"); advisor.addConstructorArgReference("methodSecurityMetadataSource");
advisor.addConstructorArgValue("methodSecurityMetadataSource"); advisor.addConstructorArgValue("methodSecurityMetadataSource");
MultiValueMap<String,Object> attributes = importingClassMetadata.getAllAnnotationAttributes(EnableGlobalMethodSecurity.class.getName()); MultiValueMap<String, Object> attributes = importingClassMetadata.getAllAnnotationAttributes(EnableGlobalMethodSecurity.class.getName());
Integer order = (Integer) attributes.getFirst("order"); Integer order = (Integer) attributes.getFirst("order");
if(order != null) { if(order != null) {
advisor.addPropertyValue("order", order); advisor.addPropertyValue("order", order);
@ -59,4 +59,4 @@ class MethodSecurityMetadataSourceAdvisorRegistrar implements
registry.registerBeanDefinition("metaDataSourceAdvisor", registry.registerBeanDefinition("metaDataSourceAdvisor",
advisor.getBeanDefinition()); advisor.getBeanDefinition());
} }
} }

View File

@ -201,7 +201,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
// @formatter:off // @formatter:off
http http
.authenticationProvider(authenticationProvider) .authenticationProvider(authenticationProvider)
.setSharedObject(AuthenticationEntryPoint.class,new Http403ForbiddenEntryPoint()); .setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
// @formatter:on // @formatter:on
} }
@ -259,4 +259,4 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
detailsSource = postProcess(detailsSource); detailsSource = postProcess(detailsSource);
return detailsSource; return detailsSource;
} }
} }

View File

@ -163,7 +163,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
http http
.authenticationProvider(authenticationProvider) .authenticationProvider(authenticationProvider)
.setSharedObject(AuthenticationEntryPoint.class,new Http403ForbiddenEntryPoint()); .setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
} }
// @formatter:on // @formatter:on
@ -201,4 +201,4 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
return authenticationUserDetailsService; return authenticationUserDetailsService;
} }
} }

View File

@ -57,7 +57,7 @@ public class UserDetailsResourceFactoryBean implements ResourceLoaderAware, Fact
@Override @Override
public void setResourceLoader(ResourceLoader resourceLoader) { public void setResourceLoader(ResourceLoader resourceLoader) {
Assert.notNull(resourceLoader,"resourceLoader cannot be null"); Assert.notNull(resourceLoader, "resourceLoader cannot be null");
this.resourceLoader = resourceLoader; this.resourceLoader = resourceLoader;
} }

View File

@ -836,7 +836,7 @@ final class AuthenticationConfigBuilder {
} }
private static class CsrfTokenHiddenInputFunction implements private static class CsrfTokenHiddenInputFunction implements
Function<HttpServletRequest,Map<String,String>> { Function<HttpServletRequest, Map<String, String>> {
@Override @Override
public Map<String, String> apply(HttpServletRequest request) { public Map<String, String> apply(HttpServletRequest request) {

View File

@ -261,7 +261,7 @@ public class ServerHttpSecurity {
List<WebFilter> sortedWebFilters = new ArrayList<>(); List<WebFilter> sortedWebFilters = new ArrayList<>();
this.webFilters.forEach( f -> { this.webFilters.forEach( f -> {
if(f instanceof OrderedWebFilter) { if(f instanceof OrderedWebFilter) {
f = ((OrderedWebFilter)f).webFilter; f = ((OrderedWebFilter) f).webFilter;
} }
sortedWebFilters.add(f); sortedWebFilters.add(f);
}); });
@ -354,11 +354,11 @@ public class ServerHttpSecurity {
public final class Access { public final class Access {
public AuthorizeExchangeSpec permitAll() { public AuthorizeExchangeSpec permitAll() {
return access( (a,e) -> Mono.just(new AuthorizationDecision(true))); return access( (a, e) -> Mono.just(new AuthorizationDecision(true)));
} }
public AuthorizeExchangeSpec denyAll() { public AuthorizeExchangeSpec denyAll() {
return access( (a,e) -> Mono.just(new AuthorizationDecision(false))); return access( (a, e) -> Mono.just(new AuthorizationDecision(false)));
} }
public AuthorizeExchangeSpec hasRole(String role) { public AuthorizeExchangeSpec hasRole(String role) {

View File

@ -26,7 +26,7 @@ public class DisableUseExpressionsConfig extends BaseWebConfig {
// This config is also on UrlAuthorizationConfigurer javadoc // This config is also on UrlAuthorizationConfigurer javadoc
http http
.apply(new UrlAuthorizationConfigurer<HttpSecurity>(getApplicationContext())).getRegistry() .apply(new UrlAuthorizationConfigurer<HttpSecurity>(getApplicationContext())).getRegistry()
.antMatchers("/users**","/sessions/**").hasRole("USER") .antMatchers("/users**", "/sessions/**").hasRole("USER")
.antMatchers("/signup").hasRole("ANONYMOUS") .antMatchers("/signup").hasRole("ANONYMOUS")
.anyRequest().hasRole("USER"); .anyRequest().hasRole("USER");
} }

View File

@ -59,7 +59,7 @@ public class ExpressionUrlAuthorizationConfigurerConfigs {
.expressionHandler(handler) .expressionHandler(handler)
.accessDecisionManager(adm) .accessDecisionManager(adm)
.filterSecurityInterceptorOncePerRequest(true) .filterSecurityInterceptorOncePerRequest(true)
.antMatchers("/a","/b").hasRole("ADMIN") .antMatchers("/a", "/b").hasRole("ADMIN")
.anyRequest().permitAll() .anyRequest().permitAll()
.and() .and()
.formLogin(); .formLogin();

View File

@ -47,8 +47,8 @@ public class EnableReactiveMethodSecurityTests {
ReactiveMessageService delegate; ReactiveMessageService delegate;
TestPublisher<String> result = TestPublisher.create(); TestPublisher<String> result = TestPublisher.create();
Context withAdmin = ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("admin","password","ROLE_USER", "ROLE_ADMIN")); Context withAdmin = ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("admin", "password", "ROLE_USER", "ROLE_ADMIN"));
Context withUser = ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("user","password","ROLE_USER")); Context withUser = ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
@After @After
public void cleanup() { public void cleanup() {

View File

@ -70,7 +70,7 @@ public class HttpSecurityHeadersTests {
public void headerWhenSpringMvcResourceThenCacheRelatedHeadersReset() throws Exception { public void headerWhenSpringMvcResourceThenCacheRelatedHeadersReset() throws Exception {
mockMvc.perform(get("/resources/file.js")) mockMvc.perform(get("/resources/file.js"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(header().string(HttpHeaders.CACHE_CONTROL,"max-age=12345")) .andExpect(header().string(HttpHeaders.CACHE_CONTROL, "max-age=12345"))
.andExpect(header().string(HttpHeaders.PRAGMA, "")) .andExpect(header().string(HttpHeaders.PRAGMA, ""))
.andExpect(header().string(HttpHeaders.EXPIRES, "")); .andExpect(header().string(HttpHeaders.EXPIRES, ""));
} }
@ -78,7 +78,7 @@ public class HttpSecurityHeadersTests {
@Test @Test
public void headerWhenNotSpringResourceThenCacheRelatedHeadersSet() throws Exception { public void headerWhenNotSpringResourceThenCacheRelatedHeadersSet() throws Exception {
mockMvc.perform(get("/notresource")) mockMvc.perform(get("/notresource"))
.andExpect(header().string(HttpHeaders.CACHE_CONTROL,"no-cache, no-store, max-age=0, must-revalidate")) .andExpect(header().string(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0, must-revalidate"))
.andExpect(header().string(HttpHeaders.PRAGMA, "no-cache")) .andExpect(header().string(HttpHeaders.PRAGMA, "no-cache"))
.andExpect(header().string(HttpHeaders.EXPIRES, "0")); .andExpect(header().string(HttpHeaders.EXPIRES, "0"));
} }

View File

@ -79,7 +79,7 @@ public class WebSecurityConfigurerAdapterPowermockTests {
} }
} }
static class DefaultConfigurer extends AbstractHttpConfigurer<DefaultConfigurer,HttpSecurity> { static class DefaultConfigurer extends AbstractHttpConfigurer<DefaultConfigurer, HttpSecurity> {
boolean init; boolean init;
boolean configure; boolean configure;

View File

@ -70,7 +70,7 @@ public class HttpSecurityLogoutTests {
loadConfig(ClearAuthenticationFalseConfig.class); loadConfig(ClearAuthenticationFalseConfig.class);
SecurityContext currentContext = SecurityContextHolder.createEmptyContext(); SecurityContext currentContext = SecurityContextHolder.createEmptyContext();
currentContext.setAuthentication(new TestingAuthenticationToken("user", "password","ROLE_USER")); currentContext.setAuthentication(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, currentContext); request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, currentContext);
request.setMethod("POST"); request.setMethod("POST");

View File

@ -134,7 +134,7 @@ public class EnableWebFluxSecurityTests {
.switchIfEmpty(chain.filter(exchange)) .switchIfEmpty(chain.filter(exchange))
.flatMap(e -> chain.filter(exchange)), .flatMap(e -> chain.filter(exchange)),
this.springSecurityFilterChain, this.springSecurityFilterChain,
(exchange,chain) -> (exchange, chain) ->
ReactiveSecurityContextHolder.getContext() ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication) .map(SecurityContext::getAuthentication)
.flatMap( principal -> exchange.getResponse() .flatMap( principal -> exchange.getResponse()
@ -154,7 +154,7 @@ public class EnableWebFluxSecurityTests {
this.spring.register(Config.class).autowire(); this.spring.register(Config.class).autowire();
WebTestClient client = WebTestClientBuilder.bindToWebFilters( WebTestClient client = WebTestClientBuilder.bindToWebFilters(
this.springSecurityFilterChain, this.springSecurityFilterChain,
(exchange,chain) -> (exchange, chain) ->
ReactiveSecurityContextHolder.getContext() ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication) .map(SecurityContext::getAuthentication)
.flatMap( principal -> exchange.getResponse() .flatMap( principal -> exchange.getResponse()
@ -166,7 +166,7 @@ public class EnableWebFluxSecurityTests {
client client
.get() .get()
.uri("/") .uri("/")
.attributes(basicAuthenticationCredentials("user","password")) .attributes(basicAuthenticationCredentials("user", "password"))
.exchange() .exchange()
.expectStatus().isOk() .expectStatus().isOk()
.expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user")); .expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user"));
@ -191,7 +191,7 @@ public class EnableWebFluxSecurityTests {
this.spring.register(CustomPasswordEncoderConfig.class).autowire(); this.spring.register(CustomPasswordEncoderConfig.class).autowire();
WebTestClient client = WebTestClientBuilder.bindToWebFilters( WebTestClient client = WebTestClientBuilder.bindToWebFilters(
this.springSecurityFilterChain, this.springSecurityFilterChain,
(exchange,chain) -> (exchange, chain) ->
ReactiveSecurityContextHolder.getContext() ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication) .map(SecurityContext::getAuthentication)
.flatMap( principal -> exchange.getResponse() .flatMap( principal -> exchange.getResponse()
@ -203,7 +203,7 @@ public class EnableWebFluxSecurityTests {
client client
.get() .get()
.uri("/") .uri("/")
.attributes(basicAuthenticationCredentials("user","password")) .attributes(basicAuthenticationCredentials("user", "password"))
.exchange() .exchange()
.expectStatus().isOk() .expectStatus().isOk()
.expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user")); .expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user"));
@ -231,7 +231,7 @@ public class EnableWebFluxSecurityTests {
this.spring.register(Config.class).autowire(); this.spring.register(Config.class).autowire();
WebTestClient client = WebTestClientBuilder.bindToWebFilters( WebTestClient client = WebTestClientBuilder.bindToWebFilters(
this.springSecurityFilterChain, this.springSecurityFilterChain,
(exchange,chain) -> (exchange, chain) ->
Mono.subscriberContext() Mono.subscriberContext()
.flatMap( c -> c.<Mono<Principal>>get(Authentication.class)) .flatMap( c -> c.<Mono<Principal>>get(Authentication.class))
.flatMap( principal -> exchange.getResponse() .flatMap( principal -> exchange.getResponse()

View File

@ -91,7 +91,7 @@ public class JdbcUserServiceBeanDefinitionParserTests {
+ "'/>" + DATA_SOURCE); + "'/>" + DATA_SOURCE);
JdbcUserDetailsManager mgr = (JdbcUserDetailsManager) appContext JdbcUserDetailsManager mgr = (JdbcUserDetailsManager) appContext
.getBean("myUserService"); .getBean("myUserService");
assertThat(FieldUtils.getFieldValue(mgr,"usersByUsernameQuery")).isEqualTo(userQuery); assertThat(FieldUtils.getFieldValue(mgr, "usersByUsernameQuery")).isEqualTo(userQuery);
assertThat(FieldUtils.getFieldValue(mgr, "authoritiesByUsernameQuery")).isEqualTo(authoritiesQuery); assertThat(FieldUtils.getFieldValue(mgr, "authoritiesByUsernameQuery")).isEqualTo(authoritiesQuery);
assertThat(mgr.loadUserByUsername("rod") != null).isTrue(); assertThat(mgr.loadUserByUsername("rod") != null).isTrue();
} }

View File

@ -57,7 +57,7 @@ public class HttpInterceptUrlTests {
} }
private void loadConfig(String... configLocations) { private void loadConfig(String... configLocations) {
for(int i=0;i<configLocations.length;i++) { for(int i=0; i<configLocations.length; i++) {
configLocations[i] = getClass().getName().replaceAll("\\.", "/") + "-" + configLocations[i]; configLocations[i] = getClass().getName().replaceAll("\\.", "/") + "-" + configLocations[i];
} }
XmlWebApplicationContext context = new XmlWebApplicationContext(); XmlWebApplicationContext context = new XmlWebApplicationContext();

View File

@ -26,7 +26,7 @@ import org.springframework.security.web.DefaultSecurityFilterChain;
* @author Rob Winch * @author Rob Winch
* *
*/ */
public class CustomConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain,HttpSecurity> { public class CustomConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
@Value("${permitAllPattern}") @Value("${permitAllPattern}")
private String permitAllPattern; private String permitAllPattern;
@ -64,4 +64,4 @@ public class CustomConfigurer extends SecurityConfigurerAdapter<DefaultSecurityF
public static CustomConfigurer customConfigurer() { public static CustomConfigurer customConfigurer() {
return new CustomConfigurer(); return new CustomConfigurer();
} }
} }

View File

@ -134,7 +134,7 @@ public class HeaderSpecTests {
.exchange() .exchange()
.returnResult(String.class); .returnResult(String.class);
Map<String,List<String>> responseHeaders = response.getResponseHeaders(); Map<String, List<String>> responseHeaders = response.getResponseHeaders();
this.ignoredHeaderNames.stream().forEach(responseHeaders::remove); this.ignoredHeaderNames.stream().forEach(responseHeaders::remove);
assertThat(responseHeaders).describedAs(response.toString()).isEqualTo( assertThat(responseHeaders).describedAs(response.toString()).isEqualTo(

View File

@ -85,8 +85,8 @@ final class HtmlUnitWebTestClient {
return request.body(BodyInserters.fromObject(requestBody)); return request.body(BodyInserters.fromObject(requestBody));
} }
private MultiValueMap<String,String> formData(List<NameValuePair> params) { private MultiValueMap<String, String> formData(List<NameValuePair> params) {
MultiValueMap<String,String> result = new LinkedMultiValueMap<>(params.size()); MultiValueMap<String, String> result = new LinkedMultiValueMap<>(params.size());
params.forEach( pair -> result.add(pair.getName(), pair.getValue())); params.forEach( pair -> result.add(pair.getName(), pair.getValue()));
return result; return result;
} }
@ -129,7 +129,7 @@ final class HtmlUnitWebTestClient {
} }
private void headers(WebTestClient.RequestBodySpec request, WebRequest webRequest) { private void headers(WebTestClient.RequestBodySpec request, WebRequest webRequest) {
webRequest.getAdditionalHeaders().forEach( (name,value) -> request.header(name, value)); webRequest.getAdditionalHeaders().forEach( (name, value) -> request.header(name, value));
} }
private HttpMethod httpMethod(WebRequest webRequest) { private HttpMethod httpMethod(WebRequest webRequest) {
@ -191,8 +191,8 @@ final class HtmlUnitWebTestClient {
}).build(); }).build();
} }
private MultiValueMap<String,String> clientCookies() { private MultiValueMap<String, String> clientCookies() {
MultiValueMap<String,String> result = new LinkedMultiValueMap<>(this.cookies.size()); MultiValueMap<String, String> result = new LinkedMultiValueMap<>(this.cookies.size());
this.cookies.values().forEach( cookie -> this.cookies.values().forEach( cookie ->
result.add(cookie.getName(), cookie.getValue()) result.add(cookie.getName(), cookie.getValue())
); );

View File

@ -47,7 +47,7 @@ public class ReactiveSecurityContextHolder {
* @return Return a {@code Mono<Void>} which only replays complete and error signals * @return Return a {@code Mono<Void>} which only replays complete and error signals
* from clearing the context. * from clearing the context.
*/ */
public static Function<Context,Context> clearContext() { public static Function<Context, Context> clearContext() {
return context -> context.delete(SECURITY_CONTEXT_KEY); return context -> context.delete(SECURITY_CONTEXT_KEY);
} }

View File

@ -60,7 +60,7 @@ public class SessionRegistryImpl implements SessionRegistry,
this.sessionIds = new ConcurrentHashMap<String, SessionInformation>(); this.sessionIds = new ConcurrentHashMap<String, SessionInformation>();
} }
public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals,Map<String, SessionInformation> sessionIds) { public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals, Map<String, SessionInformation> sessionIds) {
this.principals=principals; this.principals=principals;
this.sessionIds=sessionIds; this.sessionIds=sessionIds;
} }

View File

@ -31,9 +31,9 @@ import reactor.core.publisher.Mono;
* @since 5.0 * @since 5.0
*/ */
public class MapReactiveUserDetailsService implements ReactiveUserDetailsService { public class MapReactiveUserDetailsService implements ReactiveUserDetailsService {
private final Map<String,UserDetails> users; private final Map<String, UserDetails> users;
public MapReactiveUserDetailsService(Map<String,UserDetails> users) { public MapReactiveUserDetailsService(Map<String, UserDetails> users) {
this.users = users; this.users = users;
} }

View File

@ -293,7 +293,7 @@ public class User implements UserDetails, CredentialsContainer {
private boolean accountLocked; private boolean accountLocked;
private boolean credentialsExpired; private boolean credentialsExpired;
private boolean disabled; private boolean disabled;
private Function<String,String> passwordEncoder = password -> password; private Function<String, String> passwordEncoder = password -> password;
/** /**
* Creates a new instance * Creates a new instance
@ -335,7 +335,7 @@ public class User implements UserDetails, CredentialsContainer {
* @return the {@link UserBuilder} for method chaining (i.e. to populate * @return the {@link UserBuilder} for method chaining (i.e. to populate
* additional attributes for this user) * additional attributes for this user)
*/ */
public UserBuilder passwordEncoder(Function<String,String> encoder) { public UserBuilder passwordEncoder(Function<String, String> encoder) {
Assert.notNull(encoder, "encoder cannot be null"); Assert.notNull(encoder, "encoder cannot be null");
this.passwordEncoder = encoder; this.passwordEncoder = encoder;
return this; return this;

View File

@ -248,7 +248,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
class CustomAnnotatedServiceImpl implements CustomAnnotatedService { class CustomAnnotatedServiceImpl implements CustomAnnotatedService {
} }
enum SecurityEnum implements ConfigAttribute,GrantedAuthority { enum SecurityEnum implements ConfigAttribute, GrantedAuthority {
ADMIN, USER; ADMIN, USER;
public String getAttribute() { public String getAttribute() {

View File

@ -88,7 +88,7 @@ public class MethodExpressionVoterTests {
am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute( am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute(
"(filterObject == 'joe' or filterObject == 'sam')", "collection", "(filterObject == 'joe' or filterObject == 'sam')", "collection",
"permitAll"))); "permitAll")));
assertThat(arg).containsExactly("joe","sam"); assertThat(arg).containsExactly("joe", "sam");
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)

View File

@ -85,8 +85,8 @@ public class SpringSecurityCoreVersionTests {
String version = "1"; String version = "1";
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn(version).when(SpringSecurityCoreVersion.class,"getVersion"); doReturn(version).when(SpringSecurityCoreVersion.class, "getVersion");
doReturn(version).when(SpringVersion.class,"getVersion"); doReturn(version).when(SpringVersion.class, "getVersion");
performChecks(); performChecks();
@ -97,8 +97,8 @@ public class SpringSecurityCoreVersionTests {
public void noLoggingIfSpringVersionNull() throws Exception { public void noLoggingIfSpringVersionNull() throws Exception {
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn("1").when(SpringSecurityCoreVersion.class,"getVersion"); doReturn("1").when(SpringSecurityCoreVersion.class, "getVersion");
doReturn(null).when(SpringVersion.class,"getVersion"); doReturn(null).when(SpringVersion.class, "getVersion");
performChecks(); performChecks();
@ -109,8 +109,8 @@ public class SpringSecurityCoreVersionTests {
public void warnIfSpringVersionTooSmall() throws Exception { public void warnIfSpringVersionTooSmall() throws Exception {
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn("3").when(SpringSecurityCoreVersion.class,"getVersion"); doReturn("3").when(SpringSecurityCoreVersion.class, "getVersion");
doReturn("2").when(SpringVersion.class,"getVersion"); doReturn("2").when(SpringVersion.class, "getVersion");
performChecks(); performChecks();
@ -121,8 +121,8 @@ public class SpringSecurityCoreVersionTests {
public void noWarnIfSpringVersionLarger() throws Exception { public void noWarnIfSpringVersionLarger() throws Exception {
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn("4.0.0.RELEASE").when(SpringSecurityCoreVersion.class,"getVersion"); doReturn("4.0.0.RELEASE").when(SpringSecurityCoreVersion.class, "getVersion");
doReturn("4.0.0.RELEASE").when(SpringVersion.class,"getVersion"); doReturn("4.0.0.RELEASE").when(SpringVersion.class, "getVersion");
performChecks(); performChecks();
@ -135,8 +135,8 @@ public class SpringSecurityCoreVersionTests {
String minSpringVersion = "3.2.8.RELEASE"; String minSpringVersion = "3.2.8.RELEASE";
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn("3.2.0.RELEASE").when(SpringSecurityCoreVersion.class,"getVersion"); doReturn("3.2.0.RELEASE").when(SpringSecurityCoreVersion.class, "getVersion");
doReturn("3.2.10.RELEASE").when(SpringVersion.class,"getVersion"); doReturn("3.2.10.RELEASE").when(SpringVersion.class, "getVersion");
performChecks(minSpringVersion); performChecks(minSpringVersion);
@ -147,8 +147,8 @@ public class SpringSecurityCoreVersionTests {
public void noLoggingIfPropertySet() throws Exception { public void noLoggingIfPropertySet() throws Exception {
spy(SpringSecurityCoreVersion.class); spy(SpringSecurityCoreVersion.class);
spy(SpringVersion.class); spy(SpringVersion.class);
doReturn("3").when(SpringSecurityCoreVersion.class,"getVersion"); doReturn("3").when(SpringSecurityCoreVersion.class, "getVersion");
doReturn("2").when(SpringVersion.class,"getVersion"); doReturn("2").when(SpringVersion.class, "getVersion");
System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString()); System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString());
performChecks(); performChecks();

View File

@ -25,7 +25,7 @@ import java.util.function.Function;
public class PasswordEncodedUser { public class PasswordEncodedUser {
private static final UserDetails USER = withUsername("user").password("password").roles("USER").build(); private static final UserDetails USER = withUsername("user").password("password").roles("USER").build();
private static final UserDetails ADMIN = withUsername("admin").password("password").roles("USER","ADMIN").build(); private static final UserDetails ADMIN = withUsername("admin").password("password").roles("USER", "ADMIN").build();
public static UserDetails user() { public static UserDetails user() {
return User.withUserDetails(USER).build(); return User.withUserDetails(USER).build();
@ -48,7 +48,7 @@ public class PasswordEncodedUser {
.passwordEncoder(passwordEncoder()); .passwordEncoder(passwordEncoder());
} }
private static Function<String,String> passwordEncoder() { private static Function<String, String> passwordEncoder() {
return rawPassword -> "{noop}" + rawPassword; return rawPassword -> "{noop}" + rawPassword;
} }

View File

@ -150,7 +150,7 @@ public class UserTests {
@Test @Test
public void withUserDetailsWhenAllEnabled() throws Exception { public void withUserDetailsWhenAllEnabled() throws Exception {
User expected = new User("rob","pass", true, true, true, true, ROLE_12); User expected = new User("rob", "pass", true, true, true, true, ROLE_12);
UserDetails actual = User.withUserDetails(expected).build(); UserDetails actual = User.withUserDetails(expected).build();
@ -166,7 +166,7 @@ public class UserTests {
@Test @Test
public void withUserDetailsWhenAllDisabled() throws Exception { public void withUserDetailsWhenAllDisabled() throws Exception {
User expected = new User("rob","pass", false, false, false, false, ROLE_12); User expected = new User("rob", "pass", false, false, false, false, ROLE_12);
UserDetails actual = User.withUserDetails(expected).build(); UserDetails actual = User.withUserDetails(expected).build();

View File

@ -107,8 +107,8 @@ public class RememberMeAuthenticationTokenMixinTests extends AbstractMixinTests
.readValue(String.format(REMEMBERME_AUTH_JSON, "\"password\""), RememberMeAuthenticationToken.class); .readValue(String.format(REMEMBERME_AUTH_JSON, "\"password\""), RememberMeAuthenticationToken.class);
assertThat(token).isNotNull(); assertThat(token).isNotNull();
assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class); assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class);
assertThat(((User)token.getPrincipal()).getUsername()).isEqualTo("admin"); assertThat(((User) token.getPrincipal()).getUsername()).isEqualTo("admin");
assertThat(((User)token.getPrincipal()).getPassword()).isEqualTo("1234"); assertThat(((User) token.getPrincipal()).getPassword()).isEqualTo("1234");
assertThat(((User) token.getPrincipal()).getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER")); assertThat(((User) token.getPrincipal()).getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER"));
assertThat(token.getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER")); assertThat(token.getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER"));
assertThat(((User) token.getPrincipal()).isEnabled()).isEqualTo(true); assertThat(((User) token.getPrincipal()).isEnabled()).isEqualTo(true);

View File

@ -120,7 +120,7 @@ public class UsernamePasswordAuthenticationTokenMixinTests extends AbstractMixin
.readValue(AUTHENTICATED_JSON, UsernamePasswordAuthenticationToken.class); .readValue(AUTHENTICATED_JSON, UsernamePasswordAuthenticationToken.class);
assertThat(token).isNotNull(); assertThat(token).isNotNull();
assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class); assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class);
assertThat(((User)token.getPrincipal()).getAuthorities()).isNotNull().hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER")); assertThat(((User) token.getPrincipal()).getAuthorities()).isNotNull().hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER"));
assertThat(token.isAuthenticated()).isEqualTo(true); assertThat(token.isAuthenticated()).isEqualTo(true);
assertThat(token.getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER")); assertThat(token.getAuthorities()).hasSize(1).contains(new SimpleGrantedAuthority("ROLE_USER"));
} }

View File

@ -60,7 +60,7 @@ public class PasswordEncoderFactories {
*/ */
public static PasswordEncoder createDelegatingPasswordEncoder() { public static PasswordEncoder createDelegatingPasswordEncoder() {
String encodingId = "bcrypt"; String encodingId = "bcrypt";
Map<String,PasswordEncoder> encoders = new HashMap<>(); Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put(encodingId, new BCryptPasswordEncoder()); encoders.put(encodingId, new BCryptPasswordEncoder());
encoders.put("ldap", new LdapShaPasswordEncoder()); encoders.put("ldap", new LdapShaPasswordEncoder());
encoders.put("MD4", new Md4PasswordEncoder()); encoders.put("MD4", new Md4PasswordEncoder());

View File

@ -123,7 +123,7 @@ public class DelegatingPasswordEncoder implements PasswordEncoder {
private static final String SUFFIX = "}"; private static final String SUFFIX = "}";
private final String idForEncode; private final String idForEncode;
private final PasswordEncoder passwordEncoderForEncode; private final PasswordEncoder passwordEncoderForEncode;
private final Map<String,PasswordEncoder> idToPasswordEncoder; private final Map<String, PasswordEncoder> idToPasswordEncoder;
private PasswordEncoder defaultPasswordEncoderForMatches = new UnmappedIdPasswordEncoder(); private PasswordEncoder defaultPasswordEncoderForMatches = new UnmappedIdPasswordEncoder();
/** /**

View File

@ -34,7 +34,7 @@ public class HexTests {
@Test @Test
public void encode() { public void encode() {
assertThat(Hex.encode(new byte[] { (byte) 'A', (byte) 'B', (byte) 'C', assertThat(Hex.encode(new byte[] { (byte) 'A', (byte) 'B', (byte) 'C',
(byte) 'D' })).isEqualTo(new char[] {'4','1','4','2','4','3','4','4'}); (byte) 'D' })).isEqualTo(new char[] {'4', '1', '4', '2', '4', '3', '4', '4'});
} }
@Test @Test

View File

@ -55,7 +55,7 @@ public class DelegatingPasswordEncoderTests {
private String noopEncodedPassword = "{noop}" + this.encodedPassword; private String noopEncodedPassword = "{noop}" + this.encodedPassword;
private Map<String,PasswordEncoder> delegates; private Map<String, PasswordEncoder> delegates;
private DelegatingPasswordEncoder passwordEncoder; private DelegatingPasswordEncoder passwordEncoder;

View File

@ -100,7 +100,7 @@ public class LdapShaPasswordEncoderTests {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidPrefixIsRejected() { public void invalidPrefixIsRejected() {
this.sha.matches("somepassword","{MD9}xxxxxxxxxx"); this.sha.matches("somepassword", "{MD9}xxxxxxxxxx");
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)

View File

@ -1,120 +1,120 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.security.crypto.scrypt; package org.springframework.security.crypto.scrypt;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.Test; import org.junit.Test;
/** /**
* @author Shazin Sadakath * @author Shazin Sadakath
* *
*/ */
public class SCryptPasswordEncoderTests { public class SCryptPasswordEncoderTests {
@Test @Test
public void matches() { public void matches() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
String result = encoder.encode("password"); String result = encoder.encode("password");
assertThat(result).isNotEqualTo("password"); assertThat(result).isNotEqualTo("password");
assertThat(encoder.matches("password", result)).isTrue(); assertThat(encoder.matches("password", result)).isTrue();
} }
@Test @Test
public void unicode() { public void unicode() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
String result = encoder.encode("passw\u9292rd"); String result = encoder.encode("passw\u9292rd");
assertThat(encoder.matches("pass\u9292\u9292rd", result)).isFalse(); assertThat(encoder.matches("pass\u9292\u9292rd", result)).isFalse();
assertThat(encoder.matches("passw\u9292rd", result)).isTrue(); assertThat(encoder.matches("passw\u9292rd", result)).isTrue();
} }
@Test @Test
public void notMatches() { public void notMatches() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
String result = encoder.encode("password"); String result = encoder.encode("password");
assertThat(encoder.matches("bogus", result)).isFalse(); assertThat(encoder.matches("bogus", result)).isFalse();
} }
@Test @Test
public void customParameters() { public void customParameters() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(512, 8, 4, 32, 16); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(512, 8, 4, 32, 16);
String result = encoder.encode("password"); String result = encoder.encode("password");
assertThat(result).isNotEqualTo("password"); assertThat(result).isNotEqualTo("password");
assertThat(encoder.matches("password", result)).isTrue(); assertThat(encoder.matches("password", result)).isTrue();
} }
@Test @Test
public void differentPasswordHashes() { public void differentPasswordHashes() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
String password = "secret"; String password = "secret";
assertThat(encoder.encode(password)).isNotEqualTo(encoder.encode(password)); assertThat(encoder.encode(password)).isNotEqualTo(encoder.encode(password));
} }
@Test @Test
public void samePasswordWithDifferentParams() { public void samePasswordWithDifferentParams() {
SCryptPasswordEncoder oldEncoder = new SCryptPasswordEncoder(16384, 8, 1, 32,64); SCryptPasswordEncoder oldEncoder = new SCryptPasswordEncoder(16384, 8, 1, 32, 64);
SCryptPasswordEncoder newEncoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder newEncoder = new SCryptPasswordEncoder();
String password = "secret"; String password = "secret";
String oldEncodedPassword = oldEncoder.encode(password); String oldEncodedPassword = oldEncoder.encode(password);
assertThat(newEncoder.matches(password, oldEncodedPassword)).isTrue(); assertThat(newEncoder.matches(password, oldEncodedPassword)).isTrue();
} }
@Test @Test
public void doesntMatchNullEncodedValue() { public void doesntMatchNullEncodedValue() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
assertThat(encoder.matches("password", null)).isFalse(); assertThat(encoder.matches("password", null)).isFalse();
} }
@Test @Test
public void doesntMatchEmptyEncodedValue() { public void doesntMatchEmptyEncodedValue() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
assertThat(encoder.matches("password", "")).isFalse(); assertThat(encoder.matches("password", "")).isFalse();
} }
@Test @Test
public void doesntMatchBogusEncodedValue() { public void doesntMatchBogusEncodedValue() {
SCryptPasswordEncoder encoder = new SCryptPasswordEncoder(); SCryptPasswordEncoder encoder = new SCryptPasswordEncoder();
assertThat(encoder.matches("password", "012345678901234567890123456789")).isFalse(); assertThat(encoder.matches("password", "012345678901234567890123456789")).isFalse();
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidCpuCostParameter() { public void invalidCpuCostParameter() {
new SCryptPasswordEncoder(Integer.MIN_VALUE, 16, 2, 32, 16); new SCryptPasswordEncoder(Integer.MIN_VALUE, 16, 2, 32, 16);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidMemoryCostParameter() { public void invalidMemoryCostParameter() {
new SCryptPasswordEncoder(2, Integer.MAX_VALUE, 2, 32, 16); new SCryptPasswordEncoder(2, Integer.MAX_VALUE, 2, 32, 16);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidParallelizationParameter() { public void invalidParallelizationParameter() {
new SCryptPasswordEncoder(2, 8, Integer.MAX_VALUE, 32, 16); new SCryptPasswordEncoder(2, 8, Integer.MAX_VALUE, 32, 16);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidSaltLengthParameter() { public void invalidSaltLengthParameter() {
new SCryptPasswordEncoder(2, 8, 1, 16, -1); new SCryptPasswordEncoder(2, 8, 1, 16, -1);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void invalidKeyLengthParameter() { public void invalidKeyLengthParameter() {
new SCryptPasswordEncoder(2, 8, 1, -1, 16); new SCryptPasswordEncoder(2, 8, 1, -1, 16);
} }
} }

View File

@ -40,5 +40,8 @@
<property name="illegalPattern" value="true"/> <property name="illegalPattern" value="true"/>
<property name="message" value="Trailing whitespace"/> <property name="message" value="Trailing whitespace"/>
</module> </module>
<!-- Whitespace -->
<module name="WhitespaceAfterCheck" />
</module> </module>
</module> </module>

View File

@ -47,7 +47,7 @@ public class ConcurrentSessionManagementTests extends AbstractWebServerIntegrati
final MockHttpSession session1 = new MockHttpSession(); final MockHttpSession session1 = new MockHttpSession();
final MockHttpSession session2 = new MockHttpSession(); final MockHttpSession session2 = new MockHttpSession();
MockMvc mockMvc = createMockMvc("classpath:/spring/http-security-concurrency.xml","classpath:/spring/in-memory-provider.xml", "classpath:/spring/testapp-servlet.xml"); MockMvc mockMvc = createMockMvc("classpath:/spring/http-security-concurrency.xml", "classpath:/spring/in-memory-provider.xml", "classpath:/spring/testapp-servlet.xml");
mockMvc.perform(get("secure/index").session(session1)) mockMvc.perform(get("secure/index").session(session1))
.andExpect(status().is3xxRedirection()); .andExpect(status().is3xxRedirection());

View File

@ -127,7 +127,7 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic
return null; return null;
} }
if(passwordAttrValue instanceof byte[]) { if(passwordAttrValue instanceof byte[]) {
return new String((byte[])passwordAttrValue); return new String((byte[]) passwordAttrValue);
} }
return String.valueOf(passwordAttrValue); return String.valueOf(passwordAttrValue);
} }

View File

@ -49,7 +49,7 @@ public class LdapUtilsTests {
when(mockCtx.getNameInNamespace()).thenReturn("dc=springframework,dc=org"); when(mockCtx.getNameInNamespace()).thenReturn("dc=springframework,dc=org");
assertThat(LdapUtils.getRelativeName("dc=springframework,dc=org",mockCtx)).isEqualTo(""); assertThat(LdapUtils.getRelativeName("dc=springframework,dc=org", mockCtx)).isEqualTo("");
} }
@Test @Test

View File

@ -125,7 +125,7 @@ public class OAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFilt
String redirectUriStr = this.expandRedirectUri(request, clientRegistration); String redirectUriStr = this.expandRedirectUri(request, clientRegistration);
Map<String,Object> additionalParameters = new HashMap<>(); Map<String, Object> additionalParameters = new HashMap<>();
additionalParameters.put(OAuth2ParameterNames.REGISTRATION_ID, clientRegistration.getRegistrationId()); additionalParameters.put(OAuth2ParameterNames.REGISTRATION_ID, clientRegistration.getRegistrationId());
OAuth2AuthorizationRequest.Builder builder; OAuth2AuthorizationRequest.Builder builder;

View File

@ -117,7 +117,7 @@ public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProce
} }
this.authorizationRequestRepository.removeAuthorizationRequest(request); this.authorizationRequestRepository.removeAuthorizationRequest(request);
String registrationId = (String)authorizationRequest.getAdditionalParameters().get(OAuth2ParameterNames.REGISTRATION_ID); String registrationId = (String) authorizationRequest.getAdditionalParameters().get(OAuth2ParameterNames.REGISTRATION_ID);
ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId(registrationId); ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId(registrationId);
OAuth2LoginAuthenticationToken authenticationRequest = new OAuth2LoginAuthenticationToken( OAuth2LoginAuthenticationToken authenticationRequest = new OAuth2LoginAuthenticationToken(
@ -125,7 +125,7 @@ public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProce
authenticationRequest.setDetails(this.authenticationDetailsSource.buildDetails(request)); authenticationRequest.setDetails(this.authenticationDetailsSource.buildDetails(request));
OAuth2LoginAuthenticationToken authenticationResult = OAuth2LoginAuthenticationToken authenticationResult =
(OAuth2LoginAuthenticationToken)this.getAuthenticationManager().authenticate(authenticationRequest); (OAuth2LoginAuthenticationToken) this.getAuthenticationManager().authenticate(authenticationRequest);
OAuth2AuthenticationToken oauth2Authentication = new OAuth2AuthenticationToken( OAuth2AuthenticationToken oauth2Authentication = new OAuth2AuthenticationToken(
authenticationResult.getPrincipal(), authenticationResult.getPrincipal(),

View File

@ -119,7 +119,7 @@ public class OAuth2LoginAuthenticationProviderTests {
when(this.authorizationRequest.getScopes()).thenReturn(new LinkedHashSet<>(Collections.singleton("openid"))); when(this.authorizationRequest.getScopes()).thenReturn(new LinkedHashSet<>(Collections.singleton("openid")));
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication).isNull(); assertThat(authentication).isNull();
@ -175,7 +175,7 @@ public class OAuth2LoginAuthenticationProviderTests {
when(this.userService.loadUser(any())).thenReturn(principal); when(this.userService.loadUser(any())).thenReturn(principal);
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication.isAuthenticated()).isTrue(); assertThat(authentication.isAuthenticated()).isTrue();
@ -207,7 +207,7 @@ public class OAuth2LoginAuthenticationProviderTests {
this.authenticationProvider.setAuthoritiesMapper(authoritiesMapper); this.authenticationProvider.setAuthoritiesMapper(authoritiesMapper);
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication.getAuthorities()).isEqualTo(mappedAuthorities); assertThat(authentication.getAuthorities()).isEqualTo(mappedAuthorities);

View File

@ -143,7 +143,7 @@ public class OidcAuthorizationCodeAuthenticationProviderTests {
when(this.authorizationRequest.getScopes()).thenReturn(new LinkedHashSet<>(Collections.singleton("scope1"))); when(this.authorizationRequest.getScopes()).thenReturn(new LinkedHashSet<>(Collections.singleton("scope1")));
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication).isNull(); assertThat(authentication).isNull();
@ -355,7 +355,7 @@ public class OidcAuthorizationCodeAuthenticationProviderTests {
when(this.userService.loadUser(any())).thenReturn(principal); when(this.userService.loadUser(any())).thenReturn(principal);
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication.isAuthenticated()).isTrue(); assertThat(authentication.isAuthenticated()).isTrue();
@ -389,7 +389,7 @@ public class OidcAuthorizationCodeAuthenticationProviderTests {
this.authenticationProvider.setAuthoritiesMapper(authoritiesMapper); this.authenticationProvider.setAuthoritiesMapper(authoritiesMapper);
OAuth2LoginAuthenticationToken authentication = OAuth2LoginAuthenticationToken authentication =
(OAuth2LoginAuthenticationToken)this.authenticationProvider.authenticate( (OAuth2LoginAuthenticationToken) this.authenticationProvider.authenticate(
new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange)); new OAuth2LoginAuthenticationToken(this.clientRegistration, this.authorizationExchange));
assertThat(authentication.getAuthorities()).isEqualTo(mappedAuthorities); assertThat(authentication.getAuthorities()).isEqualTo(mappedAuthorities);

View File

@ -159,7 +159,7 @@ public class OidcUserServiceTests {
assertThat(user.getAuthorities().size()).isEqualTo(1); assertThat(user.getAuthorities().size()).isEqualTo(1);
assertThat(user.getAuthorities().iterator().next()).isInstanceOf(OidcUserAuthority.class); assertThat(user.getAuthorities().iterator().next()).isInstanceOf(OidcUserAuthority.class);
OidcUserAuthority userAuthority = (OidcUserAuthority)user.getAuthorities().iterator().next(); OidcUserAuthority userAuthority = (OidcUserAuthority) user.getAuthorities().iterator().next();
assertThat(userAuthority.getAuthority()).isEqualTo("ROLE_USER"); assertThat(userAuthority.getAuthority()).isEqualTo("ROLE_USER");
assertThat(userAuthority.getIdToken()).isEqualTo(user.getIdToken()); assertThat(userAuthority.getIdToken()).isEqualTo(user.getIdToken());
assertThat(userAuthority.getUserInfo()).isEqualTo(user.getUserInfo()); assertThat(userAuthority.getUserInfo()).isEqualTo(user.getUserInfo());

View File

@ -121,7 +121,7 @@ public class DefaultOAuth2UserServiceTests {
assertThat(user.getAuthorities().size()).isEqualTo(1); assertThat(user.getAuthorities().size()).isEqualTo(1);
assertThat(user.getAuthorities().iterator().next()).isInstanceOf(OAuth2UserAuthority.class); assertThat(user.getAuthorities().iterator().next()).isInstanceOf(OAuth2UserAuthority.class);
OAuth2UserAuthority userAuthority = (OAuth2UserAuthority)user.getAuthorities().iterator().next(); OAuth2UserAuthority userAuthority = (OAuth2UserAuthority) user.getAuthorities().iterator().next();
assertThat(userAuthority.getAuthority()).isEqualTo("ROLE_USER"); assertThat(userAuthority.getAuthority()).isEqualTo("ROLE_USER");
assertThat(userAuthority.getAttributes()).isEqualTo(user.getAttributes()); assertThat(userAuthority.getAttributes()).isEqualTo(user.getAttributes());
} }

View File

@ -43,7 +43,7 @@ public class OAuth2AuthorizationRequestUriBuilderTests {
@Test @Test
public void buildWhenScopeMultiThenSeparatedByEncodedSpace() { public void buildWhenScopeMultiThenSeparatedByEncodedSpace() {
OAuth2AuthorizationRequest request = OAuth2AuthorizationRequest.implicit() OAuth2AuthorizationRequest request = OAuth2AuthorizationRequest.implicit()
.additionalParameters(Collections.singletonMap("foo","bar")) .additionalParameters(Collections.singletonMap("foo", "bar"))
.authorizationUri("https://idp.example.com/oauth2/v2/auth") .authorizationUri("https://idp.example.com/oauth2/v2/auth")
.clientId("client-id") .clientId("client-id")
.state("thestate") .state("thestate")

View File

@ -75,7 +75,7 @@ public interface ClaimAccessor {
return null; return null;
} }
Map<String, Object> claimValues = new HashMap<>(); Map<String, Object> claimValues = new HashMap<>();
((Map<?, ?>)this.getClaims().get(claim)).forEach((k, v) -> claimValues.put(k.toString(), v)); ((Map<?, ?>) this.getClaims().get(claim)).forEach((k, v) -> claimValues.put(k.toString(), v));
return claimValues; return claimValues;
} }
@ -84,7 +84,7 @@ public interface ClaimAccessor {
return null; return null;
} }
List<String> claimValues = new ArrayList<>(); List<String> claimValues = new ArrayList<>();
((List<?>)this.getClaims().get(claim)).forEach(e -> claimValues.add(e.toString())); ((List<?>) this.getClaims().get(claim)).forEach(e -> claimValues.add(e.toString()));
return claimValues; return claimValues;
} }
} }

View File

@ -33,7 +33,7 @@ import java.util.Set;
*/ */
public final class OAuth2AccessTokenResponse { public final class OAuth2AccessTokenResponse {
private OAuth2AccessToken accessToken; private OAuth2AccessToken accessToken;
private Map<String,Object> additionalParameters; private Map<String, Object> additionalParameters;
private OAuth2AccessTokenResponse() { private OAuth2AccessTokenResponse() {
} }
@ -55,7 +55,7 @@ public final class OAuth2AccessTokenResponse {
private OAuth2AccessToken.TokenType tokenType; private OAuth2AccessToken.TokenType tokenType;
private long expiresIn; private long expiresIn;
private Set<String> scopes; private Set<String> scopes;
private Map<String,Object> additionalParameters; private Map<String, Object> additionalParameters;
private Builder(String tokenValue) { private Builder(String tokenValue) {
this.tokenValue = tokenValue; this.tokenValue = tokenValue;
@ -76,7 +76,7 @@ public final class OAuth2AccessTokenResponse {
return this; return this;
} }
public Builder additionalParameters(Map<String,Object> additionalParameters) { public Builder additionalParameters(Map<String, Object> additionalParameters) {
this.additionalParameters = additionalParameters; this.additionalParameters = additionalParameters;
return this; return this;
} }

View File

@ -49,7 +49,7 @@ public final class OAuth2AuthorizationRequest implements Serializable {
private String redirectUri; private String redirectUri;
private Set<String> scopes; private Set<String> scopes;
private String state; private String state;
private Map<String,Object> additionalParameters; private Map<String, Object> additionalParameters;
private OAuth2AuthorizationRequest() { private OAuth2AuthorizationRequest() {
} }
@ -102,7 +102,7 @@ public final class OAuth2AuthorizationRequest implements Serializable {
private String redirectUri; private String redirectUri;
private Set<String> scopes; private Set<String> scopes;
private String state; private String state;
private Map<String,Object> additionalParameters; private Map<String, Object> additionalParameters;
private Builder(AuthorizationGrantType authorizationGrantType) { private Builder(AuthorizationGrantType authorizationGrantType) {
Assert.notNull(authorizationGrantType, "authorizationGrantType cannot be null"); Assert.notNull(authorizationGrantType, "authorizationGrantType cannot be null");
@ -147,7 +147,7 @@ public final class OAuth2AuthorizationRequest implements Serializable {
return this; return this;
} }
public Builder additionalParameters(Map<String,Object> additionalParameters) { public Builder additionalParameters(Map<String, Object> additionalParameters) {
this.additionalParameters = additionalParameters; this.additionalParameters = additionalParameters;
return this; return this;
} }

View File

@ -123,12 +123,12 @@ public final class DefaultAddressStandardClaim implements AddressStandardClaim {
} }
public Builder(Map<String, Object> addressFields) { public Builder(Map<String, Object> addressFields) {
this.formatted((String)addressFields.get(FORMATTED_FIELD_NAME)); this.formatted((String) addressFields.get(FORMATTED_FIELD_NAME));
this.streetAddress((String)addressFields.get(STREET_ADDRESS_FIELD_NAME)); this.streetAddress((String) addressFields.get(STREET_ADDRESS_FIELD_NAME));
this.locality((String)addressFields.get(LOCALITY_FIELD_NAME)); this.locality((String) addressFields.get(LOCALITY_FIELD_NAME));
this.region((String)addressFields.get(REGION_FIELD_NAME)); this.region((String) addressFields.get(REGION_FIELD_NAME));
this.postalCode((String)addressFields.get(POSTAL_CODE_FIELD_NAME)); this.postalCode((String) addressFields.get(POSTAL_CODE_FIELD_NAME));
this.country((String)addressFields.get(COUNTRY_FIELD_NAME)); this.country((String) addressFields.get(COUNTRY_FIELD_NAME));
} }
public Builder formatted(String formatted) { public Builder formatted(String formatted) {

View File

@ -87,11 +87,11 @@ public class HelloWebfluxMethodApplicationITests {
} }
private Consumer<Map<String, Object>> robsCredentials() { private Consumer<Map<String, Object>> robsCredentials() {
return basicAuthenticationCredentials("rob","rob"); return basicAuthenticationCredentials("rob", "rob");
} }
private Consumer<Map<String, Object>> adminCredentials() { private Consumer<Map<String, Object>> adminCredentials() {
return basicAuthenticationCredentials("admin","admin"); return basicAuthenticationCredentials("admin", "admin");
} }
private String base64Encode(String value) { private String base64Encode(String value) {

View File

@ -49,7 +49,7 @@ public class SecurityConfig {
public MapReactiveUserDetailsService userDetailsRepository() { public MapReactiveUserDetailsService userDetailsRepository() {
User.UserBuilder userBuilder = User.withDefaultPasswordEncoder(); User.UserBuilder userBuilder = User.withDefaultPasswordEncoder();
UserDetails rob = userBuilder.username("rob").password("rob").roles("USER").build(); UserDetails rob = userBuilder.username("rob").password("rob").roles("USER").build();
UserDetails admin = userBuilder.username("admin").password("admin").roles("USER","ADMIN").build(); UserDetails admin = userBuilder.username("admin").password("admin").roles("USER", "ADMIN").build();
return new MapReactiveUserDetailsService(rob, admin); return new MapReactiveUserDetailsService(rob, admin);
} }

View File

@ -138,10 +138,10 @@ public class HelloWebfluxMethodApplicationTests {
} }
private Consumer<Map<String, Object>> robsCredentials() { private Consumer<Map<String, Object>> robsCredentials() {
return basicAuthenticationCredentials("rob","rob"); return basicAuthenticationCredentials("rob", "rob");
} }
private Consumer<Map<String, Object>> adminCredentials() { private Consumer<Map<String, Object>> adminCredentials() {
return basicAuthenticationCredentials("admin","admin"); return basicAuthenticationCredentials("admin", "admin");
} }
} }

View File

@ -87,10 +87,10 @@ public class HelloWebfluxApplicationITests {
} }
private Consumer<Map<String, Object>> userCredentials() { private Consumer<Map<String, Object>> userCredentials() {
return basicAuthenticationCredentials("user","user"); return basicAuthenticationCredentials("user", "user");
} }
private Consumer<Map<String, Object>> invalidCredentials() { private Consumer<Map<String, Object>> invalidCredentials() {
return basicAuthenticationCredentials("user","INVALID"); return basicAuthenticationCredentials("user", "INVALID");
} }
} }

View File

@ -32,13 +32,13 @@ import reactor.core.publisher.Mono;
public class HelloUserController { public class HelloUserController {
@GetMapping("/") @GetMapping("/")
public Mono<Map<String,String>> hello(Mono<Principal> principal) { public Mono<Map<String, String>> hello(Mono<Principal> principal) {
return principal return principal
.map(Principal::getName) .map(Principal::getName)
.map(this::helloMessage); .map(this::helloMessage);
} }
private Map<String,String> helloMessage(String username) { private Map<String, String> helloMessage(String username) {
return Collections.singletonMap("message", "Hello " + username + "!"); return Collections.singletonMap("message", "Hello " + username + "!");
} }
} }

View File

@ -112,10 +112,10 @@ public class HelloWebfluxApplicationTests {
} }
private Consumer<Map<String, Object>> userCredentials() { private Consumer<Map<String, Object>> userCredentials() {
return basicAuthenticationCredentials("user","user"); return basicAuthenticationCredentials("user", "user");
} }
private Consumer<Map<String, Object>> invalidCredentials() { private Consumer<Map<String, Object>> invalidCredentials() {
return basicAuthenticationCredentials("user","INVALID"); return basicAuthenticationCredentials("user", "INVALID");
} }
} }

View File

@ -86,10 +86,10 @@ public class HelloWebfluxFnApplicationITests {
} }
private Consumer<Map<String, Object>> userCredentials() { private Consumer<Map<String, Object>> userCredentials() {
return basicAuthenticationCredentials("user","user"); return basicAuthenticationCredentials("user", "user");
} }
private Consumer<Map<String, Object>> invalidCredentials() { private Consumer<Map<String, Object>> invalidCredentials() {
return basicAuthenticationCredentials("user","INVALID"); return basicAuthenticationCredentials("user", "INVALID");
} }
} }

View File

@ -115,10 +115,10 @@ public class HelloWebfluxFnApplicationTests {
} }
private Consumer<Map<String, Object>> userCredentials() { private Consumer<Map<String, Object>> userCredentials() {
return basicAuthenticationCredentials("user","user"); return basicAuthenticationCredentials("user", "user");
} }
private Consumer<Map<String, Object>> invalidCredentials() { private Consumer<Map<String, Object>> invalidCredentials() {
return basicAuthenticationCredentials("user","INVALID"); return basicAuthenticationCredentials("user", "INVALID");
} }
} }

View File

@ -27,11 +27,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http http
.authorizeRequests() .authorizeRequests()
.antMatchers("/login","/resources/**").permitAll() .antMatchers("/login", "/resources/**").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
.jee() .jee()
.mappableRoles("USER","ADMIN"); .mappableRoles("USER", "ADMIN");
} }
// @formatter:on // @formatter:on
} }

View File

@ -31,7 +31,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
auth. auth.
inMemoryAuthentication() inMemoryAuthentication()
.withUser("dianne").password("password").roles("USER").and() .withUser("dianne").password("password").roles("USER").and()
.withUser("rod").password("password").roles("USER","ADMIN").and() .withUser("rod").password("password").roles("USER", "ADMIN").and()
.withUser("scott").password("password").roles("USER"); .withUser("scott").password("password").roles("USER");
} }
// @formatter:on // @formatter:on

View File

@ -58,7 +58,7 @@ public class ClientApplication {
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
for (Map.Entry<String,ContactManager> entry : contactServices.entrySet()) { for (Map.Entry<String, ContactManager> entry : contactServices.entrySet()) {
String beanName = entry.getKey(); String beanName = entry.getKey();
ContactManager remoteContactManager = entry.getValue(); ContactManager remoteContactManager = entry.getValue();
Object object = this.beanFactory.getBean("&" + beanName); Object object = this.beanFactory.getBean("&" + beanName);

View File

@ -98,11 +98,11 @@ public class AbstractAuthorizeTagTests {
@Test @Test
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void expressionFromChildContext() throws IOException { public void expressionFromChildContext() throws IOException {
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user", "pass","USER")); SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user", "pass", "USER"));
DefaultWebSecurityExpressionHandler expected = new DefaultWebSecurityExpressionHandler(); DefaultWebSecurityExpressionHandler expected = new DefaultWebSecurityExpressionHandler();
tag.setAccess("permitAll"); tag.setAccess("permitAll");
WebApplicationContext wac = mock(WebApplicationContext.class); WebApplicationContext wac = mock(WebApplicationContext.class);
when(wac.getBeansOfType(SecurityExpressionHandler.class)).thenReturn(Collections.<String,SecurityExpressionHandler>singletonMap("wipe", expected)); when(wac.getBeansOfType(SecurityExpressionHandler.class)).thenReturn(Collections.<String, SecurityExpressionHandler>singletonMap("wipe", expected));
servletContext.setAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher", wac); servletContext.setAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher", wac);
assertThat(tag.authorize()).isTrue(); assertThat(tag.authorize()).isTrue();

View File

@ -66,7 +66,7 @@ public class Sec2935Tests {
@Test @Test
public void postProcessorUserNoUser() throws Exception { public void postProcessorUserNoUser() throws Exception {
mvc mvc
.perform(get("/admin/abc").with(user("user").roles("ADMIN","USER"))) .perform(get("/admin/abc").with(user("user").roles("ADMIN", "USER")))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(authenticated().withUsername("user")); .andExpect(authenticated().withUsername("user"));
@ -79,7 +79,7 @@ public class Sec2935Tests {
@Test @Test
public void postProcessorUserOtherUser() throws Exception { public void postProcessorUserOtherUser() throws Exception {
mvc mvc
.perform(get("/admin/abc").with(user("user1").roles("ADMIN","USER"))) .perform(get("/admin/abc").with(user("user1").roles("ADMIN", "USER")))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(authenticated().withUsername("user1")); .andExpect(authenticated().withUsername("user1"));
@ -93,7 +93,7 @@ public class Sec2935Tests {
@Test @Test
public void postProcessorUserWithMockUser() throws Exception { public void postProcessorUserWithMockUser() throws Exception {
mvc mvc
.perform(get("/admin/abc").with(user("user1").roles("ADMIN","USER"))) .perform(get("/admin/abc").with(user("user1").roles("ADMIN", "USER")))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(authenticated().withUsername("user1")); .andExpect(authenticated().withUsername("user1"));
@ -112,7 +112,7 @@ public class Sec2935Tests {
.build(); .build();
mvc mvc
.perform(get("/admin/abc").with(user("user1").roles("ADMIN","USER"))) .perform(get("/admin/abc").with(user("user1").roles("ADMIN", "USER")))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(authenticated().withUsername("user1")); .andExpect(authenticated().withUsername("user1"));
@ -132,7 +132,7 @@ public class Sec2935Tests {
.build(); .build();
mvc mvc
.perform(get("/admin/abc").with(user("user1").roles("ADMIN","USER"))) .perform(get("/admin/abc").with(user("user1").roles("ADMIN", "USER")))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
.andExpect(authenticated().withUsername("user1")); .andExpect(authenticated().withUsername("user1"));

View File

@ -159,7 +159,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests {
MockHttpServletRequestBuilder requestWithCsrf = post("/") MockHttpServletRequestBuilder requestWithCsrf = post("/")
.param(token.getParameterName(), token.getToken()) .param(token.getParameterName(), token.getToken())
.session((MockHttpSession)request.getSession()); .session((MockHttpSession) request.getSession());
this.mockMvc.perform(requestWithCsrf) this.mockMvc.perform(requestWithCsrf)
.andExpect(status().isOk()); .andExpect(status().isOk());
// @formatter:on // @formatter:on

View File

@ -28,6 +28,6 @@ import org.springframework.security.test.context.support.WithMockUser;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Inherited @Inherited
@Documented @Documented
@WithMockUser(value="rob",roles="ADMIN") @WithMockUser(value="rob", roles="ADMIN")
public @interface WithAdminRob { public @interface WithAdminRob {
} }

View File

@ -103,8 +103,8 @@ public class WithUserDetailsAuthenticationTests {
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER","ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
} }
// @formatter:on // @formatter:on
} }
} }

View File

@ -103,8 +103,8 @@ public class WithUserDetailsClassLevelAuthenticationTests {
auth auth
.inMemoryAuthentication() .inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and() .withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER","ADMIN"); .withUser("admin").password("password").roles("USER", "ADMIN");
} }
// @formatter:on // @formatter:on
} }
} }

View File

@ -62,7 +62,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
private String openIDusernameParameter; private String openIDusernameParameter;
private String openIDrememberMeParameter; private String openIDrememberMeParameter;
private Map<String, String> oauth2AuthenticationUrlToClientName; private Map<String, String> oauth2AuthenticationUrlToClientName;
private Function<HttpServletRequest,Map<String,String>> resolveHiddenInputs = request -> Collections private Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs = request -> Collections
.emptyMap(); .emptyMap();
@ -298,7 +298,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
} }
private void renderHiddenInputs(StringBuilder sb, HttpServletRequest request) { private void renderHiddenInputs(StringBuilder sb, HttpServletRequest request) {
for(Map.Entry<String,String> input : this.resolveHiddenInputs.apply(request).entrySet()) { for(Map.Entry<String, String> input : this.resolveHiddenInputs.apply(request).entrySet()) {
sb.append(" <input name=\"" + input.getKey() sb.append(" <input name=\"" + input.getKey()
+ "\" type=\"hidden\" value=\"" + input.getValue() + "\" />\n"); + "\" type=\"hidden\" value=\"" + input.getValue() + "\" />\n");
} }

View File

@ -32,7 +32,7 @@ import org.springframework.web.server.ServerWebExchange;
* @author Rob Winch * @author Rob Winch
* @since 5.0 * @since 5.0
*/ */
public class ServerFormLoginAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> { public class ServerFormLoginAuthenticationConverter implements Function<ServerWebExchange, Mono<Authentication>> {
private String usernameParameter = "username"; private String usernameParameter = "username";

View File

@ -31,7 +31,7 @@ import reactor.core.publisher.Mono;
* @author Rob Winch * @author Rob Winch
* @since 5.0 * @since 5.0
*/ */
public class ServerHttpBasicAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> { public class ServerHttpBasicAuthenticationConverter implements Function<ServerWebExchange, Mono<Authentication>> {
public static final String BASIC = "Basic "; public static final String BASIC = "Basic ";

View File

@ -46,7 +46,7 @@ public class AuthenticationWebFilter implements WebFilter {
private ServerAuthenticationSuccessHandler authenticationSuccessHandler = new WebFilterChainServerAuthenticationSuccessHandler(); private ServerAuthenticationSuccessHandler authenticationSuccessHandler = new WebFilterChainServerAuthenticationSuccessHandler();
private Function<ServerWebExchange,Mono<Authentication>> authenticationConverter = new ServerHttpBasicAuthenticationConverter(); private Function<ServerWebExchange, Mono<Authentication>> authenticationConverter = new ServerHttpBasicAuthenticationConverter();
private ServerAuthenticationFailureHandler authenticationFailureHandler = new ServerAuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint()); private ServerAuthenticationFailureHandler authenticationFailureHandler = new ServerAuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint());
@ -97,7 +97,7 @@ public class AuthenticationWebFilter implements WebFilter {
this.authenticationSuccessHandler = authenticationSuccessHandler; this.authenticationSuccessHandler = authenticationSuccessHandler;
} }
public void setAuthenticationConverter(Function<ServerWebExchange,Mono<Authentication>> authenticationConverter) { public void setAuthenticationConverter(Function<ServerWebExchange, Mono<Authentication>> authenticationConverter) {
this.authenticationConverter = authenticationConverter; this.authenticationConverter = authenticationConverter;
} }

View File

@ -57,7 +57,7 @@ public class LogoutWebFilter implements WebFilter {
.map(result -> exchange) .map(result -> exchange)
.flatMap(this::flatMapAuthentication) .flatMap(this::flatMapAuthentication)
.flatMap( authentication -> { .flatMap( authentication -> {
WebFilterExchange webFilterExchange = new WebFilterExchange(exchange,chain); WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, chain);
return logout(webFilterExchange, authentication); return logout(webFilterExchange, authentication);
}); });
} }

View File

@ -27,13 +27,13 @@ import java.util.Map;
*/ */
public class AuthorizationContext { public class AuthorizationContext {
private final ServerWebExchange exchange; private final ServerWebExchange exchange;
private final Map<String,Object> variables; private final Map<String, Object> variables;
public AuthorizationContext(ServerWebExchange exchange) { public AuthorizationContext(ServerWebExchange exchange) {
this(exchange, Collections.emptyMap()); this(exchange, Collections.emptyMap());
} }
public AuthorizationContext(ServerWebExchange exchange, Map<String,Object> variables) { public AuthorizationContext(ServerWebExchange exchange, Map<String, Object> variables) {
this.exchange = exchange; this.exchange = exchange;
this.variables = variables; this.variables = variables;
} }
@ -42,7 +42,7 @@ public class AuthorizationContext {
return exchange; return exchange;
} }
public Map<String,Object> getVariables() { public Map<String, Object> getVariables() {
return Collections.unmodifiableMap(variables); return Collections.unmodifiableMap(variables);
} }
} }

View File

@ -64,14 +64,14 @@ public class WebSessionServerCsrfTokenRepository
.flatMap( attrs -> save(attrs, token)); .flatMap( attrs -> save(attrs, token));
} }
private Mono<CsrfToken> save(Map<String,Object> attributes, CsrfToken token) { private Mono<CsrfToken> save(Map<String, Object> attributes, CsrfToken token) {
return Mono.defer(() -> { return Mono.defer(() -> {
putToken(attributes, token); putToken(attributes, token);
return Mono.justOrEmpty(token); return Mono.justOrEmpty(token);
}); });
} }
private void putToken(Map<String,Object> attributes, CsrfToken token) { private void putToken(Map<String, Object> attributes, CsrfToken token) {
if(token == null) { if(token == null) {
attributes.remove(this.sessionAttributeName); attributes.remove(this.sessionAttributeName);
} else { } else {
@ -118,7 +118,7 @@ public class WebSessionServerCsrfTokenRepository
} }
private CsrfToken createCsrfToken(Map<String,Object> attributes) { private CsrfToken createCsrfToken(Map<String, Object> attributes) {
return new LazyCsrfToken(attributes, createCsrfToken()); return new LazyCsrfToken(attributes, createCsrfToken());
} }
@ -131,7 +131,7 @@ public class WebSessionServerCsrfTokenRepository
} }
private class LazyCsrfToken implements CsrfToken { private class LazyCsrfToken implements CsrfToken {
private final Map<String,Object> attributes; private final Map<String, Object> attributes;
private final CsrfToken delegate; private final CsrfToken delegate;
private LazyCsrfToken(Map<String, Object> attributes, CsrfToken delegate) { private LazyCsrfToken(Map<String, Object> attributes, CsrfToken delegate) {

View File

@ -68,8 +68,8 @@ public final class PathPatternParserServerWebExchangeMatcher implements ServerWe
if(!match) { if(!match) {
return MatchResult.notMatch(); return MatchResult.notMatch();
} }
Map<String,String> pathVariables = this.pattern.matchAndExtract(path).getUriVariables(); Map<String, String> pathVariables = this.pattern.matchAndExtract(path).getUriVariables();
Map<String,Object> variables = new HashMap<>(pathVariables); Map<String, Object> variables = new HashMap<>(pathVariables);
return MatchResult.match(variables); return MatchResult.match(variables);
} }

View File

@ -32,7 +32,7 @@ public interface ServerWebExchangeMatcher {
class MatchResult { class MatchResult {
private final boolean match; private final boolean match;
private final Map<String,Object> variables; private final Map<String, Object> variables;
private MatchResult(boolean match, Map<String, Object> variables) { private MatchResult(boolean match, Map<String, Object> variables) {
this.match = match; this.match = match;
@ -43,7 +43,7 @@ public interface ServerWebExchangeMatcher {
return match; return match;
} }
public Map<String,Object> getVariables() { public Map<String, Object> getVariables() {
return variables; return variables;
} }
@ -51,7 +51,7 @@ public interface ServerWebExchangeMatcher {
return match(Collections.emptyMap()); return match(Collections.emptyMap());
} }
public static Mono<MatchResult> match(Map<String,Object> variables) { public static Mono<MatchResult> match(Map<String, Object> variables) {
return Mono.just(new MatchResult(true, variables)); return Mono.just(new MatchResult(true, variables));
} }

View File

@ -90,7 +90,7 @@ public class DigestAuthUtilsTests {
public void testSplitNormalOperation() { public void testSplitNormalOperation() {
String unsplit = "username=\"rod==\""; String unsplit = "username=\"rod==\"";
assertThat(DigestAuthUtils.split(unsplit, "=")[0]).isEqualTo("username"); assertThat(DigestAuthUtils.split(unsplit, "=")[0]).isEqualTo("username");
assertThat(DigestAuthUtils.split(unsplit, "=")[1]).isEqualTo("\"rod==\"");// should assertThat(DigestAuthUtils.split(unsplit, "=")[1]).isEqualTo("\"rod==\""); // should
// not // not
// remove // remove
// quotes // quotes

View File

@ -84,7 +84,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void deserializeSavedCookieWithList() throws IOException, JSONException { public void deserializeSavedCookieWithList() throws IOException, JSONException {
List<SavedCookie> savedCookies = (List<SavedCookie>)mapper.readValue(COOKIES_JSON, Object.class); List<SavedCookie> savedCookies = (List<SavedCookie>) mapper.readValue(COOKIES_JSON, Object.class);
assertThat(savedCookies).isNotNull().hasSize(1); assertThat(savedCookies).isNotNull().hasSize(1);
assertThat(savedCookies.get(0).getName()).isEqualTo("SESSION"); assertThat(savedCookies.get(0).getName()).isEqualTo("SESSION");
assertThat(savedCookies.get(0).getValue()).isEqualTo("123456789"); assertThat(savedCookies.get(0).getValue()).isEqualTo("123456789");

View File

@ -39,7 +39,7 @@ public class ServerFormLoginAuthenticationConverterTests {
@Mock @Mock
private ServerWebExchange exchange; private ServerWebExchange exchange;
private MultiValueMap<String,String> data = new LinkedMultiValueMap<>(); private MultiValueMap<String, String> data = new LinkedMultiValueMap<>();
private ServerFormLoginAuthenticationConverter converter = new ServerFormLoginAuthenticationConverter(); private ServerFormLoginAuthenticationConverter converter = new ServerFormLoginAuthenticationConverter();

View File

@ -56,7 +56,7 @@ public class AuthenticationWebFilterTests {
@Mock @Mock
private ServerAuthenticationSuccessHandler successHandler; private ServerAuthenticationSuccessHandler successHandler;
@Mock @Mock
private Function<ServerWebExchange,Mono<Authentication>> authenticationConverter; private Function<ServerWebExchange, Mono<Authentication>> authenticationConverter;
@Mock @Mock
private ReactiveAuthenticationManager authenticationManager; private ReactiveAuthenticationManager authenticationManager;
@Mock @Mock
@ -96,7 +96,7 @@ public class AuthenticationWebFilterTests {
@Test @Test
public void filterWhenDefaultsAndAuthenticationSuccessThenContinues() { public void filterWhenDefaultsAndAuthenticationSuccessThenContinues() {
when(this.authenticationManager.authenticate(any())).thenReturn(Mono.just(new TestingAuthenticationToken("test","this", "ROLE"))); when(this.authenticationManager.authenticate(any())).thenReturn(Mono.just(new TestingAuthenticationToken("test", "this", "ROLE")));
this.filter = new AuthenticationWebFilter(this.authenticationManager); this.filter = new AuthenticationWebFilter(this.authenticationManager);
WebTestClient client = WebTestClientBuilder WebTestClient client = WebTestClientBuilder
@ -185,7 +185,7 @@ public class AuthenticationWebFilterTests {
when(this.authenticationConverter.apply(any())).thenReturn(authentication); when(this.authenticationConverter.apply(any())).thenReturn(authentication);
when(this.authenticationManager.authenticate(any())).thenReturn(authentication); when(this.authenticationManager.authenticate(any())).thenReturn(authentication);
when(this.successHandler.onAuthenticationSuccess(any(), any())).thenReturn(Mono.empty()); when(this.successHandler.onAuthenticationSuccess(any(), any())).thenReturn(Mono.empty());
when(this.securityContextRepository.save(any(),any())).thenAnswer( a -> Mono.just(a.getArguments()[0])); when(this.securityContextRepository.save(any(), any())).thenAnswer( a -> Mono.just(a.getArguments()[0]));
WebTestClient client = WebTestClientBuilder WebTestClient client = WebTestClientBuilder
.bindToWebFilters(this.filter) .bindToWebFilters(this.filter)
@ -231,7 +231,7 @@ public class AuthenticationWebFilterTests {
Mono<Authentication> authentication = Mono.just(new TestingAuthenticationToken("test", "this", "ROLE_USER")); Mono<Authentication> authentication = Mono.just(new TestingAuthenticationToken("test", "this", "ROLE_USER"));
when(this.authenticationConverter.apply(any())).thenReturn(authentication); when(this.authenticationConverter.apply(any())).thenReturn(authentication);
when(this.authenticationManager.authenticate(any())).thenReturn(Mono.error(new BadCredentialsException("Failed"))); when(this.authenticationManager.authenticate(any())).thenReturn(Mono.error(new BadCredentialsException("Failed")));
when(this.failureHandler.onAuthenticationFailure(any(),any())).thenReturn(Mono.empty()); when(this.failureHandler.onAuthenticationFailure(any(), any())).thenReturn(Mono.empty());
WebTestClient client = WebTestClientBuilder WebTestClient client = WebTestClientBuilder
.bindToWebFilters(this.filter) .bindToWebFilters(this.filter)
@ -244,7 +244,7 @@ public class AuthenticationWebFilterTests {
.expectStatus().isOk() .expectStatus().isOk()
.expectBody().isEmpty(); .expectBody().isEmpty();
verify(this.failureHandler).onAuthenticationFailure(any(),any()); verify(this.failureHandler).onAuthenticationFailure(any(), any());
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.successHandler); verifyZeroInteractions(this.successHandler);
} }

View File

@ -50,7 +50,7 @@ public class AuthorizationWebFilterTests {
@Test @Test
public void filterWhenNoSecurityContextThenThrowsAccessDenied() { public void filterWhenNoSecurityContextThenThrowsAccessDenied() {
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> Mono.error(new AccessDeniedException("Denied"))); AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> Mono.error(new AccessDeniedException("Denied")));
Mono<Void> result = filter.filter(this.exchange, this.chain); Mono<Void> result = filter.filter(this.exchange, this.chain);
@ -63,7 +63,7 @@ public class AuthorizationWebFilterTests {
@Test @Test
public void filterWhenNoAuthenticationThenThrowsAccessDenied() { public void filterWhenNoAuthenticationThenThrowsAccessDenied() {
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> Mono.error(new AccessDeniedException("Denied"))); AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> Mono.error(new AccessDeniedException("Denied")));
Mono<Void> result = filter Mono<Void> result = filter
.filter(this.exchange, this.chain) .filter(this.exchange, this.chain)
@ -78,11 +78,11 @@ public class AuthorizationWebFilterTests {
@Test @Test
public void filterWhenAuthenticationThenThrowsAccessDenied() { public void filterWhenAuthenticationThenThrowsAccessDenied() {
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> Mono.error(new AccessDeniedException("Denied"))); AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> Mono.error(new AccessDeniedException("Denied")));
Mono<Void> result = filter Mono<Void> result = filter
.filter(this.exchange, this.chain) .filter(this.exchange, this.chain)
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("a","b", "R"))); .subscriberContext(ReactiveSecurityContextHolder.withAuthentication(new TestingAuthenticationToken("a", "b", "R")));
StepVerifier.create(result) StepVerifier.create(result)
.expectError(AccessDeniedException.class) .expectError(AccessDeniedException.class)
@ -94,7 +94,7 @@ public class AuthorizationWebFilterTests {
public void filterWhenDoesNotAccessAuthenticationThenSecurityContextNotSubscribed() { public void filterWhenDoesNotAccessAuthenticationThenSecurityContextNotSubscribed() {
PublisherProbe<SecurityContext> context = PublisherProbe.empty(); PublisherProbe<SecurityContext> context = PublisherProbe.empty();
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> Mono.error(new AccessDeniedException("Denied"))); AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> Mono.error(new AccessDeniedException("Denied")));
Mono<Void> result = filter Mono<Void> result = filter
.filter(this.exchange, this.chain) .filter(this.exchange, this.chain)
@ -111,7 +111,7 @@ public class AuthorizationWebFilterTests {
public void filterWhenGrantedAndDoesNotAccessAuthenticationThenChainSubscribedAndSecurityContextNotSubscribed() { public void filterWhenGrantedAndDoesNotAccessAuthenticationThenChainSubscribedAndSecurityContextNotSubscribed() {
PublisherProbe<SecurityContext> context = PublisherProbe.empty(); PublisherProbe<SecurityContext> context = PublisherProbe.empty();
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> Mono.just(new AuthorizationDecision(true))); AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> Mono.just(new AuthorizationDecision(true)));
Mono<Void> result = filter Mono<Void> result = filter
.filter(this.exchange, this.chain) .filter(this.exchange, this.chain)
@ -127,7 +127,7 @@ public class AuthorizationWebFilterTests {
public void filterWhenGrantedAndDoeAccessAuthenticationThenChainSubscribedAndSecurityContextSubscribed() { public void filterWhenGrantedAndDoeAccessAuthenticationThenChainSubscribedAndSecurityContextSubscribed() {
PublisherProbe<SecurityContext> context = PublisherProbe.empty(); PublisherProbe<SecurityContext> context = PublisherProbe.empty();
when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono()); when(this.chain.filter(this.exchange)).thenReturn(this.chainResult.mono());
AuthorizationWebFilter filter = new AuthorizationWebFilter((a,e) -> a AuthorizationWebFilter filter = new AuthorizationWebFilter((a, e) -> a
.map( auth -> new AuthorizationDecision(true)) .map( auth -> new AuthorizationDecision(true))
.defaultIfEmpty(new AuthorizationDecision(true)) .defaultIfEmpty(new AuthorizationDecision(true))
); );

View File

@ -74,7 +74,7 @@ public class ReactorContextWebFilterTests {
@Test @Test
public void filterWhenGetPrincipalMonoThenNoInteractions() { public void filterWhenGetPrincipalMonoThenNoInteractions() {
this.handler = WebTestHandler.bindToWebFilters(this.filter, (e,c) -> { this.handler = WebTestHandler.bindToWebFilters(this.filter, (e, c) -> {
ReactiveSecurityContextHolder.getContext(); ReactiveSecurityContextHolder.getContext();
return c.filter(e); return c.filter(e);
}); });
@ -88,7 +88,7 @@ public class ReactorContextWebFilterTests {
public void filterWhenPrincipalAndGetPrincipalThenInteractAndUseOriginalPrincipal() { public void filterWhenPrincipalAndGetPrincipalThenInteractAndUseOriginalPrincipal() {
SecurityContextImpl context = new SecurityContextImpl(this.principal); SecurityContextImpl context = new SecurityContextImpl(this.principal);
when(this.repository.load(any())).thenReturn(Mono.just(context)); when(this.repository.load(any())).thenReturn(Mono.just(context));
this.handler = WebTestHandler.bindToWebFilters(this.filter, (e,c) -> this.handler = WebTestHandler.bindToWebFilters(this.filter, (e, c) ->
ReactiveSecurityContextHolder.getContext() ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication) .map(SecurityContext::getAuthentication)
.doOnSuccess( p -> assertThat(p).isSameAs(this.principal)) .doOnSuccess( p -> assertThat(p).isSameAs(this.principal))

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SecurityContextServerWebExchangeWebFilterTests { public class SecurityContextServerWebExchangeWebFilterTests {
SecurityContextServerWebExchangeWebFilter filter = new SecurityContextServerWebExchangeWebFilter(); SecurityContextServerWebExchangeWebFilter filter = new SecurityContextServerWebExchangeWebFilter();
Authentication principal = new TestingAuthenticationToken("user","password", "ROLE_USER"); Authentication principal = new TestingAuthenticationToken("user", "password", "ROLE_USER");
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").build()); ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").build());
@ -73,7 +73,7 @@ public class SecurityContextServerWebExchangeWebFilterTests {
@Test @Test
public void filterWhenPrincipalNullThenContextEmpty() { public void filterWhenPrincipalNullThenContextEmpty() {
Authentication defaultAuthentication = new TestingAuthenticationToken("anonymouse","anonymous", "TEST"); Authentication defaultAuthentication = new TestingAuthenticationToken("anonymouse", "anonymous", "TEST");
Mono<Void> result = this.filter.filter(this.exchange, new DefaultWebFilterChain( e -> Mono<Void> result = this.filter.filter(this.exchange, new DefaultWebFilterChain( e ->
e.getPrincipal() e.getPrincipal()
.defaultIfEmpty(defaultAuthentication) .defaultIfEmpty(defaultAuthentication)

View File

@ -94,9 +94,9 @@ public class OnCommittedResponseWrapperTests {
int off = 2; int off = 2;
int len = 3; int len = 3;
response.getWriter().write(buff,off,len); response.getWriter().write(buff, off, len);
verify(writer).write(buff,off,len); verify(writer).write(buff, off, len);
} }
@Test @Test
@ -114,9 +114,9 @@ public class OnCommittedResponseWrapperTests {
int off = 2; int off = 2;
int len = 3; int len = 3;
response.getWriter().write(s,off,len); response.getWriter().write(s, off, len);
verify(writer).write(s,off,len); verify(writer).write(s, off, len);
} }
@Test @Test
@ -602,7 +602,7 @@ public class OnCommittedResponseWrapperTests {
int len = 3; int len = 3;
response.setContentLength(3); response.setContentLength(3);
response.getWriter().write(buff,off,len); response.getWriter().write(buff, off, len);
assertThat(committed).isTrue(); assertThat(committed).isTrue();
} }
@ -624,7 +624,7 @@ public class OnCommittedResponseWrapperTests {
int len = 3; int len = 3;
response.setContentLength(3); response.setContentLength(3);
response.getWriter().write(s,off,len); response.getWriter().write(s, off, len);
assertThat(committed).isTrue(); assertThat(committed).isTrue();
} }
@ -1104,7 +1104,7 @@ public class OnCommittedResponseWrapperTests {
@Test @Test
public void addHeaderContentLengthPrintWriterWriteStringCommits() throws Exception { public void addHeaderContentLengthPrintWriterWriteStringCommits() throws Exception {
int expected = 1234; int expected = 1234;
response.addHeader("Content-Length",String.valueOf(String.valueOf(expected).length())); response.addHeader("Content-Length", String.valueOf(String.valueOf(expected).length()));
response.getWriter().write(expected); response.getWriter().write(expected);