1
0
mirror of synced 2026-08-05 17:57:15 +00:00

Remove redundant throws clauses

Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
This commit is contained in:
Lars Grefer
2019-08-23 01:03:54 +02:00
parent f0515a021c
commit 34dd5fea30
418 changed files with 1146 additions and 1273 deletions
@@ -59,7 +59,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
}
@Test
public void beanClassNamesAreCorrect() throws Exception {
public void beanClassNamesAreCorrect() {
assertThat(FilterBasedLdapUserSearch.class.getName()).isEqualTo(LDAP_SEARCH_CLASS);
assertThat(PersonContextMapper.class.getName()).isEqualTo(PERSON_MAPPER_CLASS);
assertThat(InetOrgPersonContextMapper.class.getName()).isEqualTo(INET_ORG_PERSON_MAPPER_CLASS);
@@ -69,12 +69,12 @@ public class LdapUserServiceBeanDefinitionParserTests {
}
@Test
public void minimalConfigurationIsParsedOk() throws Exception {
public void minimalConfigurationIsParsedOk() {
setContext("<ldap-user-service user-search-filter='(uid={0})' /><ldap-server ldif='classpath:test-server.ldif' url='ldap://127.0.0.1:343/dc=springframework,dc=org' />");
}
@Test
public void userServiceReturnsExpectedData() throws Exception {
public void userServiceReturnsExpectedData() {
setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
@@ -86,7 +86,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
}
@Test
public void differentUserSearchBaseWorksAsExpected() throws Exception {
public void differentUserSearchBaseWorksAsExpected() {
setContext("<ldap-user-service id='ldapUDS' "
+ " user-search-base='ou=otherpeople' "
+ " user-search-filter='(cn={0})' "
@@ -99,7 +99,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
}
@Test
public void rolePrefixIsSupported() throws Exception {
public void rolePrefixIsSupported() {
setContext("<ldap-user-service id='ldapUDS' "
+ " user-search-filter='(uid={0})' "
+ " group-search-filter='member={0}' role-prefix='PREFIX_'/>"
@@ -117,7 +117,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
}
@Test
public void differentGroupRoleAttributeWorksAsExpected() throws Exception {
public void differentGroupRoleAttributeWorksAsExpected() {
setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-role-attribute='ou' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
@@ -183,10 +183,9 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* {@link SecurityConfigurer#init(SecurityBuilder)} immediately if necessary.
*
* @param configurer the {@link SecurityConfigurer} to add
* @throws Exception if an error occurs
*/
@SuppressWarnings("unchecked")
private <C extends SecurityConfigurer<O, B>> void add(C configurer) throws Exception {
private <C extends SecurityConfigurer<O, B>> void add(C configurer) {
Assert.notNull(configurer, "configurer cannot be null");
Class<? extends SecurityConfigurer<O, B>> clazz = (Class<? extends SecurityConfigurer<O, B>>) configurer
@@ -344,7 +343,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* method. Subclasses may override this method to hook into the lifecycle without
* using a {@link SecurityConfigurer}.
*/
protected void beforeInit() throws Exception {
protected void beforeInit() {
}
/**
@@ -228,7 +228,7 @@ public class AuthenticationManagerBuilder
}
@Override
protected ProviderManager performBuild() throws Exception {
protected ProviderManager performBuild() {
if (!isConfigured()) {
logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
return null;
@@ -128,7 +128,7 @@ public class AuthenticationConfiguration {
@Autowired(required = false)
public void setGlobalAuthenticationConfigurers(
List<GlobalAuthenticationConfigurerAdapter> configurers) throws Exception {
List<GlobalAuthenticationConfigurerAdapter> configurers) {
configurers.sort(AnnotationAwareOrderComparator.INSTANCE);
this.globalAuthConfigurers = configurers;
}
@@ -55,7 +55,7 @@ class InitializeAuthenticationProviderBeanManagerConfigurer
class InitializeUserDetailsManagerConfigurer
extends GlobalAuthenticationConfigurerAdapter {
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
public void configure(AuthenticationManagerBuilder auth) {
if (auth.isConfigured()) {
return;
}
@@ -64,10 +64,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
*
* @param dataSource the {@link DataSource} to be used. Cannot be null.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> dataSource(DataSource dataSource)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> dataSource(DataSource dataSource) {
this.dataSource = dataSource;
getUserDetailsService().setDataSource(dataSource);
return this;
@@ -83,10 +81,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* is enabled by username. Must contain a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(String query)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(String query) {
getUserDetailsService().setUsersByUsernameQuery(query);
return this;
}
@@ -103,10 +99,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* Must contain a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(String query)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(String query) {
getUserDetailsService().setAuthoritiesByUsernameQuery(query);
return this;
}
@@ -127,10 +121,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(String query)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(String query) {
JdbcUserDetailsManager userDetailsService = getUserDetailsService();
userDetailsService.setEnableGroups(true);
userDetailsService.setGroupAuthoritiesByUsernameQuery(query);
@@ -143,10 +135,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
*
* @param rolePrefix
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> rolePrefix(String rolePrefix)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> rolePrefix(String rolePrefix) {
getUserDetailsService().setRolePrefix(rolePrefix);
return this;
}
@@ -156,10 +146,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
*
* @param userCache the {@link UserCache} to use
* @return the {@link JdbcUserDetailsManagerConfigurer} for further customizations
* @throws Exception
*/
public JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache)
throws Exception {
public JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache) {
getUserDetailsService().setUserCache(userCache);
return this;
}
@@ -97,7 +97,7 @@ final class AutowireBeanFactoryObjectPostProcessor
*
* @see org.springframework.beans.factory.DisposableBean#destroy()
*/
public void destroy() throws Exception {
public void destroy() {
for (DisposableBean disposable : this.disposableBeans) {
try {
disposable.destroy();
@@ -46,7 +46,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) throws Exception {
public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) {
MethodSecurityMetadataSourceAdvisor advisor = new MethodSecurityMetadataSourceAdvisor(
"securityMethodInterceptor", source, "methodMetadataSource");
advisor.setOrder(advisorOrder);
@@ -2325,7 +2325,7 @@ public final class HttpSecurity extends
}
@Override
protected DefaultSecurityFilterChain performBuild() throws Exception {
protected DefaultSecurityFilterChain performBuild() {
filters.sort(comparator);
return new DefaultSecurityFilterChain(requestMatcher, filters);
}
@@ -2633,9 +2633,8 @@ public final class HttpSecurity extends
* @param requestMatcherCustomizer the {@link Customizer} to provide more options for
* the {@link RequestMatcherConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
*/
public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) throws Exception {
public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) {
requestMatcherCustomizer.customize(requestMatcherConfigurer);
return HttpSecurity.this;
}
@@ -108,11 +108,10 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
* Creates the {@link WebInvocationPrivilegeEvaluator} that is necessary for the JSP
* tag support.
* @return the {@link WebInvocationPrivilegeEvaluator}
* @throws Exception
*/
@Bean
@DependsOn(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
public WebInvocationPrivilegeEvaluator privilegeEvaluator() throws Exception {
public WebInvocationPrivilegeEvaluator privilegeEvaluator() {
return webSecurity.getPrivilegeEvaluator();
}
@@ -331,7 +331,7 @@ public abstract class WebSecurityConfigurerAdapter implements
* Override this method to configure {@link WebSecurity}. For example, if you wish to
* ignore certain requests.
*/
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
}
/**
@@ -145,7 +145,7 @@ public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
if (authenticationProvider == null) {
authenticationProvider = new AnonymousAuthenticationProvider(getKey());
}
@@ -158,7 +158,7 @@ public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
authenticationFilter.afterPropertiesSet();
http.addFilter(authenticationFilter);
}
@@ -98,7 +98,7 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>> e
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
ChannelDecisionManagerImpl channelDecisionManager = new ChannelDecisionManagerImpl();
channelDecisionManager.setChannelProcessors(getChannelProcessors(http));
channelDecisionManager = postProcess(channelDecisionManager);
@@ -60,7 +60,7 @@ public class CorsConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
CorsFilter corsFilter = getCorsFilter(context);
@@ -203,7 +203,7 @@ public final class CsrfConfigurer<H extends HttpSecurityBuilder<H>>
@SuppressWarnings("unchecked")
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
CsrfFilter filter = new CsrfFilter(this.csrfTokenRepository);
RequestMatcher requireCsrfProtectionMatcher = getRequireCsrfProtectionMatcher();
if (requireCsrfProtectionMatcher != null) {
@@ -73,7 +73,7 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
private DefaultLogoutPageGeneratingFilter logoutPageGeneratingFilter = new DefaultLogoutPageGeneratingFilter();
@Override
public void init(H http) throws Exception {
public void init(H http) {
Function<HttpServletRequest, Map<String, String>> hiddenInputs = request -> {
CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
if (token == null) {
@@ -89,7 +89,7 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
@Override
@SuppressWarnings("unchecked")
public void configure(H http) throws Exception {
public void configure(H http) {
AuthenticationEntryPoint authenticationEntryPoint = null;
ExceptionHandlingConfigurer<?> exceptionConf = http
.getConfigurer(ExceptionHandlingConfigurer.class);
@@ -188,7 +188,7 @@ public final class ExceptionHandlingConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http);
ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(
entryPoint, getRequestCache(http));
@@ -899,7 +899,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
HeaderWriterFilter headersFilter = createHeaderWriterFilter();
http.addFilter(headersFilter);
}
@@ -91,10 +91,9 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
/**
* Creates a new instance
* @throws Exception
* @see HttpSecurity#httpBasic()
*/
public HttpBasicConfigurer() throws Exception {
public HttpBasicConfigurer() {
realmName(DEFAULT_REALM);
LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
@@ -150,7 +149,7 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
}
@Override
public void init(B http) throws Exception {
public void init(B http) {
registerDefaults(http);
}
@@ -204,7 +203,7 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
}
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
AuthenticationManager authenticationManager = http
.getSharedObject(AuthenticationManager.class);
BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter(
@@ -192,7 +192,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
* @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder)
*/
@Override
public void init(H http) throws Exception {
public void init(H http) {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider
.setPreAuthenticatedUserDetailsService(getUserDetailsService());
@@ -206,7 +206,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
J2eePreAuthenticatedProcessingFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class));
http.addFilter(filter);
@@ -270,7 +270,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
if (permitAll) {
PermitAllSupport.permitAll(http, this.logoutSuccessUrl);
PermitAllSupport.permitAll(http, this.getLogoutRequestMatcher(http));
@@ -325,9 +325,8 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
*
* @param http the builder to use
* @return the {@link LogoutFilter} to use.
* @throws Exception
*/
private LogoutFilter createLogoutFilter(H http) throws Exception {
private LogoutFilter createLogoutFilter(H http) {
logoutHandlers.add(contextLogoutHandler);
LogoutHandler[] handlers = logoutHandlers
.toArray(new LogoutHandler[0]);
@@ -62,7 +62,7 @@ public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>> extend
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
http.setSharedObject(PortMapper.class, getPortMapper());
}
@@ -282,7 +282,7 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
RememberMeAuthenticationFilter rememberMeFilter = new RememberMeAuthenticationFilter(
http.getSharedObject(AuthenticationManager.class),
this.rememberMeServices);
@@ -373,10 +373,8 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
* @param http the {@link HttpSecurity} to lookup shared objects
* @param key the {@link #key(String)}
* @return the {@link RememberMeServices} to use
* @throws Exception
*/
private AbstractRememberMeServices createRememberMeServices(H http, String key)
throws Exception {
private AbstractRememberMeServices createRememberMeServices(H http, String key) {
return this.tokenRepository == null
? createTokenBasedRememberMeServices(http, key)
: createPersistentRememberMeServices(http, key);
@@ -441,4 +439,4 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
}
return this.key;
}
}
}
@@ -95,12 +95,12 @@ public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>> exte
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
http.setSharedObject(RequestCache.class, getRequestCache(http));
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
RequestCache requestCache = getRequestCache(http);
RequestCacheAwareFilter requestCacheFilter = new RequestCacheAwareFilter(
requestCache);
@@ -82,7 +82,7 @@ public final class SecurityContextConfigurer<H extends HttpSecurityBuilder<H>> e
@Override
@SuppressWarnings("unchecked")
public void configure(H http) throws Exception {
public void configure(H http) {
SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class);
@@ -75,7 +75,7 @@ public final class ServletApiConfigurer<H extends HttpSecurityBuilder<H>> extend
@Override
@SuppressWarnings("unchecked")
public void configure(H http) throws Exception {
public void configure(H http) {
securityContextRequestFilter.setAuthenticationManager(http
.getSharedObject(AuthenticationManager.class));
ExceptionHandlingConfigurer<H> exceptionConf = http
@@ -441,7 +441,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class);
boolean stateless = isStateless();
@@ -478,7 +478,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class);
SessionManagementFilter sessionManagementFilter = new SessionManagementFilter(
@@ -171,7 +171,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
// @formatter:off
@Override
public void init(H http) throws Exception {
public void init(H http) {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
@@ -182,7 +182,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
// @formatter:on
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
X509AuthenticationFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class));
http.addFilter(filter);
@@ -83,7 +83,7 @@ public final class ImplicitGrantConfigurer<B extends HttpSecurityBuilder<B>> ext
}
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter(
OAuth2ClientConfigurerUtils.getClientRegistrationRepository(this.getBuilder()), this.getAuthorizationRequestBaseUri());
http.addFilter(this.postProcess(authorizationRequestFilter));
@@ -142,10 +142,8 @@ public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>> exte
* @param authorizationCodeGrantCustomizer the {@link Customizer} to provide more options for
* the {@link AuthorizationCodeGrantConfigurer}
* @return the {@link OAuth2ClientConfigurer} for further customizations
* @throws Exception
*/
public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer)
throws Exception {
public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer) {
authorizationCodeGrantCustomizer.customize(this.authorizationCodeGrantConfigurer);
return this;
}
@@ -270,12 +268,12 @@ public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>> exte
}
@Override
public void init(B builder) throws Exception {
public void init(B builder) {
this.authorizationCodeGrantConfigurer.init(builder);
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
this.authorizationCodeGrantConfigurer.configure(builder);
}
}
@@ -221,14 +221,14 @@ public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
registerDefaultAccessDeniedHandler(http);
registerDefaultEntryPoint(http);
registerDefaultCsrfOverride(http);
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
BearerTokenResolver bearerTokenResolver = getBearerTokenResolver();
this.requestMatcher.setBearerTokenResolver(bearerTokenResolver);
@@ -54,7 +54,7 @@ public class UserDetailsMapFactoryBean implements FactoryBean<Collection<UserDet
}
@Override
public Collection<UserDetails> getObject() throws Exception {
public Collection<UserDetails> getObject() {
Collection<UserDetails> users = new ArrayList<>(this.userProperties.size());
UserAttributeEditor editor = new UserAttributeEditor();
@@ -32,7 +32,7 @@ public class DataSourcePopulator implements InitializingBean {
JdbcTemplate template;
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notNull(template, "dataSource required");
template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(500) NOT NULL,ENABLED BOOLEAN NOT NULL);");
@@ -105,7 +105,7 @@ public class FilterChainProxyConfigTests {
}
@Test
public void pathWithNoMatchHasNoFilters() throws Exception {
public void pathWithNoMatchHasNoFilters() {
FilterChainProxy filterChainProxy = appCtx.getBean(
"newFilterChainProxyNoDefaultPath", FilterChainProxy.class);
assertThat(filterChainProxy.getFilters("/nomatch")).isNull();
@@ -113,7 +113,7 @@ public class FilterChainProxyConfigTests {
// SEC-1235
@Test
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() throws Exception {
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() {
FilterChainProxy fcp = appCtx.getBean("sec1235FilterChainProxy",
FilterChainProxy.class);
@@ -128,8 +128,7 @@ public class FilterChainProxyConfigTests {
.getRequestMatcher()).getPattern();
}
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy)
throws Exception {
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy) {
List<Filter> filters = filterChainProxy.getFilters("/foo/blah;x=1");
assertThat(filters).hasSize(1);
assertThat(filters.get(0) instanceof SecurityContextHolderAwareRequestFilter).isTrue();
@@ -72,7 +72,7 @@ public class SecurityNamespaceHandlerTests {
}
@Test
public void pre32SchemaAreNotSupported() throws Exception {
public void pre32SchemaAreNotSupported() {
try {
new InMemoryXmlApplicationContext(
"<user-service id='us'>"
@@ -27,7 +27,7 @@ class ConcereteSecurityConfigurerAdapter extends
private List<Object> list = new ArrayList<>();
@Override
public void configure(SecurityBuilder<Object> builder) throws Exception {
public void configure(SecurityBuilder<Object> builder) {
list = postProcess(list);
}
@@ -55,7 +55,7 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
protected void configure(AuthenticationManagerBuilder auth) {
auth
.authenticationProvider(authenticationProvider());
}
@@ -60,7 +60,7 @@ public class PasswordEncoderConfigurerTests {
// @formatter:on
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
@Bean
@@ -203,7 +203,7 @@ public class AuthenticationConfigurationTests {
inits.add(getClass());
}
public void configure(AuthenticationManagerBuilder auth) throws Exception {
public void configure(AuthenticationManagerBuilder auth) {
configs.add(getClass());
}
}
@@ -256,7 +256,7 @@ public class AuthenticationConfigurationTests {
static class DefaultBootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter {
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
public void configure(AuthenticationManagerBuilder auth) {
if (auth.isConfigured()) {
return;
}
@@ -477,7 +477,7 @@ public class AuthenticationConfigurationTests {
}
@Test
public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() throws Exception {
public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() {
this.spring.register(UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
// no exception
@@ -491,7 +491,7 @@ public class AuthenticationConfigurationTests {
}
@Test
public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() throws Exception {
public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() {
this.spring.register(ServicesConfig.class, UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
// no exception
@@ -154,7 +154,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
@Test
// SEC-2382
public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() throws Exception {
public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() {
this.spring.testConfigLocations("AutowireBeanFactoryObjectPostProcessorTests-aopconfig.xml").autowire();
MyAdvisedBean bean = this.spring.getContext().getBean(MyAdvisedBean.class);
@@ -47,7 +47,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// @formatter:off
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
protected void configure(AuthenticationManagerBuilder auth) {
auth
.authenticationProvider(authenticationProvider());
}
@@ -251,7 +251,7 @@ public class GlobalMethodSecurityConfigurationTests {
}
@Test
public void multiPermissionEvaluatorConfig() throws Exception {
public void multiPermissionEvaluatorConfig() {
this.spring.register(MultiPermissionEvaluatorConfig.class).autowire();
// no exception
@@ -65,7 +65,7 @@ public class AbstractConfiguredSecurityBuilderTests {
}
@Test(expected = IllegalStateException.class)
public void getObjectWhenNotBuiltThenThrowIllegalStateException() throws Exception {
public void getObjectWhenNotBuiltThenThrowIllegalStateException() {
this.builder.getObject();
}
@@ -141,7 +141,7 @@ public class AbstractConfiguredSecurityBuilderTests {
super(objectPostProcessor, allowConfigurersOfSameType);
}
public Object performBuild() throws Exception {
public Object performBuild() {
return "success";
}
}
@@ -57,7 +57,7 @@ public class HttpSecurityHeadersTests {
MockMvc mockMvc;
@Before
public void setup() throws Exception {
public void setup() {
mockMvc = MockMvcBuilders
.webAppContextSetup(wac)
.addFilters(springSecurityFilterChain)
@@ -86,7 +86,7 @@ public class HttpSecurityHeadersTests {
@EnableWebSecurity
static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -210,7 +210,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class SampleWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/resources/**");
@@ -367,7 +367,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
@Configuration
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/resources/**");
@@ -79,7 +79,7 @@ public class WebSecurityConfigurerAdapterPowermockTests {
@EnableWebSecurity
static class Config extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -88,12 +88,12 @@ public class WebSecurityConfigurerAdapterPowermockTests {
boolean configure;
@Override
public void init(HttpSecurity builder) throws Exception {
public void init(HttpSecurity builder) {
this.init = true;
}
@Override
public void configure(HttpSecurity builder) throws Exception {
public void configure(HttpSecurity builder) {
this.configure = true;
}
}
@@ -110,7 +110,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -146,7 +146,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -237,7 +237,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Test
public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() throws Exception {
public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() {
OverrideContentNegotiationStrategySharedObjectConfig.CONTENT_NEGOTIATION_STRATEGY_BEAN = mock(ContentNegotiationStrategy.class);
this.spring.register(OverrideContentNegotiationStrategySharedObjectConfig.class).autowire();
@@ -267,7 +267,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Test
public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() throws Exception {
public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() {
this.spring.register(ContentNegotiationStrategyDefaultSharedObjectConfig.class).autowire();
ContentNegotiationStrategyDefaultSharedObjectConfig securityConfig =
@@ -289,7 +289,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Test
public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() throws Exception {
public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() {
this.spring.register(RequiresUserDetailsServiceConfig.class, UserDetailsServiceConfig.class).autowire();
MyFilter myFilter = this.spring.getContext().getBean(MyFilter.class);
@@ -350,7 +350,7 @@ public class WebSecurityConfigurerAdapterTests {
// SEC-2274: WebSecurityConfigurer adds ApplicationContext as a shared object
@Test
public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() throws Exception {
public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() {
this.spring.register(ApplicationContextSharedObjectConfig.class).autowire();
ApplicationContextSharedObjectConfig securityConfig =
@@ -372,7 +372,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Test
public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() throws Exception {
public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() {
CustomTrustResolverConfig.AUTHENTICATION_TRUST_RESOLVER_BEAN = mock(AuthenticationTrustResolver.class);
this.spring.register(CustomTrustResolverConfig.class).autowire();
@@ -402,7 +402,7 @@ public class WebSecurityConfigurerAdapterTests {
}
@Test
public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() throws Exception {
public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() {
AnnotationAwareOrderComparator comparator = new AnnotationAwareOrderComparator();
assertThat(comparator.compare(
new LowestPriorityWebSecurityConfig(),
@@ -56,7 +56,7 @@ public class HttpConfigurationTests {
private MockMvc mockMvc;
@Test
public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() throws Exception {
public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() {
Throwable thrown = catchThrowable(() -> this.spring.register(UnregisteredFilterConfig.class).autowire() );
assertThat(thrown).isInstanceOf(BeanCreationException.class);
assertThat(thrown.getMessage()).contains("The Filter class " + UnregisteredFilter.class.getName() +
@@ -67,7 +67,7 @@ public class HttpConfigurationTests {
@EnableWebSecurity
static class UnregisteredFilterConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.addFilter(new UnregisteredFilter());
}
@@ -104,7 +104,7 @@ public class HttpConfigurationTests {
static class CasAuthenticationFilterConfig extends WebSecurityConfigurerAdapter {
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER;
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.addFilter(CAS_AUTHENTICATION_FILTER);
}
@@ -139,7 +139,7 @@ public class NamespaceHttpTests {
static AuthenticationManager AUTHENTICATION_MANAGER;
@Override
protected AuthenticationManager authenticationManager() throws Exception {
protected AuthenticationManager authenticationManager() {
return AUTHENTICATION_MANAGER;
}
@@ -298,7 +298,7 @@ public class NamespaceHttpTests {
@EnableWebSecurity
static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.addFilter(new JaasApiIntegrationFilter());
}
@@ -327,7 +327,7 @@ public class NamespaceHttpTests {
}
@Test // http@request-matcher-ref ant
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() throws Exception {
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() {
this.spring.register(RequestMatcherAntConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@@ -340,14 +340,14 @@ public class NamespaceHttpTests {
@EnableWebSecurity
static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.antMatcher("/api/**");
}
}
@Test // http@request-matcher-ref regex
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() throws Exception {
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() {
this.spring.register(RequestMatcherRegexConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@@ -360,14 +360,14 @@ public class NamespaceHttpTests {
@EnableWebSecurity
static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.regexMatcher("/regex/.*");
}
}
@Test // http@request-matcher-ref
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() throws Exception {
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() {
this.spring.register(RequestMatcherRefConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@@ -380,7 +380,7 @@ public class NamespaceHttpTests {
@EnableWebSecurity
static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.requestMatcher(new MyRequestMatcher());
}
@@ -393,7 +393,7 @@ public class NamespaceHttpTests {
}
@Test // http@security=none
public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() throws Exception {
public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() {
this.spring.register(SecurityNoneConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@@ -415,14 +415,14 @@ public class NamespaceHttpTests {
static class SecurityNoneConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/resources/**", "/public/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -510,7 +510,7 @@ public class NamespaceHttpTests {
}
@Test // http@use-expressions=true
public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() throws Exception {
public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() {
this.spring.register(UseExpressionsConfig.class).autowire();
UseExpressionsConfig config = this.spring.getContext().getBean(UseExpressionsConfig.class);
@@ -545,7 +545,7 @@ public class NamespaceHttpTests {
}
@Test // http@use-expressions=false
public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() throws Exception {
public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() {
this.spring.register(DisableUseExpressionsConfig.class).autowire();
DisableUseExpressionsConfig config = this.spring.getContext().getBean(DisableUseExpressionsConfig.class);
@@ -104,7 +104,7 @@ public class WebSecurityTests {
@EnableWebMvc
static class MvcMatcherConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
// @formatter:off
web
.ignoring()
@@ -180,7 +180,7 @@ public class WebSecurityTests {
@EnableWebMvc
static class MvcMatcherServletPathConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
// @formatter:off
web
.ignoring()
@@ -51,7 +51,7 @@ public class EnableWebSecurityTests {
private MockMvc mockMvc;
@Test
public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() throws Exception {
public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() {
this.spring.register(SecurityConfig.class).autowire();
AuthenticationManager authenticationManager = this.spring.getContext().getBean(AuthenticationManager.class);
@@ -85,7 +85,7 @@ public class EnableWebSecurityTests {
}
@Test
public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() throws Exception {
public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() {
this.spring.register(ChildSecurityConfig.class).autowire();
this.spring.getContext().getBean("springSecurityFilterChain", DebugFilter.class);
}
@@ -110,7 +110,7 @@ public class EnableWebSecurityTests {
@EnableWebMvc
static class AuthenticationPrincipalConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
@RestController
@@ -133,7 +133,7 @@ public class OAuth2ClientConfigurationTests {
static OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> ACCESS_TOKEN_RESPONSE_CLIENT;
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
@RestController
@@ -39,7 +39,7 @@ public class Sec2515Tests {
// SEC-2515
@Test(expected = FatalBeanException.class)
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() throws Exception {
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() {
this.spring.register(StackOverflowSecurityConfig.class).autowire();
}
@@ -54,7 +54,7 @@ public class Sec2515Tests {
}
@Test(expected = FatalBeanException.class)
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() throws Exception {
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() {
this.spring.register(CustomBeanNameStackOverflowSecurityConfig.class).autowire();
}
@@ -70,7 +70,7 @@ public class Sec2515Tests {
// SEC-2549
@Test
public void loadConfigWhenChildClassLoaderSetThenContextLoads() throws Exception {
public void loadConfigWhenChildClassLoaderSetThenContextLoads() {
CanLoadWithChildConfig.AUTHENTICATION_MANAGER = mock(AuthenticationManager.class);
this.spring.register(CanLoadWithChildConfig.class);
AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) this.spring.getContext();
@@ -92,7 +92,7 @@ public class Sec2515Tests {
// SEC-2515
@Test
public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() throws Exception {
public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() {
this.spring.register(SecurityConfig.class).autowire();
}
@@ -78,7 +78,7 @@ public class WebSecurityConfigurationTests {
private MockMvc mockMvc;
@Test
public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() throws Exception {
public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() {
this.spring.register(SortedWebSecurityConfigurerAdaptersConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@@ -116,7 +116,7 @@ public class WebSecurityConfigurationTests {
@Order(1)
static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/ignore1", "/ignore2");
@@ -168,7 +168,7 @@ public class WebSecurityConfigurationTests {
}
@Test
public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() throws Exception {
public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() {
Throwable thrown = catchThrowable(() -> this.spring.register(DuplicateOrderConfig.class).autowire());
assertThat(thrown).isInstanceOf(BeanCreationException.class)
@@ -205,7 +205,7 @@ public class WebSecurityConfigurationTests {
}
@Test
public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() throws Exception {
public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() {
PrivilegeEvaluatorConfigurerAdapterConfig.PRIVILEGE_EVALUATOR = mock(WebInvocationPrivilegeEvaluator.class);
this.spring.register(PrivilegeEvaluatorConfigurerAdapterConfig.class).autowire();
@@ -219,13 +219,13 @@ public class WebSecurityConfigurationTests {
static WebInvocationPrivilegeEvaluator PRIVILEGE_EVALUATOR;
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web.privilegeEvaluator(PRIVILEGE_EVALUATOR);
}
}
@Test
public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() throws Exception {
public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() {
WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER = mock(SecurityExpressionHandler.class);
when(WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER.getExpressionParser()).thenReturn(mock(ExpressionParser.class));
@@ -240,7 +240,7 @@ public class WebSecurityConfigurationTests {
static SecurityExpressionHandler EXPRESSION_HANDLER;
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web.expressionHandler(EXPRESSION_HANDLER);
}
@@ -254,7 +254,7 @@ public class WebSecurityConfigurationTests {
}
@Test
public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() throws Exception {
public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() {
this.spring.register(WebSecurityExpressionHandlerDefaultsConfig.class).autowire();
assertThat(this.spring.getContext().getBean(SecurityExpressionHandler.class))
@@ -272,7 +272,7 @@ public class WebSecurityConfigurationTests {
}
@Test
public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() throws Exception {
public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() {
this.spring.register(WebSecurityExpressionHandlerPermissionEvaluatorBeanConfig.class).autowire();
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "notused");
FilterInvocation invocation = new FilterInvocation(new MockHttpServletRequest("GET", ""), new MockHttpServletResponse(), new MockFilterChain());
@@ -308,7 +308,7 @@ public class WebSecurityConfigurationTests {
}
@Test
public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() throws Exception {
public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() {
this.spring.register(WebInvocationPrivilegeEvaluatorDefaultsConfig.class).autowire();
assertThat(this.spring.getContext().getBean(WebInvocationPrivilegeEvaluator.class))
@@ -372,7 +372,7 @@ public class WebSecurityConfigurationTests {
// SEC-2461
@Test
public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() throws Exception {
public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() {
this.spring.register(ParentConfig.class).autowire();
this.child.register(ChildConfig.class);
@@ -400,7 +400,7 @@ public class WebSecurityConfigurationTests {
// SEC-2773
@Test
public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() throws Exception {
public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() {
Method method = ClassUtils.getMethod(WebSecurityConfiguration.class, "delegatingApplicationListener", null);
assertThat(Modifier.isStatic(method.getModifiers())).isTrue();
}
@@ -426,7 +426,7 @@ public class WebSecurityConfigurationTests {
@Order(1)
static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/ignore1", "/ignore2");
@@ -71,7 +71,7 @@ public class CsrfConfigurerNoWebMvcTests {
static class EnableWebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -88,7 +88,7 @@ public class CsrfConfigurerNoWebMvcTests {
static class EnableWebMvcConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -183,7 +183,7 @@ public class CsrfConfigurerTests {
static class CsrfAppliedDefaultConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -166,7 +166,7 @@ public class FormLoginConfigurerTests {
@EnableWebSecurity
static class FormLoginConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
// @formatter:off
web
.ignoring()
@@ -101,7 +101,7 @@ public class NamespaceHttpCustomFilterTests {
super(true);
}
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
// this works so long as the CustomFilter extends one of the standard filters
// if not, use addFilterBefore or addFilterAfter
@@ -123,7 +123,7 @@ public class NamespaceHttpCustomFilterTests {
super(true);
}
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
http
.addFilterAt(new OtherCustomFilter(), UsernamePasswordAuthenticationFilter.class);
}
@@ -141,8 +141,7 @@ public class NamespaceHttpCustomFilterTests {
super(true);
}
protected AuthenticationManager authenticationManager()
throws Exception {
protected AuthenticationManager authenticationManager() {
return new CustomAuthenticationManager();
}
@@ -50,7 +50,7 @@ public class NamespaceHttpFirewallTests {
MockMvc mvc;
@Test
public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() throws Exception {
public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() {
this.rule.register(HttpFirewallConfig.class).autowire();
assertThatCode(() -> this.mvc.perform(get("/public/../private/")))
.isInstanceOf(RequestRejectedException.class);
@@ -69,7 +69,7 @@ public class NamespaceHttpFirewallTests {
@EnableWebSecurity
static class CustomHttpFirewallConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.httpFirewall(new CustomHttpFirewall());
}
@@ -82,7 +82,7 @@ public class NamespaceHttpFormLoginTests {
static class FormLoginConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web
.ignoring()
.antMatchers("/resources/**");
@@ -81,7 +81,7 @@ public class NamespaceHttpLogoutTests {
@EnableWebSecurity
static class HttpLogoutConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
}
@@ -76,7 +76,7 @@ public class RememberMeConfigurerTests {
MockMvc mvc;
@Test
public void postWhenNoUserDetailsServiceThenException() throws Exception {
public void postWhenNoUserDetailsServiceThenException() {
this.spring.register(NullUserDetailsConfig.class).autowire();
assertThatThrownBy(() ->
@@ -103,7 +103,7 @@ public class RememberMeConfigurerTests {
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
protected void configure(AuthenticationManagerBuilder auth) {
User user = (User) PasswordEncodedUser.user();
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(user)));
@@ -223,7 +223,7 @@ public class ServletApiConfigurerTests {
static AuthenticationTrustResolver TR = spy(AuthenticationTrustResolver.class);
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
// @formatter:off
http
.setSharedObject(AuthenticationTrustResolver.class, TR);
@@ -476,7 +476,7 @@ public class SessionManagementConfigurerTests {
static AuthenticationTrustResolver TR;
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
// @formatter:off
http
.setSharedObject(AuthenticationTrustResolver.class, TR);
@@ -76,7 +76,7 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
protected void configure(AuthenticationManagerBuilder auth) {
auth
.authenticationProvider(new TransientAuthenticationProvider());
}
@@ -1170,7 +1170,7 @@ public class OAuth2ResourceServerConfigurerTests {
}
@Test
public void configureWhenOnlyIntrospectionUrlThenException() throws Exception {
public void configureWhenOnlyIntrospectionUrlThenException() {
assertThatCode(() -> this.spring.register(OpaqueTokenHalfConfiguredConfig.class).autowire())
.isInstanceOf(BeanCreationException.class);
}
@@ -134,7 +134,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void addsAuthenticationPrincipalResolver() throws InterruptedException {
public void addsAuthenticationPrincipalResolver() {
loadConfig(SockJsSecurityConfig.class);
MessageChannel messageChannel = clientInboundChannel();
@@ -146,8 +146,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void addsAuthenticationPrincipalResolverWhenNoAuthorization()
throws InterruptedException {
public void addsAuthenticationPrincipalResolverWhenNoAuthorization() {
loadConfig(NoInboundSecurityConfig.class);
MessageChannel messageChannel = clientInboundChannel();
@@ -159,7 +158,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void addsCsrfProtectionWhenNoAuthorization() throws InterruptedException {
public void addsCsrfProtectionWhenNoAuthorization() {
loadConfig(NoInboundSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@@ -177,7 +176,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void csrfProtectionForConnect() throws InterruptedException {
public void csrfProtectionForConnect() {
loadConfig(SockJsSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@@ -195,7 +194,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void csrfProtectionDisabledForConnect() throws InterruptedException {
public void csrfProtectionDisabledForConnect() {
loadConfig(CsrfDisabledSockJsSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@@ -265,8 +264,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void msmsRegistryCustomPatternMatcher()
throws Exception {
public void msmsRegistryCustomPatternMatcher() {
loadConfig(MsmsRegistryCustomPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a.b"));
@@ -317,8 +315,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void overrideMsmsRegistryCustomPatternMatcher()
throws Exception {
public void overrideMsmsRegistryCustomPatternMatcher() {
loadConfig(OverrideMsmsRegistryCustomPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a/b"));
@@ -371,8 +368,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void defaultPatternMatcher()
throws Exception {
public void defaultPatternMatcher() {
loadConfig(DefaultPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a/b"));
@@ -422,8 +418,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
}
@Test
public void customExpression()
throws Exception {
public void customExpression() {
loadConfig(CustomExpressionConfig.class);
clientInboundChannel().send(message("/denyRob"));
@@ -612,8 +607,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
return parameter.getParameterType().isAssignableFrom(MyCustomArgument.class);
}
public Object resolveArgument(MethodParameter parameter, Message<?> message)
throws Exception {
public Object resolveArgument(MethodParameter parameter, Message<?> message) {
return new MyCustomArgument("");
}
}
@@ -54,7 +54,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
@Test
// SEC-1225
public void providersAreRegisteredAsTopLevelBeans() throws Exception {
public void providersAreRegisteredAsTopLevelBeans() {
ConfigurableApplicationContext context = this.spring.context(CONTEXT)
.getContext();
assertThat(context.getBeansOfType(AuthenticationProvider.class)).hasSize(1);
@@ -78,7 +78,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
}
@Test
public void credentialsAreClearedByDefault() throws Exception {
public void credentialsAreClearedByDefault() {
ConfigurableApplicationContext appContext = this.spring.context(CONTEXT)
.getContext();
ProviderManager pm = (ProviderManager) appContext
@@ -87,7 +87,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
}
@Test
public void clearCredentialsPropertyIsRespected() throws Exception {
public void clearCredentialsPropertyIsRespected() {
ConfigurableApplicationContext appContext = this.spring.context("<authentication-manager erase-credentials='false'/>")
.getContext();
ProviderManager pm = (ProviderManager) appContext
@@ -57,7 +57,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
}
@Test
public void externalUserServiceRefWorks() throws Exception {
public void externalUserServiceRefWorks() {
appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>"
+ " <authentication-provider user-service-ref='myUserService' />"
@@ -69,7 +69,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
}
@Test
public void providerWithBCryptPasswordEncoderWorks() throws Exception {
public void providerWithBCryptPasswordEncoderWorks() {
setContext(" <authentication-provider>"
+ " <password-encoder hash='bcrypt'/>"
+ " <user-service>"
@@ -80,7 +80,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
}
@Test
public void providerWithMd5PasswordEncoderWorks() throws Exception {
public void providerWithMd5PasswordEncoderWorks() {
appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>"
+ " <authentication-provider>"
@@ -99,7 +99,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
}
@Test
public void providerWithShaPasswordEncoderWorks() throws Exception {
public void providerWithShaPasswordEncoderWorks() {
appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>"
+ " <authentication-provider>"
@@ -116,7 +116,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
}
@Test
public void passwordIsBase64EncodedWhenBase64IsEnabled() throws Exception {
public void passwordIsBase64EncodedWhenBase64IsEnabled() {
appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>"
+ " <authentication-provider>"
@@ -137,7 +137,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
// SEC-1466
@Test(expected = BeanDefinitionParsingException.class)
public void exernalProviderDoesNotSupportChildElements() throws Exception {
public void exernalProviderDoesNotSupportChildElements() {
appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>"
+ " <authentication-provider ref='aProvider'> "
@@ -61,7 +61,7 @@ public class JdbcUserServiceBeanDefinitionParserTests {
}
@Test
public void beanNameIsCorrect() throws Exception {
public void beanNameIsCorrect() {
assertThat(JdbcUserDetailsManager.class.getName()).isEqualTo(
new JdbcUserServiceBeanDefinitionParser()
.getBeanClassName(mock(Element.class)));
@@ -42,14 +42,14 @@ public class UserDetailsResourceFactoryBeanTest {
UserDetailsResourceFactoryBean factory = new UserDetailsResourceFactoryBean();
@Test
public void setResourceLoaderWhenNullThenThrowsException() throws Exception {
public void setResourceLoaderWhenNullThenThrowsException() {
assertThatThrownBy(() -> factory.setResourceLoader(null) )
.isInstanceOf(IllegalArgumentException.class)
.hasStackTraceContaining("resourceLoader cannot be null");
}
@Test
public void getObjectWhenPropertiesResourceLocationNullThenThrowsIllegalStateException() throws Exception {
public void getObjectWhenPropertiesResourceLocationNullThenThrowsIllegalStateException() {
factory.setResourceLoader(resourceLoader);
assertThatThrownBy(() -> factory.getObject() )
@@ -74,7 +74,7 @@ public class UserDetailsResourceFactoryBeanTest {
}
@Test
public void getObjectWhenInvalidUserThenThrowsMeaningfulException() throws Exception {
public void getObjectWhenInvalidUserThenThrowsMeaningfulException() {
factory.setResource(new InMemoryResource("user=invalidFormatHere"));
assertThatThrownBy(() -> factory.getObject() )
@@ -27,7 +27,7 @@ public class CsrfBeanDefinitionParserTests {
"classpath:org/springframework/security/config/http/CsrfBeanDefinitionParserTests";
@Test
public void registerDataValueProcessorOnlyIfNotRegistered() throws Exception {
public void registerDataValueProcessorOnlyIfNotRegistered() {
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext()) {
context.setAllowBeanDefinitionOverriding(false);
context.setConfigLocation(this.xml("RegisterDataValueProcessorOnyIfNotRegistered"));
@@ -621,7 +621,7 @@ public class CsrfConfigTests {
static class CsrfCreatedResultMatcher implements ResultMatcher {
@Override
public void match(MvcResult result) throws Exception {
public void match(MvcResult result) {
MockHttpServletRequest request = result.getRequest();
CsrfToken token = WebTestUtils.getCsrfTokenRepository(request).loadToken(request);
assertThat(token).isNotNull();
@@ -61,7 +61,7 @@ public class DefaultFilterChainValidatorTests {
private FilterSecurityInterceptor fsi;
@Before
public void setUp() throws Exception {
public void setUp() {
AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
fsi = new FilterSecurityInterceptor();
fsi.setAccessDecisionManager(accessDecisionManager);
@@ -227,7 +227,7 @@ public class FormLoginConfigTests {
public void onAuthenticationFailure(
HttpServletRequest request,
HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
AuthenticationException exception) {
response.setStatus(HttpStatus.I_AM_A_TEAPOT.value());
}
@@ -236,7 +236,7 @@ public class FormLoginConfigTests {
public void onAuthenticationSuccess(
HttpServletRequest request,
HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
Authentication authentication) {
response.setStatus(HttpStatus.I_AM_A_TEAPOT.value());
}
@@ -858,22 +858,22 @@ public class MiscHttpConfigTests {
}
@Override
public boolean login() throws LoginException {
public boolean login() {
return this.subject.getPrincipals().add(() -> "user");
}
@Override
public boolean commit() throws LoginException {
public boolean commit() {
return true;
}
@Override
public boolean abort() throws LoginException {
public boolean abort() {
return true;
}
@Override
public boolean logout() throws LoginException {
public boolean logout() {
return true;
}
}
@@ -104,8 +104,7 @@ public class OpenIDConfigTests {
}
@Test
public void configureWhenOpenIDAndFormLoginBothConfigureLoginPagesThenWiringException()
throws Exception {
public void configureWhenOpenIDAndFormLoginBothConfigureLoginPagesThenWiringException() {
assertThatCode(() -> this.spring.configLocations(this.xml("WithFormLoginAndOpenIDLoginPages")).autowire())
.isInstanceOf(BeanDefinitionParsingException.class);
@@ -314,7 +314,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
// SEC-1392
@Test
public void customPermissionEvaluatorIsSupported() throws Exception {
public void customPermissionEvaluatorIsSupported() {
setContext("<global-method-security pre-post-annotations='enabled'>"
+ " <expression-handler ref='expressionHandler'/>"
+ "</global-method-security>"
@@ -328,7 +328,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
// SEC-1450
@Test(expected = AuthenticationException.class)
@SuppressWarnings("unchecked")
public void genericsAreMatchedByProtectPointcut() throws Exception {
public void genericsAreMatchedByProtectPointcut() {
setContext("<b:bean id='target' class='org.springframework.security.config.method.GlobalMethodSecurityBeanDefinitionParserTests$ConcreteFoo'/>"
+ "<global-method-security>"
+ " <protect-pointcut expression='execution(* org..*Foo.foo(..))' access='ROLE_USER'/>"
@@ -340,7 +340,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
// SEC-1448
@Test
@SuppressWarnings("unchecked")
public void genericsMethodArgumentNamesAreResolved() throws Exception {
public void genericsMethodArgumentNamesAreResolved() {
setContext("<b:bean id='target' class='" + ConcreteFoo.class.getName() + "'/>"
+ "<global-method-security pre-post-annotations='enabled'/>"
+ AUTH_PROVIDER_XML);
@@ -368,7 +368,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
@Test
@SuppressWarnings("unchecked")
public void supportsExternalMetadataSource() throws Exception {
public void supportsExternalMetadataSource() {
setContext("<b:bean id='target' class='"
+ ConcreteFoo.class.getName()
+ "'/>"
@@ -394,7 +394,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
}
@Test
public void supportsCustomAuthenticationManager() throws Exception {
public void supportsCustomAuthenticationManager() {
setContext("<b:bean id='target' class='"
+ ConcreteFoo.class.getName()
+ "'/>"
@@ -103,7 +103,7 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements
}
@Test(expected = AuthenticationException.class)
public void transactionalMethodsShouldBeSecured() throws Exception {
public void transactionalMethodsShouldBeSecured() {
transactionalTarget.doSomething();
}
@@ -34,7 +34,7 @@ public class CommonOAuth2ProviderTests {
private static final String DEFAULT_REDIRECT_URL = "{baseUrl}/{action}/oauth2/code/{registrationId}";
@Test
public void getBuilderWhenGoogleShouldHaveGoogleSettings() throws Exception {
public void getBuilderWhenGoogleShouldHaveGoogleSettings() {
ClientRegistration registration = build(CommonOAuth2Provider.GOOGLE);
ProviderDetails providerDetails = registration.getProviderDetails();
assertThat(providerDetails.getAuthorizationUri())
@@ -58,7 +58,7 @@ public class CommonOAuth2ProviderTests {
}
@Test
public void getBuilderWhenGitHubShouldHaveGitHubSettings() throws Exception {
public void getBuilderWhenGitHubShouldHaveGitHubSettings() {
ClientRegistration registration = build(CommonOAuth2Provider.GITHUB);
ProviderDetails providerDetails = registration.getProviderDetails();
assertThat(providerDetails.getAuthorizationUri())
@@ -81,7 +81,7 @@ public class CommonOAuth2ProviderTests {
}
@Test
public void getBuilderWhenFacebookShouldHaveFacebookSettings() throws Exception {
public void getBuilderWhenFacebookShouldHaveFacebookSettings() {
ClientRegistration registration = build(CommonOAuth2Provider.FACEBOOK);
ProviderDetails providerDetails = registration.getProviderDetails();
assertThat(providerDetails.getAuthorizationUri())
@@ -104,7 +104,7 @@ public class CommonOAuth2ProviderTests {
}
@Test
public void getBuilderWhenOktaShouldHaveOktaSettings() throws Exception {
public void getBuilderWhenOktaShouldHaveOktaSettings() {
ClientRegistration registration = builder(CommonOAuth2Provider.OKTA)
.authorizationUri("https://example.com/auth")
.tokenUri("https://example.com/token")
@@ -62,7 +62,7 @@ public class SpringTestContext implements Closeable {
}
@Override
public void close() throws IOException {
public void close() {
try {
this.context.close();
} catch(Exception e) {}
@@ -104,8 +104,7 @@ public class SpringTestContext implements Closeable {
return addFilter(new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
HttpServletResponse response, FilterChain filterChain) {
response.setStatus(HttpServletResponse.SC_OK);
}
});
@@ -52,7 +52,7 @@ public class InMemoryXmlWebApplicationContext extends AbstractRefreshableWebAppl
}
@Override
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(new Resource[] { inMemoryXml });
}
@@ -93,7 +93,7 @@ public class AuthorizeExchangeSpecTests {
}
@Test
public void antMatchersWhenPatternsInLambdaThenAnyMethod() throws Exception {
public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
this.http
.csrf(ServerHttpSecurity.CsrfSpec::disable)
.authorizeExchange(exchanges ->
@@ -151,7 +151,7 @@ public class AuthorizeExchangeSpecTests {
}
@Test(expected = IllegalStateException.class)
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() throws Exception {
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() {
this.http
.authorizeExchange(exchanges ->
exchanges
@@ -75,7 +75,7 @@ public class CorsSpecTests {
}
@Test
public void corsWhenEnabledInLambdaThenAccessControlAllowOriginAndSecurityHeaders() throws Exception {
public void corsWhenEnabledInLambdaThenAccessControlAllowOriginAndSecurityHeaders() {
this.http.cors(cors -> cors.configurationSource(this.source));
this.expectedHeaders.set("Access-Control-Allow-Origin", "*");
this.expectedHeaders.set("X-Frame-Options", "DENY");
@@ -59,8 +59,7 @@ public class ExceptionHandlingSpecTests {
}
@Test
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed()
throws Exception {
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(exchanges ->
exchanges
@@ -106,7 +105,7 @@ public class ExceptionHandlingSpecTests {
}
@Test
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() throws Exception {
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(exchanges ->
exchanges
@@ -155,8 +154,7 @@ public class ExceptionHandlingSpecTests {
}
@Test
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAccessDeniedHandlerUsed()
throws Exception {
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAccessDeniedHandlerUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.httpBasic(withDefaults())
.authorizeExchange(exchanges ->
@@ -204,8 +202,7 @@ public class ExceptionHandlingSpecTests {
}
@Test
public void requestWhenCustomAccessDeniedHandlerInLambdaThenCustomAccessDeniedHandlerUsed()
throws Exception {
public void requestWhenCustomAccessDeniedHandlerInLambdaThenCustomAccessDeniedHandlerUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.httpBasic(withDefaults())
.authorizeExchange(exchanges ->
@@ -98,7 +98,7 @@ public class FormLoginTests {
}
@Test
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() throws Exception {
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(exchanges ->
exchanges
@@ -173,7 +173,7 @@ public class FormLoginTests {
}
@Test
public void formLoginWhenCustomLoginPageInLambdaThenUsed() throws Exception {
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(exchanges ->
exchanges
@@ -79,7 +79,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenDisableInLambdaThenNoSecurityHeaders() throws Exception {
public void headersWhenDisableInLambdaThenNoSecurityHeaders() {
new HashSet<>(this.expectedHeaders.keySet()).forEach(this::expectHeaderNamesNotPresent);
this.http.headers(headers -> headers.disable());
@@ -103,7 +103,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenDefaultsInLambdaThenAllDefaultsWritten() throws Exception {
public void headersWhenDefaultsInLambdaThenAllDefaultsWritten() {
this.http.headers(withDefaults());
assertHeaders();
@@ -119,7 +119,7 @@ public class HeaderSpecTests {
@Test
public void headersWhenCacheDisableInLambdaThenCacheNotWritten() throws Exception {
public void headersWhenCacheDisableInLambdaThenCacheNotWritten() {
expectHeaderNamesNotPresent(HttpHeaders.CACHE_CONTROL, HttpHeaders.PRAGMA, HttpHeaders.EXPIRES);
this.http
.headers(headers ->
@@ -138,7 +138,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenContentOptionsDisableInLambdaThenContentTypeOptionsNotWritten() throws Exception {
public void headersWhenContentOptionsDisableInLambdaThenContentTypeOptionsNotWritten() {
expectHeaderNamesNotPresent(ContentTypeOptionsServerHttpHeadersWriter.X_CONTENT_OPTIONS);
this.http
.headers(headers ->
@@ -157,7 +157,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenHstsDisableInLambdaThenHstsNotWritten() throws Exception {
public void headersWhenHstsDisableInLambdaThenHstsNotWritten() {
expectHeaderNamesNotPresent(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
this.http
.headers(headers ->
@@ -179,7 +179,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenHstsCustomInLambdaThenCustomHstsWritten() throws Exception {
public void headersWhenHstsCustomInLambdaThenCustomHstsWritten() {
this.expectedHeaders.remove(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
this.expectedHeaders.add(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY, "max-age=60");
this.http
@@ -207,7 +207,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenHstsCustomWithPreloadInLambdaThenCustomHstsWritten() throws Exception {
public void headersWhenHstsCustomWithPreloadInLambdaThenCustomHstsWritten() {
this.expectedHeaders.remove(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY);
this.expectedHeaders.add(StrictTransportSecurityServerHttpHeadersWriter.STRICT_TRANSPORT_SECURITY, "max-age=60 ; includeSubDomains ; preload");
this.http
@@ -232,7 +232,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenFrameOptionsDisableInLambdaThenFrameOptionsNotWritten() throws Exception {
public void headersWhenFrameOptionsDisableInLambdaThenFrameOptionsNotWritten() {
expectHeaderNamesNotPresent(XFrameOptionsServerHttpHeadersWriter.X_FRAME_OPTIONS);
this.http
.headers(headers ->
@@ -253,7 +253,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenFrameOptionsModeInLambdaThenFrameOptionsCustomMode() throws Exception {
public void headersWhenFrameOptionsModeInLambdaThenFrameOptionsCustomMode() {
this.expectedHeaders.set(XFrameOptionsServerHttpHeadersWriter.X_FRAME_OPTIONS, "SAMEORIGIN");
this.http
.headers(headers ->
@@ -276,7 +276,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenXssProtectionDisableInLambdaThenXssProtectionNotWritten() throws Exception {
public void headersWhenXssProtectionDisableInLambdaThenXssProtectionNotWritten() {
expectHeaderNamesNotPresent("X-Xss-Protection");
this.http
.headers(headers ->
@@ -309,7 +309,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenContentSecurityPolicyEnabledWithDefaultsInLambdaThenDefaultPolicyWritten() throws Exception {
public void headersWhenContentSecurityPolicyEnabledWithDefaultsInLambdaThenDefaultPolicyWritten() {
String expectedPolicyDirectives = "default-src 'self'";
this.expectedHeaders.add(ContentSecurityPolicyServerHttpHeadersWriter.CONTENT_SECURITY_POLICY,
expectedPolicyDirectives);
@@ -323,7 +323,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenContentSecurityPolicyEnabledInLambdaThenContentSecurityPolicyWritten() throws Exception {
public void headersWhenContentSecurityPolicyEnabledInLambdaThenContentSecurityPolicyWritten() {
String policyDirectives = "default-src 'self' *.trusted.com";
this.expectedHeaders.add(ContentSecurityPolicyServerHttpHeadersWriter.CONTENT_SECURITY_POLICY,
policyDirectives);
@@ -350,7 +350,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenReferrerPolicyEnabledInLambdaThenReferrerPolicyWritten() throws Exception {
public void headersWhenReferrerPolicyEnabledInLambdaThenReferrerPolicyWritten() {
this.expectedHeaders.add(ReferrerPolicyServerHttpHeadersWriter.REFERRER_POLICY,
ReferrerPolicy.NO_REFERRER.getPolicy());
this.http
@@ -372,7 +372,7 @@ public class HeaderSpecTests {
}
@Test
public void headersWhenReferrerPolicyCustomEnabledInLambdaThenCustomReferrerPolicyWritten() throws Exception {
public void headersWhenReferrerPolicyCustomEnabledInLambdaThenCustomReferrerPolicyWritten() {
this.expectedHeaders.add(ReferrerPolicyServerHttpHeadersWriter.REFERRER_POLICY,
ReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE.getPolicy());
this.http
@@ -121,7 +121,7 @@ public class LogoutSpecTests {
}
@Test
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() throws Exception {
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(authorizeExchange ->
authorizeExchange
@@ -523,7 +523,7 @@ public class OAuth2LoginTests {
@Test
public void logoutWhenUsingOidcLogoutHandlerThenRedirects() throws Exception {
public void logoutWhenUsingOidcLogoutHandlerThenRedirects() {
this.spring.register(OAuth2LoginConfigWithOidcLogoutSuccessHandler.class).autowire();
OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(
@@ -679,7 +679,7 @@ public class OAuth2ResourceServerSpecTests {
@EnableWebFluxSecurity
static class CustomAuthenticationManagerResolverConfig {
@Bean
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
// @formatter:off
http
.authorizeExchange()
@@ -105,7 +105,7 @@ public class RequestCacheTests {
}
@Test
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() throws Exception {
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(authorizeExchange ->
authorizeExchange
@@ -240,7 +240,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void getWhenAnonymousConfiguredThenAuthenticationIsAnonymous() throws Exception {
public void getWhenAnonymousConfiguredThenAuthenticationIsAnonymous() {
SecurityWebFilterChain securityFilterChain = this.http.anonymous(withDefaults()).build();
WebTestClient client = WebTestClientBuilder.bindToControllerAndWebFilters(AnonymousAuthenticationWebFilterTests.HttpMeController.class,
securityFilterChain).build();
@@ -300,7 +300,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void requestWhenBasicWithRealmNameInLambdaThenRealmNameUsed() throws Exception {
public void requestWhenBasicWithRealmNameInLambdaThenRealmNameUsed() {
this.http.securityContextRepository(new WebSessionServerSecurityContextRepository());
HttpBasicServerAuthenticationEntryPoint authenticationEntryPoint = new HttpBasicServerAuthenticationEntryPoint();
authenticationEntryPoint.setRealm("myrealm");
@@ -344,7 +344,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed() throws Exception {
public void requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed() {
ReactiveAuthenticationManager customAuthenticationManager = mock(ReactiveAuthenticationManager.class);
given(customAuthenticationManager.authenticate(any()))
.willReturn(Mono.just(new TestingAuthenticationToken("rob", "rob", "ROLE_USER", "ROLE_ADMIN")));
@@ -386,7 +386,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void x509WhenCustomizedThenAddsX509Filter() throws Exception {
public void x509WhenCustomizedThenAddsX509Filter() {
X509PrincipalExtractor mockExtractor = mock(X509PrincipalExtractor.class);
ReactiveAuthenticationManager mockAuthenticationManager = mock(ReactiveAuthenticationManager.class);
@@ -413,7 +413,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void x509WhenDefaultsThenAddsX509Filter() throws Exception {
public void x509WhenDefaultsThenAddsX509Filter() {
this.http.x509(withDefaults());
SecurityWebFilterChain securityWebFilterChain = this.http.build();
@@ -423,7 +423,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void postWhenCsrfDisabledThenPermitted() throws Exception {
public void postWhenCsrfDisabledThenPermitted() {
SecurityWebFilterChain securityFilterChain = this.http.csrf(csrf -> csrf.disable()).build();
WebFilterChainProxy springSecurityFilterChain = new WebFilterChainProxy(securityFilterChain);
WebTestClient client = WebTestClientBuilder.bindToWebFilters(springSecurityFilterChain).build();
@@ -435,7 +435,7 @@ public class ServerHttpSecurityTests {
}
@Test
public void postWhenCustomCsrfTokenRepositoryThenUsed() throws Exception {
public void postWhenCustomCsrfTokenRepositoryThenUsed() {
ServerCsrfTokenRepository customServerCsrfTokenRepository = mock(ServerCsrfTokenRepository.class);
when(customServerCsrfTokenRepository.loadToken(any(ServerWebExchange.class))).thenReturn(Mono.empty());
SecurityWebFilterChain securityFilterChain = this.http
@@ -299,7 +299,7 @@ public class WebSocketMessageBrokerConfigTests {
}
@Test
public void sendWhenNoIdMessageThenAuthenticationPrincipalResolved() throws Exception {
public void sendWhenNoIdMessageThenAuthenticationPrincipalResolved() {
this.spring.configLocations(xml("SyncConfig")).autowire();
this.clientInboundChannel.send(message("/message"));
@@ -484,7 +484,7 @@ public class WebSocketMessageBrokerConfigTests {
}
@Override
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
public Object resolveArgument(MethodParameter parameter, Message<?> message) {
return new MessageArgument("");
}
}
@@ -57,7 +57,7 @@ final class MockWebResponseBuilder {
return new WebResponse(webResponseData, this.webRequest, endTime - this.startTime);
}
private WebResponseData webResponseData() throws IOException {
private WebResponseData webResponseData() {
List<NameValuePair> responseHeaders = responseHeaders();
HttpStatus status = this.exchangeResult.getStatus();
return new WebResponseData(this.exchangeResult.getResponseBodyContent(), status.value(), status.getReasonPhrase(), responseHeaders);