Reduce method visibility when possible
Reduce method visibility for package private classes when possible. In the case of abstract classes that will eventually be made public, the class has been made public and a package-private constructor has been added. Issue gh-8945
This commit is contained in:
@@ -32,7 +32,7 @@ class ConcereteSecurityConfigurerAdapter extends SecurityConfigurerAdapter<Objec
|
||||
this.list = postProcess(this.list);
|
||||
}
|
||||
|
||||
public ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
this.list = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ObjectPostProcessorTests {
|
||||
|
||||
static class PerformConversion {
|
||||
|
||||
public static List<?> perform(ArrayList<?> l) {
|
||||
static List<?> perform(ArrayList<?> l) {
|
||||
return new ListToLinkedListObjectPostProcessor().postProcess(l);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SecurityConfigurerAdapterClosureTests {
|
||||
this.list = postProcess(this.list);
|
||||
}
|
||||
|
||||
public ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
this.list = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -235,19 +235,19 @@ public class AuthenticationManagerBuilderTests {
|
||||
Resource users;
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager() throws Exception {
|
||||
AuthenticationManager authenticationManager() throws Exception {
|
||||
return new ProviderManager(Arrays.asList(authenticationProvider()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() throws Exception {
|
||||
AuthenticationProvider authenticationProvider() throws Exception {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(userDetailsService());
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
UserDetailsService userDetailsService() throws Exception {
|
||||
Properties properties = new Properties();
|
||||
properties.load(this.users.getInputStream());
|
||||
return new InMemoryUserDetailsManager(properties);
|
||||
|
||||
@@ -81,7 +81,7 @@ public class NamespaceAuthenticationManagerTests {
|
||||
static class EraseCredentialsTrueDefaultConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -110,7 +110,7 @@ public class NamespaceAuthenticationManagerTests {
|
||||
static class GlobalEraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.eraseCredentials(false)
|
||||
|
||||
@@ -73,7 +73,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DaoAuthenticationProvider authenticationProvider() {
|
||||
DaoAuthenticationProvider authenticationProvider() {
|
||||
DaoAuthenticationProvider result = new DaoAuthenticationProvider();
|
||||
result.setUserDetailsService(new InMemoryUserDetailsManager(PasswordEncodedUser.user()));
|
||||
return result;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
static class DataSourceConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
static class CustomDataSourceConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
|
||||
// simulate that the DB already has the schema loaded and users in it
|
||||
.addScript("CustomJdbcUserServiceSampleConfig.sql");
|
||||
|
||||
@@ -104,7 +104,7 @@ public class NamespacePasswordEncoderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class NamespacePasswordEncoderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder() {
|
||||
BCryptPasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder() {
|
||||
BCryptPasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ public class AuthenticationConfigurationTests {
|
||||
AuthenticationManager authenticationManager = mock(AuthenticationManager.class);
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager() {
|
||||
AuthenticationManager authenticationManager() {
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ public class AuthenticationConfigurationTests {
|
||||
static class ServicesConfig {
|
||||
|
||||
@Bean
|
||||
public Service service() {
|
||||
Service service() {
|
||||
return new ServiceImpl();
|
||||
}
|
||||
|
||||
@@ -466,12 +466,12 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2531Config {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor() {
|
||||
ObjectPostProcessor objectPostProcessor() {
|
||||
return mock(ObjectPostProcessor.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager manager() {
|
||||
AuthenticationManager manager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2822WebSecurity extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
@@ -498,14 +498,14 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2822UseAuth {
|
||||
|
||||
@Autowired
|
||||
public void useAuthenticationManager(AuthenticationConfiguration auth) throws Exception {
|
||||
void useAuthenticationManager(AuthenticationConfiguration auth) throws Exception {
|
||||
auth.getAuthenticationManager();
|
||||
}
|
||||
|
||||
// Ensures that Sec2822UseAuth is initialized before Sec2822WebSecurity
|
||||
// must have additional GlobalAuthenticationConfigurerAdapter to trigger SEC-2822
|
||||
@Bean
|
||||
public static GlobalAuthenticationConfigurerAdapter bootGlobalAuthenticationConfigurerAdapter() {
|
||||
static GlobalAuthenticationConfigurerAdapter bootGlobalAuthenticationConfigurerAdapter() {
|
||||
return new BootGlobalAuthenticationConfigurerAdapter();
|
||||
}
|
||||
|
||||
@@ -621,12 +621,12 @@ public class AuthenticationConfigurationTests {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public AuthenticationManager manager1() {
|
||||
AuthenticationManager manager1() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager manager2() {
|
||||
AuthenticationManager manager2() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class Config {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class BeanProxyEnabledByDefaultConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class BeanProxyDisabledConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
return new AutowireBeanFactoryObjectPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
SmartInitializingSingleton toTest = mock(SmartInitializingSingleton.class);
|
||||
|
||||
@Autowired
|
||||
public void configure(ObjectPostProcessor<Object> p) {
|
||||
void configure(ObjectPostProcessor<Object> p) {
|
||||
p.postProcess(this.toTest);
|
||||
}
|
||||
|
||||
@@ -172,12 +172,12 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
static class WithBeanNameAutoProxyCreatorConfig {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
return new AutowireBeanFactoryObjectPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configure(ObjectPostProcessor<Object> p) {
|
||||
void configure(ObjectPostProcessor<Object> p) {
|
||||
p.postProcess(new Object());
|
||||
}
|
||||
|
||||
|
||||
@@ -470,12 +470,12 @@ public class EnableReactiveMethodSecurityTests {
|
||||
ReactiveMessageService delegate = mock(ReactiveMessageService.class);
|
||||
|
||||
@Bean
|
||||
public DelegatingReactiveMessageService defaultMessageService() {
|
||||
DelegatingReactiveMessageService defaultMessageService() {
|
||||
return new DelegatingReactiveMessageService(this.delegate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Authz authz() {
|
||||
Authz authz() {
|
||||
return new Authz();
|
||||
}
|
||||
|
||||
|
||||
@@ -340,12 +340,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class CustomTrustResolverConfig {
|
||||
|
||||
@Bean
|
||||
public AuthenticationTrustResolver trustResolver() {
|
||||
AuthenticationTrustResolver trustResolver() {
|
||||
return mock(AuthenticationTrustResolver.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl service() {
|
||||
MethodSecurityServiceImpl service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@@ -355,12 +355,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class ExpressionHandlerHasBeanResolverSetConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl service() {
|
||||
MethodSecurityServiceImpl service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Authz authz() {
|
||||
Authz authz() {
|
||||
return new Authz();
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class MethodSecurityServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@@ -380,12 +380,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
public static class AutowirePermissionEvaluatorConfig {
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@@ -395,12 +395,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
public static class MultiPermissionEvaluatorConfig {
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator2() {
|
||||
PermissionEvaluator permissionEvaluator2() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class ParentConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2479ParentConfig {
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager am() {
|
||||
AuthenticationManager am() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2479ChildConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@@ -445,17 +445,17 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2815Config {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockBeanPostProcessor mockBeanPostProcessor() {
|
||||
MockBeanPostProcessor mockBeanPostProcessor() {
|
||||
return new MockBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
return mock(DataSource.class);
|
||||
}
|
||||
|
||||
@@ -499,12 +499,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec3005Config {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
@@ -548,24 +548,24 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class CustomGrantedAuthorityConfig {
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults ga() {
|
||||
GrantedAuthorityDefaults ga() {
|
||||
return new GrantedAuthorityDefaults("ROLE:");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomAuthorityService service() {
|
||||
CustomAuthorityService service() {
|
||||
return new CustomAuthorityService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl methodSecurityService() {
|
||||
MethodSecurityServiceImpl methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
static class CustomAuthorityService {
|
||||
|
||||
@PreAuthorize("hasRole('ROLE:USER')")
|
||||
public void customPrefixRoleUser() {
|
||||
void customPrefixRoleUser() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -576,24 +576,24 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class EmptyRolePrefixGrantedAuthorityConfig {
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults ga() {
|
||||
GrantedAuthorityDefaults ga() {
|
||||
return new GrantedAuthorityDefaults("");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomAuthorityService service() {
|
||||
CustomAuthorityService service() {
|
||||
return new CustomAuthorityService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl methodSecurityService() {
|
||||
MethodSecurityServiceImpl methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
static class CustomAuthorityService {
|
||||
|
||||
@Secured("USER")
|
||||
public void emptyPrefixRoleUser() {
|
||||
void emptyPrefixRoleUser() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ReactiveMethodSecurityConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
static class Foo {
|
||||
|
||||
public void bar(String param) {
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SampleEnableGlobalMethodSecurityTests {
|
||||
static class SampleWebSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService methodSecurityService() {
|
||||
MethodSecurityService methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class Sec2758Tests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Service service() {
|
||||
Service service() {
|
||||
return new Service();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Sec2758Tests {
|
||||
static class RootController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@@ -123,11 +123,11 @@ public class Sec2758Tests {
|
||||
static class Service {
|
||||
|
||||
@PreAuthorize("hasRole('CUSTOM')")
|
||||
public void doPreAuthorize() {
|
||||
void doPreAuthorize() {
|
||||
}
|
||||
|
||||
@RolesAllowed("CUSTOM")
|
||||
public void doJsr250() {
|
||||
void doJsr250() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
static class InMemoryConfigureGlobalConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -308,7 +308,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
private ContentNegotiationStrategy contentNegotiationStrategySharedObject;
|
||||
|
||||
@Bean
|
||||
public ContentNegotiationStrategy contentNegotiationStrategy() {
|
||||
ContentNegotiationStrategy contentNegotiationStrategy() {
|
||||
return CONTENT_NEGOTIATION_STRATEGY_BEAN;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
static class RequiresUserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MyFilter myFilter(UserDetailsService userDetailsService) {
|
||||
MyFilter myFilter(UserDetailsService userDetailsService) {
|
||||
return new MyFilter(userDetailsService);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
private AuthenticationTrustResolver authenticationTrustResolverSharedObject;
|
||||
|
||||
@Bean
|
||||
public AuthenticationTrustResolver authenticationTrustResolver() {
|
||||
AuthenticationTrustResolver authenticationTrustResolver() {
|
||||
return AUTHENTICATION_TRUST_RESOLVER_BEAN;
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationEventPublisher authenticationEventPublisher() {
|
||||
AuthenticationEventPublisher authenticationEventPublisher() {
|
||||
return mock(AuthenticationEventPublisher.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -613,7 +613,7 @@ public class NamespaceHttpTests {
|
||||
static Class<? extends HttpServletRequest> HTTP_SERVLET_REQUEST_TYPE;
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(HttpServletRequest request) {
|
||||
String index(HttpServletRequest request) {
|
||||
HTTP_SERVLET_REQUEST_TYPE = request.getClass();
|
||||
return "index";
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class WebSecurityTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class WebSecurityTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
||||
@@ -192,12 +192,12 @@ public class EnableWebSecurityTests {
|
||||
static class BeanProxyEnabledByDefaultConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -208,12 +208,12 @@ public class EnableWebSecurityTests {
|
||||
static class BeanProxyDisabledConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class EnableWebSecurityTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class NameController {
|
||||
|
||||
@GetMapping("/name")
|
||||
public Callable<String> name() {
|
||||
Callable<String> name() {
|
||||
return () -> SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class DefaultWithFilterChainConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class AuthorizeRequestsConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.authorizeRequests((authorize) -> authorize.anyRequest().permitAll()).build();
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class SecurityEnabledConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.formLogin(withDefaults()).build();
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class UserDetailsConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER")
|
||||
.build();
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
@@ -221,7 +221,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void index() {
|
||||
void index() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class UserController {
|
||||
|
||||
@GetMapping("/user")
|
||||
public void user(HttpServletRequest request) {
|
||||
void user(HttpServletRequest request) {
|
||||
if (!request.isUserInRole("USER")) {
|
||||
throw new AccessDeniedException("This resource is only available to users");
|
||||
}
|
||||
|
||||
@@ -217,25 +217,25 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return CLIENT_REGISTRATION_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return AUTHORIZED_CLIENT_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return ACCESS_TOKEN_RESPONSE_CLIENT;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class Controller {
|
||||
class Controller {
|
||||
|
||||
@GetMapping("/authorized-client")
|
||||
public String authorizedClient(
|
||||
String authorizedClient(
|
||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
||||
}
|
||||
@@ -260,22 +260,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository1() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository1() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository2() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository2() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@@ -314,22 +314,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository1() {
|
||||
ClientRegistrationRepository clientRegistrationRepository1() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository2() {
|
||||
ClientRegistrationRepository clientRegistrationRepository2() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@@ -351,22 +351,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient1() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient1() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient2() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient2() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@@ -385,25 +385,25 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return CLIENT_REGISTRATION_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return AUTHORIZED_CLIENT_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientManager authorizedClientManager() {
|
||||
OAuth2AuthorizedClientManager authorizedClientManager() {
|
||||
return AUTHORIZED_CLIENT_MANAGER;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class Controller {
|
||||
class Controller {
|
||||
|
||||
@GetMapping("/authorized-client")
|
||||
public String authorizedClient(
|
||||
String authorizedClient(
|
||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class SecurityReactorContextConfigurationResourceServerTests {
|
||||
}
|
||||
|
||||
@GetMapping("/token")
|
||||
public String token() {
|
||||
String token() {
|
||||
return this.rest.get().uri(this.uri).retrieve().bodyToMono(String.class)
|
||||
.flatMap((result) -> this.rest.get().uri(this.uri).retrieve().bodyToMono(String.class)).block();
|
||||
}
|
||||
|
||||
@@ -106,18 +106,18 @@ public class WebMvcSecurityConfigurationTests {
|
||||
static class TestController {
|
||||
|
||||
@RequestMapping("/authentication-principal")
|
||||
public ModelAndView authenticationPrincipal(@AuthenticationPrincipal String principal) {
|
||||
ModelAndView authenticationPrincipal(@AuthenticationPrincipal String principal) {
|
||||
return new ModelAndView("authentication-principal-view", "result", principal);
|
||||
}
|
||||
|
||||
@RequestMapping("/deprecated-authentication-principal")
|
||||
public ModelAndView deprecatedAuthenticationPrincipal(
|
||||
ModelAndView deprecatedAuthenticationPrincipal(
|
||||
@org.springframework.security.web.bind.annotation.AuthenticationPrincipal String principal) {
|
||||
return new ModelAndView("deprecated-authentication-principal-view", "result", principal);
|
||||
}
|
||||
|
||||
@RequestMapping("/csrf")
|
||||
public ModelAndView csrf(CsrfToken token) {
|
||||
ModelAndView csrf(CsrfToken token) {
|
||||
return new ModelAndView("view", "result", token);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class WebMvcSecurityConfigurationTests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public TestController testController() {
|
||||
TestController testController() {
|
||||
return new TestController();
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ public class WebSecurityConfigurationTests {
|
||||
};
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return PERMIT_ALL_PERMISSION_EVALUATOR;
|
||||
}
|
||||
|
||||
@@ -564,10 +564,10 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class HomeController {
|
||||
class HomeController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String home() {
|
||||
String home() {
|
||||
return "home";
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ public class WebSecurityConfigurationTests {
|
||||
static class ParentConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ public class AuthorizeRequestsTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RoleHierarchy roleHiearchy() {
|
||||
RoleHierarchy roleHiearchy() {
|
||||
RoleHierarchyImpl result = new RoleHierarchyImpl();
|
||||
result.setHierarchy("ROLE_USER > ROLE_ADMIN");
|
||||
return result;
|
||||
@@ -515,7 +515,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public RequestDataValueProcessor requestDataValueProcessor() {
|
||||
RequestDataValueProcessor requestDataValueProcessor() {
|
||||
return mock(RequestDataValueProcessor.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -738,11 +738,11 @@ public class CsrfConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void rootGet() {
|
||||
void rootGet() {
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public void rootPost() {
|
||||
void rootPost() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class DefaultFiltersTests {
|
||||
static class FilterChainProxyBuilderMissingConfig {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -153,7 +153,7 @@ public class DefaultFiltersTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(PasswordEncodedUser.user(), PasswordEncodedUser.admin());
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ public class ExceptionHandlingConfigurerTests {
|
||||
static class DefaultSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsManager() {
|
||||
InMemoryUserDetailsManager userDetailsManager() {
|
||||
// @formatter:off
|
||||
return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
@@ -310,7 +310,7 @@ public class ExceptionHandlingConfigurerTests {
|
||||
static ContentNegotiationStrategy CNS = mock(ContentNegotiationStrategy.class);
|
||||
|
||||
@Bean
|
||||
public static ContentNegotiationStrategy cns() {
|
||||
static ContentNegotiationStrategy cns() {
|
||||
return CNS;
|
||||
}
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationListener<AuthorizedEvent> applicationListener() {
|
||||
ApplicationListener<AuthorizedEvent> applicationListener() {
|
||||
return AL;
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Checker permission() {
|
||||
Checker permission() {
|
||||
return new Checker();
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomExpressionHandler expressionHandler() {
|
||||
CustomExpressionHandler expressionHandler() {
|
||||
return new CustomExpressionHandler();
|
||||
}
|
||||
|
||||
@@ -937,8 +937,9 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return new PermissionEvaluator() {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject,
|
||||
Object permission) {
|
||||
@@ -950,6 +951,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
Object permission) {
|
||||
return "ID".equals(targetId) && "TYPE".equals(targetType) && "PERMISSION".equals(permission);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -970,7 +972,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RoleHierarchy roleHierarchy() {
|
||||
RoleHierarchy roleHierarchy() {
|
||||
RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
|
||||
roleHierarchy.setHierarchy("ROLE_USER > ROLE_MEMBER");
|
||||
return roleHierarchy;
|
||||
@@ -982,11 +984,11 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void rootGet() {
|
||||
void rootGet() {
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public void rootPost() {
|
||||
void rootPost() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -995,7 +997,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
static class WildcardController {
|
||||
|
||||
@GetMapping("/{path}")
|
||||
public void wildcard(@PathVariable String path) {
|
||||
void wildcard(@PathVariable String path) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ public class NamespaceHttpBasicTests {
|
||||
static class UserConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
|
||||
@@ -192,15 +192,9 @@ public class NamespaceHttpCustomFilterTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build());
|
||||
// @formatter:on
|
||||
User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class NamespaceHttpFormLoginTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
|
||||
@@ -152,27 +152,27 @@ public class NamespaceHttpInterceptUrlTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/users")
|
||||
public String users() {
|
||||
String users() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/sessions")
|
||||
public String sessions() {
|
||||
String sessions() {
|
||||
return "sessions";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/post")
|
||||
public String adminPost() {
|
||||
String adminPost() {
|
||||
return "adminPost";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/another-post")
|
||||
public String adminAnotherPost() {
|
||||
String adminAnotherPost() {
|
||||
return "adminAnotherPost";
|
||||
}
|
||||
|
||||
@GetMapping("/signup")
|
||||
public String signup() {
|
||||
String signup() {
|
||||
return "signup";
|
||||
}
|
||||
|
||||
|
||||
@@ -147,12 +147,12 @@ public class NamespaceHttpJeeTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/authenticated")
|
||||
public String authenticated(Authentication authentication) {
|
||||
String authenticated(Authentication authentication) {
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
@GetMapping("/roles")
|
||||
public String roles(Authentication authentication) {
|
||||
String roles(Authentication authentication) {
|
||||
return authentication.getAuthorities().stream().map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
|
||||
@@ -293,15 +293,9 @@ public class NamespaceHttpOpenIDLoginTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build());
|
||||
// @formatter:on
|
||||
User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestCache requestCache() {
|
||||
RequestCache requestCache() {
|
||||
return mock(RequestCache.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ public class NamespaceSessionManagementTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockEventListener eventListener() {
|
||||
MockEventListener eventListener() {
|
||||
return spy(new MockEventListener());
|
||||
}
|
||||
|
||||
@@ -425,12 +425,12 @@ public class NamespaceSessionManagementTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/auth")
|
||||
public String auth(Principal principal) {
|
||||
String auth(Principal principal) {
|
||||
return principal.getName();
|
||||
}
|
||||
|
||||
@@ -444,17 +444,17 @@ public class NamespaceSessionManagementTests {
|
||||
|
||||
private Boolean exists = true;
|
||||
|
||||
public ResultMatcher exists(boolean exists) {
|
||||
ResultMatcher exists(boolean exists) {
|
||||
this.exists = exists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultMatcher valid(boolean valid) {
|
||||
ResultMatcher valid(boolean valid) {
|
||||
this.valid = valid;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
public ResultMatcher id(String id) {
|
||||
ResultMatcher id(String id) {
|
||||
this.id = id;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -344,7 +344,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -372,7 +372,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -402,7 +402,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -434,7 +434,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
|
||||
@@ -387,7 +387,7 @@ public class RequestCacheConfigurerTests {
|
||||
static class DefaultSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsManager() {
|
||||
InMemoryUserDetailsManager userDetailsManager() {
|
||||
// @formatter:off
|
||||
return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
|
||||
@@ -256,7 +256,7 @@ public class ServletApiConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager customAuthenticationManager() throws Exception {
|
||||
AuthenticationManager customAuthenticationManager() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ public class ServletApiConfigurerTests {
|
||||
static class AdminController {
|
||||
|
||||
@GetMapping("/admin")
|
||||
public void admin(HttpServletRequest request) {
|
||||
void admin(HttpServletRequest request) {
|
||||
if (!request.isUserInRole("ADMIN")) {
|
||||
throw new AccessDeniedException("This resource is only available to admins");
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class SessionManagementConfigurerSessionCreationPolicyTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String root() {
|
||||
String root() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ public class SessionManagementConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistry() {
|
||||
SessionRegistry sessionRegistry() {
|
||||
return SESSION_REGISTRY;
|
||||
}
|
||||
|
||||
@@ -538,12 +538,12 @@ public class SessionManagementConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistryOne() {
|
||||
SessionRegistry sessionRegistryOne() {
|
||||
return SESSION_REGISTRY_ONE;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistryTwo() {
|
||||
SessionRegistry sessionRegistryTwo() {
|
||||
return SESSION_REGISTRY_TWO;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ public class UrlAuthorizationConfigurerTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class UrlAuthorizationConfigurerTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
||||
@@ -265,20 +265,20 @@ public class OAuth2ClientConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return clientRegistrationRepository;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return authorizedClientRepository;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class ResourceController {
|
||||
class ResourceController {
|
||||
|
||||
@GetMapping("/resource1")
|
||||
public String resource1(
|
||||
String resource1(
|
||||
@RegisteredOAuth2AuthorizedClient("registration-1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return "resource1";
|
||||
}
|
||||
@@ -304,12 +304,12 @@ public class OAuth2ClientConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return clientRegistrationRepository;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return authorizedClientRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -1907,7 +1907,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JwtDecoder decoder() {
|
||||
JwtDecoder decoder() {
|
||||
return mock(JwtDecoder.class);
|
||||
}
|
||||
|
||||
@@ -1930,7 +1930,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@@ -1955,7 +1955,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
public OAuth2TokenValidator<Jwt> getJwtValidator() {
|
||||
OAuth2TokenValidator<Jwt> getJwtValidator() {
|
||||
return this.jwtValidator;
|
||||
}
|
||||
|
||||
@@ -2122,7 +2122,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@@ -2150,7 +2150,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@@ -2234,7 +2234,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
static class JwtDecoderConfig {
|
||||
|
||||
@Bean
|
||||
public JwtDecoder jwtDecoder() {
|
||||
JwtDecoder jwtDecoder() {
|
||||
return mock(JwtDecoder.class);
|
||||
}
|
||||
|
||||
@@ -2244,35 +2244,35 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String get() {
|
||||
String get() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@PostMapping("/post")
|
||||
public String post() {
|
||||
String post() {
|
||||
return "post";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/authenticated", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public String authenticated(Authentication authentication) {
|
||||
String authenticated(Authentication authentication) {
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
@GetMapping("/requires-read-scope")
|
||||
public String requiresReadScope(JwtAuthenticationToken token) {
|
||||
String requiresReadScope(JwtAuthenticationToken token) {
|
||||
return token.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@GetMapping("/ms-requires-read-scope")
|
||||
@PreAuthorize("hasAuthority('SCOPE_message:read')")
|
||||
public String msRequiresReadScope(JwtAuthenticationToken token) {
|
||||
String msRequiresReadScope(JwtAuthenticationToken token) {
|
||||
return requiresReadScope(token);
|
||||
}
|
||||
|
||||
@GetMapping("/ms-deny")
|
||||
@PreAuthorize("denyAll")
|
||||
public String deny() {
|
||||
String deny() {
|
||||
return "hmm, that's odd";
|
||||
}
|
||||
|
||||
@@ -2284,7 +2284,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
private final MockWebServer server = new MockWebServer();
|
||||
|
||||
@PreDestroy
|
||||
public void shutdown() throws IOException {
|
||||
void shutdown() throws IOException {
|
||||
this.server.shutdown();
|
||||
}
|
||||
|
||||
@@ -2297,7 +2297,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockWebServer web() {
|
||||
MockWebServer web() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@@ -2354,7 +2354,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public BearerTokenRequestPostProcessor asParam() {
|
||||
BearerTokenRequestPostProcessor asParam() {
|
||||
this.asRequestParameter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -270,13 +270,13 @@ public class EnableWebFluxSecurityTests {
|
||||
static class CustomPasswordEncoderConfig {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsService userDetailsService(PasswordEncoder encoder) {
|
||||
ReactiveUserDetailsService userDetailsService(PasswordEncoder encoder) {
|
||||
return new MapReactiveUserDetailsService(
|
||||
User.withUsername("user").password(encoder.encode("password")).roles("USER").build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PasswordEncoder passwordEncoder() {
|
||||
static PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class EnableWebFluxSecurityTests {
|
||||
static class MapReactiveUserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MapReactiveUserDetailsService userDetailsService() {
|
||||
MapReactiveUserDetailsService userDetailsService() {
|
||||
// @formatter:off
|
||||
return new MapReactiveUserDetailsService(User.withUsername("user")
|
||||
.password("{noop}password")
|
||||
@@ -304,14 +304,14 @@ public class EnableWebFluxSecurityTests {
|
||||
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Bean
|
||||
public SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||
http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")).authorizeExchange()
|
||||
.anyExchange().denyAll();
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) {
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ public class EnableWebFluxSecurityTests {
|
||||
static class AuthenticationPrincipalConfig {
|
||||
|
||||
@Bean
|
||||
public PrincipalBean principalBean() {
|
||||
PrincipalBean principalBean() {
|
||||
return new PrincipalBean();
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class EnableWebFluxSecurityTests {
|
||||
}
|
||||
|
||||
@RestController
|
||||
public static class AuthenticationPrincipalResolver {
|
||||
static class AuthenticationPrincipalResolver {
|
||||
|
||||
@GetMapping("/spel")
|
||||
String username(@AuthenticationPrincipal(expression = "@principalBean.username(#this)") String username) {
|
||||
@@ -352,12 +352,12 @@ public class EnableWebFluxSecurityTests {
|
||||
static class BeanProxyEnabledByDefaultConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -369,12 +369,12 @@ public class EnableWebFluxSecurityTests {
|
||||
static class BeanProxyDisabledConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ public class EnableWebFluxSecurityTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
static class MyController {
|
||||
|
||||
@MessageMapping("/authentication")
|
||||
public void authentication(@AuthenticationPrincipal String un) {
|
||||
void authentication(@AuthenticationPrincipal String un) {
|
||||
// ... do something ...
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MyController myController() {
|
||||
MyController myController() {
|
||||
return new MyController();
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
static class SyncExecutorConfig {
|
||||
|
||||
@Bean
|
||||
public static SyncExecutorSubscribableChannelPostProcessor postProcessor() {
|
||||
static SyncExecutorSubscribableChannelPostProcessor postProcessor() {
|
||||
return new SyncExecutorSubscribableChannelPostProcessor();
|
||||
}
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@@ -545,18 +545,22 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
// @formatter:on
|
||||
|
||||
@Bean
|
||||
public static SecurityExpressionHandler<Message<Object>> messageSecurityExpressionHandler() {
|
||||
static SecurityExpressionHandler<Message<Object>> messageSecurityExpressionHandler() {
|
||||
return new DefaultMessageSecurityExpressionHandler<Object>() {
|
||||
|
||||
@Override
|
||||
protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication,
|
||||
Message<Object> invocation) {
|
||||
return new MessageSecurityExpressionRoot(authentication, invocation) {
|
||||
|
||||
public boolean denyRob() {
|
||||
Authentication auth = getAuthentication();
|
||||
return auth != null && !"rob".equals(auth.getName());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class AuthenticationConfigurationGh3935Tests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return mock(UserDetailsService.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ public class GrantedAuthorityDefaultsJcTests {
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@@ -184,12 +184,12 @@ public class GrantedAuthorityDefaultsJcTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageService messageService() {
|
||||
MessageService messageService() {
|
||||
return new HelloWorldMessageService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
static GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
return new GrantedAuthorityDefaults("");
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanPropertiesResourceITes
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean
|
||||
.fromResource(new InMemoryResource("user=password,ROLE_USER"));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanPropertiesResourceLoca
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean.fromResourceLocation("classpath:users.properties");
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanStringITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean.fromString("user=password,ROLE_USER");
|
||||
}
|
||||
|
||||
|
||||
@@ -228,12 +228,12 @@ public class InterceptUrlConfigTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@RequestMapping("/path/{un}/path")
|
||||
public String path(@PathVariable("un") String name) {
|
||||
String path(@PathVariable("un") String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -751,12 +751,12 @@ public class MiscHttpConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@RequestMapping("/unprotected")
|
||||
public String unprotected() {
|
||||
String unprotected() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping("/protected")
|
||||
public String protectedMethod(@AuthenticationPrincipal String name) {
|
||||
String protectedMethod(@AuthenticationPrincipal String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ public class MiscHttpConfigTests {
|
||||
static class CustomKeyController {
|
||||
|
||||
@GetMapping("/customKey")
|
||||
public String customKey() {
|
||||
String customKey() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if (authentication != null && authentication instanceof AnonymousAuthenticationToken) {
|
||||
@@ -782,18 +782,18 @@ public class MiscHttpConfigTests {
|
||||
static class AuthenticationController {
|
||||
|
||||
@GetMapping("/password")
|
||||
public String password(@AuthenticationPrincipal Authentication authentication) {
|
||||
String password(@AuthenticationPrincipal Authentication authentication) {
|
||||
return (String) authentication.getCredentials();
|
||||
}
|
||||
|
||||
@GetMapping("/roles")
|
||||
public String roles(@AuthenticationPrincipal Authentication authentication) {
|
||||
String roles(@AuthenticationPrincipal Authentication authentication) {
|
||||
return authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public String details(@AuthenticationPrincipal Authentication authentication) {
|
||||
String details(@AuthenticationPrincipal Authentication authentication) {
|
||||
return authentication.getDetails().getClass().getName();
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ public class MiscHttpConfigTests {
|
||||
static class JaasController {
|
||||
|
||||
@GetMapping("/username")
|
||||
public String username() {
|
||||
String username() {
|
||||
Subject subject = Subject.getSubject(AccessController.getContext());
|
||||
return subject.getPrincipals().iterator().next().getName();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MultiHttpBlockConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/first")
|
||||
public String first() {
|
||||
String first() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public class OpenIDConfigTests {
|
||||
static class CustomLoginController {
|
||||
|
||||
@GetMapping("/login")
|
||||
public String custom() {
|
||||
String custom() {
|
||||
return "a custom login page";
|
||||
}
|
||||
|
||||
|
||||
@@ -534,12 +534,12 @@ public class SessionManagementConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/auth")
|
||||
public String auth(Principal principal) {
|
||||
String auth(Principal principal) {
|
||||
return principal.getName();
|
||||
}
|
||||
|
||||
@@ -553,17 +553,17 @@ public class SessionManagementConfigTests {
|
||||
|
||||
private Boolean exists = true;
|
||||
|
||||
public ResultMatcher exists(boolean exists) {
|
||||
ResultMatcher exists(boolean exists) {
|
||||
this.exists = exists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultMatcher valid(boolean valid) {
|
||||
ResultMatcher valid(boolean valid) {
|
||||
this.valid = valid;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
public ResultMatcher id(String id) {
|
||||
ResultMatcher id(String id) {
|
||||
this.id = id;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CustomHttpSecurityConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
// Typically externalize this as a properties file
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("permitAllPattern", "/public/**");
|
||||
@@ -160,7 +160,7 @@ public class CustomHttpSecurityConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
// Typically externalize this as a properties file
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("permitAllPattern", "/public/**");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class UserDetailsManagerResourceFactoryBeanPropertiesResourceITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromResource(new InMemoryResource("user=password,ROLE_USER"));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UserDetailsManagerResourceFactoryBeanPropertiesResourceLocationITes
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromResourceLocation("classpath:users.properties");
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UserDetailsManagerResourceFactoryBeanStringITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromString("user=password,ROLE_USER");
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ public class HttpsRedirectSpecTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PortMapper portMapper() {
|
||||
PortMapper portMapper() {
|
||||
return mock(PortMapper.class);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class HttpsRedirectSpecTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PortMapper portMapper() {
|
||||
PortMapper portMapper() {
|
||||
return mock(PortMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ public class OAuth2ClientSpecTests {
|
||||
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.oauth2Client()
|
||||
@@ -284,7 +284,7 @@ public class OAuth2ClientSpecTests {
|
||||
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.oauth2Client((oauth2Client) ->
|
||||
|
||||
@@ -566,7 +566,7 @@ public class OAuth2LoginTests {
|
||||
ServerAuthenticationFailureHandler failureHandler = mock(ServerAuthenticationFailureHandler.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -599,7 +599,7 @@ public class OAuth2LoginTests {
|
||||
ServerAuthenticationSuccessHandler successHandler = mock(ServerAuthenticationSuccessHandler.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange((exchanges) ->
|
||||
@@ -635,7 +635,7 @@ public class OAuth2LoginTests {
|
||||
ServerSecurityContextRepository securityContextRepository = mock(ServerSecurityContextRepository.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -657,12 +657,12 @@ public class OAuth2LoginTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ReactiveJwtDecoderFactory<ClientRegistration> jwtDecoderFactory() {
|
||||
ReactiveJwtDecoderFactory<ClientRegistration> jwtDecoderFactory() {
|
||||
return this.jwtDecoderFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient() {
|
||||
ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient() {
|
||||
return this.tokenResponseClient;
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ public class OAuth2LoginTests {
|
||||
.build();
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.csrf().disable()
|
||||
|
||||
@@ -444,7 +444,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
String username;
|
||||
|
||||
@MessageMapping("/message")
|
||||
public void authentication(@AuthenticationPrincipal String username) {
|
||||
void authentication(@AuthenticationPrincipal String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
MessageArgument messageArgument;
|
||||
|
||||
@MessageMapping("/message-with-argument")
|
||||
public void myCustom(MessageArgument messageArgument) {
|
||||
void myCustom(MessageArgument messageArgument) {
|
||||
this.messageArgument = messageArgument;
|
||||
}
|
||||
|
||||
@@ -531,10 +531,12 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
Message<Object> invocation) {
|
||||
|
||||
return new MessageSecurityExpressionRoot(authentication, invocation) {
|
||||
|
||||
public boolean denyNile() {
|
||||
Authentication auth = getAuthentication();
|
||||
return auth != null && !"nile".equals(auth.getName());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ final class HtmlUnitWebTestClient {
|
||||
this.webTestClient = webTestClient.mutate().filter(new FollowRedirects()).filter(new CookieManager()).build();
|
||||
}
|
||||
|
||||
public FluxExchangeResult<String> getResponse(WebRequest webRequest) {
|
||||
FluxExchangeResult<String> getResponse(WebRequest webRequest) {
|
||||
WebTestClient.RequestBodySpec request = this.webTestClient.method(httpMethod(webRequest)).uri(uri(webRequest));
|
||||
contentType(request, webRequest);
|
||||
cookies(request, webRequest);
|
||||
|
||||
@@ -50,7 +50,7 @@ final class MockWebResponseBuilder {
|
||||
this.exchangeResult = exchangeResult;
|
||||
}
|
||||
|
||||
public WebResponse build() throws IOException {
|
||||
WebResponse build() throws IOException {
|
||||
WebResponseData webResponseData = webResponseData();
|
||||
long endTime = System.currentTimeMillis();
|
||||
return new WebResponse(webResponseData, this.webRequest, endTime - this.startTime);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class WebTestClientHtmlUnitDriverBuilderTests {
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping(produces = MediaType.TEXT_HTML_VALUE)
|
||||
public String index() {
|
||||
String index() {
|
||||
return "<html>\n" + "<head>\n" + "<title>Hello World</title>\n" + "</head>\n" + "<body>\n"
|
||||
+ "<h1>Hello World</h1>\n" + "</body>\n" + "</html>";
|
||||
}
|
||||
@@ -83,13 +83,13 @@ public class WebTestClientHtmlUnitDriverBuilderTests {
|
||||
class CookieController {
|
||||
|
||||
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
|
||||
public String view(@CookieValue(required = false) String cookieName) {
|
||||
String view(@CookieValue(required = false) String cookieName) {
|
||||
return "<html>\n" + "<head>\n" + "<title>Hello World</title>\n" + "</head>\n" + "<body>\n" + "<h1>"
|
||||
+ TextEscapeUtils.escapeEntities(cookieName) + "</h1>\n" + "</body>\n" + "</html>";
|
||||
}
|
||||
|
||||
@GetMapping("/cookie")
|
||||
public Mono<Void> setCookie(ServerHttpResponse response) {
|
||||
Mono<Void> setCookie(ServerHttpResponse response) {
|
||||
response.addCookie(ResponseCookie.from("cookieName", "theCookie").build());
|
||||
return redirect(response);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class WebTestClientHtmlUnitDriverBuilderTests {
|
||||
}
|
||||
|
||||
@GetMapping("/cookie/delete")
|
||||
public Mono<Void> deleteCookie(ServerHttpResponse response) {
|
||||
Mono<Void> deleteCookie(ServerHttpResponse response) {
|
||||
response.addCookie(ResponseCookie.from("cookieName", "").maxAge(Duration.ofSeconds(0)).build());
|
||||
return redirect(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user