Apply code cleanup rules to projects
Apply automated cleanup rules to add `@Override` and `@Deprecated` annotations and to fix class references used with static methods. Issue gh-8945
This commit is contained in:
@@ -30,6 +30,7 @@ public class BeanNameCollectingPostProcessor implements BeanPostProcessor {
|
||||
|
||||
Set<String> afterInitPostProcessedBeans = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (beanName != null) {
|
||||
this.beforeInitPostProcessedBeans.add(beanName);
|
||||
@@ -37,6 +38,7 @@ public class BeanNameCollectingPostProcessor implements BeanPostProcessor {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (beanName != null) {
|
||||
this.afterInitPostProcessedBeans.add(beanName);
|
||||
|
||||
@@ -40,6 +40,7 @@ public class CollectingAppListener implements ApplicationListener {
|
||||
|
||||
Set<AbstractAuthorizationEvent> authorizationEvents = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof AbstractAuthenticationEvent) {
|
||||
this.events.add(event);
|
||||
|
||||
@@ -30,6 +30,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
|
||||
JdbcTemplate template;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.template, "dataSource required");
|
||||
|
||||
|
||||
@@ -24,15 +24,18 @@ import org.springframework.security.core.Authentication;
|
||||
|
||||
public class MockAfterInvocationProvider implements AfterInvocationProvider {
|
||||
|
||||
@Override
|
||||
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
|
||||
Object returnedObject) throws AccessDeniedException {
|
||||
return returnedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class MockEventListener<T extends ApplicationEvent> implements Applicatio
|
||||
|
||||
private List<T> events = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(T event) {
|
||||
this.events.add(event);
|
||||
}
|
||||
|
||||
@@ -27,13 +27,16 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
public class MockTransactionManager implements PlatformTransactionManager {
|
||||
|
||||
@Override
|
||||
public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
|
||||
return mock(TransactionStatus.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,12 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
*/
|
||||
public class MockUserServiceBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof PostProcessedMockUserDetailsService) {
|
||||
((PostProcessedMockUserDetailsService) bean).setPostProcessorWasHere("Hello from the post processor!");
|
||||
|
||||
@@ -34,6 +34,7 @@ public class PostProcessedMockUserDetailsService implements UserDetailsService {
|
||||
this.postProcessorWasHere = postProcessorWasHere;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
throw new UnsupportedOperationException("Not for actual use");
|
||||
}
|
||||
|
||||
@@ -23,13 +23,16 @@ import org.springframework.security.core.session.SessionCreationEvent;
|
||||
*/
|
||||
public class TestBusinessBeanImpl implements TestBusinessBean, ApplicationListener<SessionCreationEvent> {
|
||||
|
||||
@Override
|
||||
public void setInteger(int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger() {
|
||||
return 1314;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(String s) {
|
||||
}
|
||||
|
||||
@@ -37,12 +40,15 @@ public class TestBusinessBeanImpl implements TestBusinessBean, ApplicationListen
|
||||
return "A string.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSomething() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unprotected() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(SessionCreationEvent event) {
|
||||
System.out.println(event);
|
||||
}
|
||||
|
||||
@@ -22,20 +22,25 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
public class TransactionalTestBusinessBean implements TestBusinessBean {
|
||||
|
||||
@Override
|
||||
public void setInteger(int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(String s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void doSomething() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unprotected() {
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public class ObjectPostProcessorTests {
|
||||
|
||||
static class ListToLinkedListObjectPostProcessor implements ObjectPostProcessor<List<?>> {
|
||||
|
||||
@Override
|
||||
public <O extends List<?>> O postProcess(O l) {
|
||||
return (O) new LinkedList(l);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SecurityConfigurerAdapterClosureTests {
|
||||
|
||||
static class ConcereteSecurityConfigurerAdapter extends SecurityConfigurerAdapter<Object, SecurityBuilder<Object>> {
|
||||
|
||||
private List<Object> list = new ArrayList<Object>();
|
||||
private List<Object> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void configure(SecurityBuilder<Object> builder) throws Exception {
|
||||
|
||||
@@ -48,10 +48,12 @@ public class SecurityConfigurerAdapterTests {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String postProcess(String object) {
|
||||
return object + " " + this.order;
|
||||
|
||||
@@ -144,6 +144,7 @@ public class AuthenticationManagerBuilderTests {
|
||||
@EnableWebSecurity
|
||||
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -175,6 +176,7 @@ public class AuthenticationManagerBuilderTests {
|
||||
@EnableWebSecurity
|
||||
static class MultiAuthenticationProvidersConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser(PasswordEncodedUser.user()).and().inMemoryAuthentication()
|
||||
.withUser(PasswordEncodedUser.admin());
|
||||
|
||||
@@ -56,6 +56,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
@EnableWebSecurity
|
||||
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -83,6 +84,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
@EnableWebSecurity
|
||||
static class UserServiceRefConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -90,6 +92,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(PasswordEncodedUser.user());
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.security.config.test.SpringTestRule;
|
||||
import org.springframework.security.core.userdetails.PasswordEncodedUser;
|
||||
import org.springframework.security.core.userdetails.UserCache;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.provisioning.JdbcUserDetailsManager;
|
||||
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
|
||||
@@ -63,6 +63,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -99,6 +100,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -112,7 +114,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
// jdbc-user-service@authorities-by-username-query
|
||||
.authoritiesByUsernameQuery("select principal,role from roles where principal = ?")
|
||||
// jdbc-user-service@group-authorities-by-username-query
|
||||
.groupAuthoritiesByUsername(JdbcUserDetailsManager.DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY)
|
||||
.groupAuthoritiesByUsername(JdbcDaoImpl.DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY)
|
||||
// jdbc-user-service@role-prefix
|
||||
.rolePrefix("ROLE_");
|
||||
// @formatter:on
|
||||
|
||||
@@ -51,6 +51,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class PasswordEncoderConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
BCryptPasswordEncoder encoder = passwordEncoder();
|
||||
// @formatter:off
|
||||
@@ -82,6 +83,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class PasswordEncoderNoAuthManagerLoadsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
BCryptPasswordEncoder encoder = passwordEncoder();
|
||||
// @formatter:off
|
||||
|
||||
@@ -165,6 +165,7 @@ public class AuthenticationConfigurationTests {
|
||||
@Configuration
|
||||
static class UserGlobalAuthenticationConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser(PasswordEncodedUser.user());
|
||||
}
|
||||
@@ -217,6 +218,7 @@ public class AuthenticationConfigurationTests {
|
||||
|
||||
static class ServiceImpl implements Service {
|
||||
|
||||
@Override
|
||||
@Secured("ROLE_USER")
|
||||
public void run() {
|
||||
}
|
||||
@@ -238,10 +240,12 @@ public class AuthenticationConfigurationTests {
|
||||
static List<Class<?>> inits = new ArrayList<>();
|
||||
static List<Class<?>> configs = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
inits.add(getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(AuthenticationManagerBuilder auth) {
|
||||
configs.add(getClass());
|
||||
}
|
||||
@@ -288,6 +292,7 @@ public class AuthenticationConfigurationTests {
|
||||
|
||||
static class ConfiguresInMemoryConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -301,6 +306,7 @@ public class AuthenticationConfigurationTests {
|
||||
@Order(Ordered.LOWEST_PRECEDENCE)
|
||||
static class BootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.apply(new DefaultBootGlobalAuthenticationConfigurerAdapter());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
public class AroundMethodInterceptor implements MethodInterceptor {
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
||||
return String.valueOf(methodInvocation.proceed());
|
||||
}
|
||||
|
||||
@@ -73,10 +73,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
Assert.notNull(this.myUserRepository);
|
||||
return new AuthenticationProvider() {
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
Object principal = authentication.getPrincipal();
|
||||
String username = String.valueOf(principal);
|
||||
|
||||
@@ -77,11 +77,13 @@ public class NamespaceGlobalMethodSecurityExpressionHandlerTests {
|
||||
DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
|
||||
|
||||
expressionHandler.setPermissionEvaluator(new PermissionEvaluator() {
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject,
|
||||
Object permission) {
|
||||
return "granted".equals(targetDomainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
|
||||
Object permission) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -96,15 +96,18 @@ public class NamespaceGlobalMethodSecurityTests {
|
||||
|
||||
public static class DenyAllAccessDecisionManager implements AccessDecisionManager {
|
||||
|
||||
@Override
|
||||
public void decide(Authentication authentication, Object object,
|
||||
Collection<ConfigAttribute> configAttributes) {
|
||||
throw new AccessDeniedException("Always Denied");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
@@ -133,16 +136,19 @@ public class NamespaceGlobalMethodSecurityTests {
|
||||
|
||||
public static class AfterInvocationManagerStub implements AfterInvocationManager {
|
||||
|
||||
@Override
|
||||
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> attributes,
|
||||
Object returnedObject) throws AccessDeniedException {
|
||||
|
||||
throw new AccessDeniedException("custom AfterInvocationManager");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
@@ -224,6 +230,7 @@ public class NamespaceGlobalMethodSecurityTests {
|
||||
@Override
|
||||
protected MethodSecurityMetadataSource customMethodSecurityMetadataSource() {
|
||||
return new AbstractMethodSecurityMetadataSource() {
|
||||
@Override
|
||||
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
|
||||
// require ROLE_NOBODY for any method on MethodSecurityService
|
||||
// interface
|
||||
@@ -231,6 +238,7 @@ public class NamespaceGlobalMethodSecurityTests {
|
||||
? Arrays.asList(new SecurityConfig("ROLE_NOBODY")) : Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ConfigAttribute> getAllConfigAttributes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -125,10 +125,12 @@ public class SampleEnableGlobalMethodSecurityTests {
|
||||
|
||||
static class CustomPermissionEvaluator implements PermissionEvaluator {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
|
||||
return !"denied".equals(targetDomainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
|
||||
Object permission) {
|
||||
return !"denied".equals(targetId);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.PriorityOrdered;
|
||||
import org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource;
|
||||
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
||||
@@ -153,7 +154,7 @@ public class Sec2758Tests {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return PriorityOrdered.HIGHEST_PRECEDENCE;
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ public class AbstractConfiguredSecurityBuilderTests {
|
||||
super(objectPostProcessor, allowConfigurersOfSameType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object performBuild() {
|
||||
return "success";
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class AbstractRequestMatcherRegistryAnyMatcherTests {
|
||||
@EnableWebSecurity
|
||||
static class AntMatchersAfterAnyRequestConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -55,6 +56,7 @@ public class AbstractRequestMatcherRegistryAnyMatcherTests {
|
||||
@EnableWebSecurity
|
||||
static class MvcMatchersAfterAnyRequestConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -75,6 +77,7 @@ public class AbstractRequestMatcherRegistryAnyMatcherTests {
|
||||
@EnableWebSecurity
|
||||
static class RegexMatchersAfterAnyRequestConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -95,6 +98,7 @@ public class AbstractRequestMatcherRegistryAnyMatcherTests {
|
||||
@EnableWebSecurity
|
||||
static class AnyRequestAfterItselfConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -115,6 +119,7 @@ public class AbstractRequestMatcherRegistryAnyMatcherTests {
|
||||
@EnableWebSecurity
|
||||
static class RequestMatchersAfterAnyRequestConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -374,6 +374,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
|
||||
@Order(1)
|
||||
public static class ApiWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -72,6 +72,7 @@ public class HttpConfigurationTests {
|
||||
@EnableWebSecurity
|
||||
static class UnregisteredFilterConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -79,6 +80,7 @@ public class HttpConfigurationTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -116,6 +118,7 @@ public class HttpConfigurationTests {
|
||||
|
||||
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -453,6 +453,7 @@ public class NamespaceHttpTests {
|
||||
|
||||
static class MyRequestMatcher implements RequestMatcher {
|
||||
|
||||
@Override
|
||||
public boolean matches(HttpServletRequest request) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class Sec2515Tests {
|
||||
|
||||
static AuthenticationManager AUTHENTICATION_MANAGER;
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager() {
|
||||
return AUTHENTICATION_MANAGER;
|
||||
|
||||
@@ -81,14 +81,17 @@ public class AbstractConfigAttributeRequestMatcherRegistryTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<RequestMatcher> chainRequestMatchersInternal(List<RequestMatcher> requestMatchers) {
|
||||
return requestMatchers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RequestMatcher> mvcMatchers(String... mvcPatterns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RequestMatcher> mvcMatchers(HttpMethod method, String... mvcPatterns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public class AnonymousConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -151,6 +152,7 @@ public class AnonymousConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
|
||||
@@ -122,6 +122,7 @@ public class DefaultFiltersTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.formLogin();
|
||||
}
|
||||
@@ -197,6 +198,7 @@ public class DefaultFiltersTests {
|
||||
@EnableWebSecurity
|
||||
static class DefaultFiltersConfigPermitAll extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) {
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class NoRequestsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -682,6 +683,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
.authorizeRequests()
|
||||
.anyRequest().permitAll()
|
||||
.withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
|
||||
@Override
|
||||
public <O extends FilterSecurityInterceptor> O postProcess(
|
||||
O fsi) {
|
||||
fsi.setPublishAuthorizationSuccess(true);
|
||||
|
||||
@@ -265,6 +265,7 @@ public class HttpBasicConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
|
||||
@@ -82,6 +82,7 @@ public class HttpSecurityAntMatchersTests {
|
||||
@Configuration
|
||||
static class AntMatchersNoPatternsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -118,6 +119,7 @@ public class HttpSecurityAntMatchersTests {
|
||||
@Configuration
|
||||
static class AntMatchersEmptyPatternsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -90,6 +90,7 @@ public class HttpSecurityLogoutTests {
|
||||
@Configuration
|
||||
static class ClearAuthenticationFalseConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -153,6 +153,7 @@ public class Issue55Tests {
|
||||
|
||||
static Authentication RESULT = new TestingAuthenticationToken("test", "this", "ROLE_USER");
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
return RESULT;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ public class NamespaceHttpAnonymousTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
|
||||
@@ -94,6 +94,7 @@ public class NamespaceHttpBasicTests {
|
||||
@EnableWebSecurity
|
||||
static class HttpBasicConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -121,6 +122,7 @@ public class NamespaceHttpBasicTests {
|
||||
@EnableWebSecurity
|
||||
static class HttpBasicLambdaConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -68,6 +68,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
@EnableWebSecurity
|
||||
static class CustomFilterBeforeConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -87,6 +88,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
@EnableWebSecurity
|
||||
static class CustomFilterAfterConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -111,6 +113,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -136,6 +139,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -158,6 +162,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthenticationManager authenticationManager() {
|
||||
return new CustomAuthenticationManager();
|
||||
}
|
||||
@@ -198,6 +203,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
|
||||
static class OtherCustomFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
filterChain.doFilter(request, response);
|
||||
@@ -207,6 +213,7 @@ public class NamespaceHttpCustomFilterTests {
|
||||
|
||||
static class CustomAuthenticationManager implements AuthenticationManager {
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public class NamespaceHttpFormLoginTests {
|
||||
@EnableWebSecurity
|
||||
static class FormLoginCustomConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
boolean alwaysUseDefaultSuccess = true;
|
||||
// @formatter:off
|
||||
@@ -143,6 +144,7 @@ public class NamespaceHttpFormLoginTests {
|
||||
@EnableWebSecurity
|
||||
static class FormLoginCustomRefsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||
successHandler.setDefaultTargetUrl("/custom/targetUrl");
|
||||
|
||||
@@ -131,6 +131,7 @@ public class NamespaceHttpInterceptUrlTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
|
||||
@@ -229,7 +229,7 @@ public class NamespaceHttpLogoutTests {
|
||||
|
||||
ResultMatcher session(Predicate<HttpSession> sessionPredicate) {
|
||||
return result -> assertThat(result.getRequest().getSession(false))
|
||||
.is(new Condition<HttpSession>(sessionPredicate, "sessionPredicate failed"));
|
||||
.is(new Condition<>(sessionPredicate, "sessionPredicate failed"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class NamespaceHttpPortMappingsTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
|
||||
@@ -67,6 +67,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
@EnableWebSecurity
|
||||
static class RequestCacheRefConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -78,6 +79,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
@@ -108,6 +110,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
@EnableWebSecurity
|
||||
static class DefaultRequestCacheRefConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -116,6 +119,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
|
||||
@@ -68,6 +68,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
|
||||
@EnableWebSecurity
|
||||
static class AccessDeniedPageConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -96,6 +97,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
|
||||
@EnableWebSecurity
|
||||
static class AccessDeniedPageInLambdaConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -122,6 +124,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
|
||||
@EnableWebSecurity
|
||||
static class AccessDeniedHandlerRefConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -155,6 +158,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
|
||||
|
||||
static AccessDeniedHandler accessDeniedHandler = mock(AccessDeniedHandler.class);
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -268,10 +268,12 @@ public class NamespaceHttpX509Tests {
|
||||
@EnableWebSecurity
|
||||
public static class AuthenticationUserDetailsServiceConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("rod").password("password").roles("USER", "ADMIN");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -392,6 +392,7 @@ public class NamespaceSessionManagementTests {
|
||||
|
||||
List<SessionFixationProtectionEvent> events = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(SessionFixationProtectionEvent event) {
|
||||
this.events.add(event);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ public class RememberMeConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class NullUserDetailsConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -188,6 +189,7 @@ public class RememberMeConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
@@ -327,6 +329,7 @@ public class RememberMeConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class RememberMeCookieDomainConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -363,6 +366,7 @@ public class RememberMeConfigurerTests {
|
||||
@EnableWebSecurity
|
||||
static class RememberMeCookieDomainInLambdaConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
@@ -401,6 +405,7 @@ public class RememberMeConfigurerTests {
|
||||
|
||||
static RememberMeServices REMEMBER_ME = mock(RememberMeServices.class);
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
|
||||
@@ -1560,6 +1560,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
@@ -1640,6 +1641,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
|
||||
@@ -150,6 +150,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
@EnableWebSocketMessageBroker
|
||||
static class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/chat").withSockJS();
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
static class MsmsRegistryCustomPatternMatcherConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry
|
||||
.addEndpoint("/other")
|
||||
@@ -330,6 +331,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry
|
||||
.addEndpoint("/other")
|
||||
@@ -382,6 +384,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
static class DefaultPatternMatcherConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry
|
||||
.addEndpoint("/other")
|
||||
@@ -467,6 +470,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
static class CustomExpressionConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry
|
||||
.addEndpoint("/other")
|
||||
@@ -596,10 +600,12 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
|
||||
static class MyCustomArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.getParameterType().isAssignableFrom(MyCustomArgument.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, Message<?> message) {
|
||||
return new MyCustomArgument("");
|
||||
}
|
||||
@@ -610,6 +616,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
|
||||
Map<String, Object> attributes;
|
||||
|
||||
@Override
|
||||
public boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
|
||||
Map<String, Object> attributes) throws HandshakeFailureException {
|
||||
this.attributes = attributes;
|
||||
@@ -630,6 +637,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
@Import(SyncExecutorConfig.class)
|
||||
static class SockJsSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/other").setHandshakeHandler(testHandshakeHandler()).withSockJS()
|
||||
.setInterceptors(new HttpSessionHandshakeInterceptor());
|
||||
@@ -687,6 +695,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
@Import(SyncExecutorConfig.class)
|
||||
static class NoInboundSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/other").withSockJS().setInterceptors(new HttpSessionHandshakeInterceptor());
|
||||
|
||||
@@ -725,6 +734,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
@Import(SyncExecutorConfig.class)
|
||||
static class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/websocket").setHandshakeHandler(testHandshakeHandler())
|
||||
.addInterceptors(new HttpSessionHandshakeInterceptor());
|
||||
@@ -754,6 +764,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/chat").setHandshakeHandler(this.context.getBean(TestHandshakeHandler.class))
|
||||
.withSockJS().setInterceptors(new HttpSessionHandshakeInterceptor());
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.messaging.support.ExecutorSubscribableChannel;
|
||||
*/
|
||||
public class SyncExecutorSubscribableChannelPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof ExecutorSubscribableChannel) {
|
||||
ExecutorSubscribableChannel original = (ExecutorSubscribableChannel) bean;
|
||||
@@ -34,6 +35,7 @@ public class SyncExecutorSubscribableChannelPostProcessor implements BeanPostPro
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
|
||||
|
||||
List<AbstractAuthenticationEvent> events = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(AbstractAuthenticationEvent event) {
|
||||
this.events.add(event);
|
||||
}
|
||||
|
||||
@@ -24,11 +24,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
*/
|
||||
public class HelloWorldMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('USER')")
|
||||
public String getMessage() {
|
||||
return "Hello World";
|
||||
}
|
||||
|
||||
@Override
|
||||
@RolesAllowed("USER")
|
||||
public String getJsrMessage() {
|
||||
return "Hello JSR";
|
||||
|
||||
@@ -35,10 +35,12 @@ public class TestAuthenticationProvider implements AuthenticationProvider {
|
||||
public TestAuthenticationProvider(AuthProviderDependency authProviderDependency) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.support.RequestDataValueProcessor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -148,8 +147,7 @@ public class CsrfConfigTests {
|
||||
public void traceWhenDefaultConfigurationThenCsrfIsEnabled() throws Exception {
|
||||
this.spring.configLocations(this.xml("shared-controllers"), this.xml("AutoConfig")).autowire();
|
||||
|
||||
MockMvc traceEnabled = MockMvcBuilders.webAppContextSetup((WebApplicationContext) this.spring.getContext())
|
||||
.apply(springSecurity())
|
||||
MockMvc traceEnabled = MockMvcBuilders.webAppContextSetup(this.spring.getContext()).apply(springSecurity())
|
||||
.addDispatcherServletCustomizer(dispatcherServlet -> dispatcherServlet.setDispatchTraceRequest(true))
|
||||
.build();
|
||||
|
||||
@@ -226,8 +224,7 @@ public class CsrfConfigTests {
|
||||
public void traceWhenCsrfElementEnabledThenOk() throws Exception {
|
||||
this.spring.configLocations(this.xml("shared-controllers"), this.xml("CsrfEnabled")).autowire();
|
||||
|
||||
MockMvc traceEnabled = MockMvcBuilders.webAppContextSetup((WebApplicationContext) this.spring.getContext())
|
||||
.apply(springSecurity())
|
||||
MockMvc traceEnabled = MockMvcBuilders.webAppContextSetup(this.spring.getContext()).apply(springSecurity())
|
||||
.addDispatcherServletCustomizer(dispatcherServlet -> dispatcherServlet.setDispatchTraceRequest(true))
|
||||
.build();
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ public class InterceptUrlConfigTests {
|
||||
this.spring.configLocations(this.xml("MvcMatchersServletPath")).autowire();
|
||||
|
||||
MockServletContext servletContext = mockServletContext("/spring");
|
||||
ConfigurableWebApplicationContext context = (ConfigurableWebApplicationContext) this.spring.getContext();
|
||||
ConfigurableWebApplicationContext context = this.spring.getContext();
|
||||
context.setServletContext(servletContext);
|
||||
|
||||
this.mvc.perform(get("/spring/path").servletPath("/spring")).andExpect(status().isUnauthorized());
|
||||
|
||||
@@ -517,16 +517,17 @@ public class MiscHttpConfigTests {
|
||||
|
||||
@Test
|
||||
public void configureWhenUserDetailsServiceInParentContextThenLocatesSuccessfully() {
|
||||
assertThatCode(() -> this.spring.configLocations(this.xml("MissingUserDetailsService")).autowire())
|
||||
.isInstanceOf(BeansException.class);
|
||||
assertThatCode(
|
||||
() -> this.spring.configLocations(MiscHttpConfigTests.xml("MissingUserDetailsService")).autowire())
|
||||
.isInstanceOf(BeansException.class);
|
||||
|
||||
try (XmlWebApplicationContext parent = new XmlWebApplicationContext()) {
|
||||
parent.setConfigLocations(this.xml("AutoConfig"));
|
||||
parent.setConfigLocations(MiscHttpConfigTests.xml("AutoConfig"));
|
||||
parent.refresh();
|
||||
|
||||
try (XmlWebApplicationContext child = new XmlWebApplicationContext()) {
|
||||
child.setParent(parent);
|
||||
child.setConfigLocation(this.xml("MissingUserDetailsService"));
|
||||
child.setConfigLocation(MiscHttpConfigTests.xml("MissingUserDetailsService"));
|
||||
child.refresh();
|
||||
}
|
||||
}
|
||||
@@ -810,6 +811,7 @@ public class MiscHttpConfigTests {
|
||||
|
||||
static class MockAuthenticationManager implements AuthenticationManager {
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) {
|
||||
return new TestingAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials(),
|
||||
AuthorityUtils.createAuthorityList("ROLE_USER"));
|
||||
|
||||
@@ -612,7 +612,7 @@ public class SessionManagementConfigTests {
|
||||
}
|
||||
|
||||
private ServletContext servletContext() {
|
||||
WebApplicationContext context = (WebApplicationContext) this.spring.getContext();
|
||||
WebApplicationContext context = this.spring.getContext();
|
||||
return context.getServletContext();
|
||||
}
|
||||
|
||||
|
||||
@@ -401,6 +401,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
return this.authenticationManager.authenticate(authentication);
|
||||
}
|
||||
@@ -412,6 +413,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
* org.springframework.context.ApplicationContextAware#setApplicationContext(org
|
||||
* .springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.authenticationManager = applicationContext.getBean(this.beanName, AuthenticationManager.class);
|
||||
}
|
||||
@@ -434,6 +436,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||
|
||||
public static class ConcreteFoo implements Foo<SecurityConfig> {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("#action.attribute == 'A'")
|
||||
public void foo(SecurityConfig action) {
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements Application
|
||||
this.transactionalTarget.doSomething();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.appContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ import org.springframework.security.core.Authentication;
|
||||
|
||||
public class TestPermissionEvaluator implements PermissionEvaluator {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
|
||||
Object permission) {
|
||||
return false;
|
||||
|
||||
@@ -36,10 +36,12 @@ public class JpaPermissionEvaluator implements PermissionEvaluator {
|
||||
System.out.println("initializing " + this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
|
||||
Object permission) {
|
||||
return true;
|
||||
|
||||
@@ -135,7 +135,8 @@ public class ClientRegistrationsBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void parseWhenMultipleClientsConfiguredThenAvailableInRepository() {
|
||||
this.spring.configLocations(this.xml("MultiClientRegistration")).autowire();
|
||||
this.spring.configLocations(ClientRegistrationsBeanDefinitionParserTests.xml("MultiClientRegistration"))
|
||||
.autowire();
|
||||
|
||||
assertThat(this.clientRegistrationRepository).isInstanceOf(InMemoryClientRegistrationRepository.class);
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ public class SpringTestContext implements Closeable {
|
||||
|
||||
private class AddFilter implements MockMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder,
|
||||
WebApplicationContext context) {
|
||||
builder.addFilters(SpringTestContext.this.filters.toArray(new Filter[0]));
|
||||
|
||||
@@ -31,6 +31,7 @@ public class SpringTestRule extends SpringTestContext implements MethodRule {
|
||||
@Override
|
||||
public Statement apply(Statement base, FrameworkMethod method, Object target) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
setTest(target);
|
||||
try {
|
||||
|
||||
@@ -72,6 +72,7 @@ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Resource[] getConfigResources() {
|
||||
return new Resource[] { this.inMemoryXml };
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class OAuth2LoginTests {
|
||||
|
||||
FormLoginTests.DefaultLoginPage loginPage = FormLoginTests.HomePage
|
||||
.to(driver, FormLoginTests.DefaultLoginPage.class).assertAt().assertLoginFormNotPresent().oauth2Login()
|
||||
.assertClientRegistrationByName(this.github.getClientName()).and();
|
||||
.assertClientRegistrationByName(OAuth2LoginTests.github.getClientName()).and();
|
||||
}
|
||||
|
||||
@EnableWebFluxSecurity
|
||||
|
||||
@@ -306,7 +306,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
public void requestWhenConnectMessageThenUsesCsrfTokenHandshakeInterceptor() throws Exception {
|
||||
this.spring.configLocations(xml("SyncConfig")).autowire();
|
||||
|
||||
WebApplicationContext context = (WebApplicationContext) this.spring.getContext();
|
||||
WebApplicationContext context = this.spring.getContext();
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
|
||||
String csrfAttributeName = CsrfToken.class.getName();
|
||||
@@ -329,7 +329,7 @@ public class WebSocketMessageBrokerConfigTests {
|
||||
public void requestWhenConnectMessageAndUsingSockJsThenUsesCsrfTokenHandshakeInterceptor() throws Exception {
|
||||
this.spring.configLocations(xml("SyncSockJsConfig")).autowire();
|
||||
|
||||
WebApplicationContext context = (WebApplicationContext) this.spring.getContext();
|
||||
WebApplicationContext context = this.spring.getContext();
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
|
||||
String csrfAttributeName = CsrfToken.class.getName();
|
||||
|
||||
Reference in New Issue
Block a user