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

View File

@@ -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);");

View File

@@ -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();

View File

@@ -72,7 +72,7 @@ public class SecurityNamespaceHandlerTests {
}
@Test
public void pre32SchemaAreNotSupported() throws Exception {
public void pre32SchemaAreNotSupported() {
try {
new InMemoryXmlApplicationContext(
"<user-service id='us'>"

View File

@@ -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);
}

View File

@@ -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());
}

View File

@@ -60,7 +60,7 @@ public class PasswordEncoderConfigurerTests {
// @formatter:on
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(HttpSecurity http) {
}
@Bean

View File

@@ -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

View File

@@ -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);

View File

@@ -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());
}

View File

@@ -251,7 +251,7 @@ public class GlobalMethodSecurityConfigurationTests {
}
@Test
public void multiPermissionEvaluatorConfig() throws Exception {
public void multiPermissionEvaluatorConfig() {
this.spring.register(MultiPermissionEvaluatorConfig.class).autowire();
// no exception

View File

@@ -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";
}
}

View File

@@ -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) {
}
}

View File

@@ -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/**");

View File

@@ -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;
}
}

View File

@@ -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(),

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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");

View File

@@ -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) {
}
}

View File

@@ -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) {
}
}

View File

@@ -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()

View File

@@ -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();
}

View File

@@ -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());
}

View File

@@ -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/**");

View File

@@ -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) {
}
}

View File

@@ -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)));

View File

@@ -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);

View File

@@ -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);

View File

@@ -76,7 +76,7 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
protected void configure(AuthenticationManagerBuilder auth) {
auth
.authenticationProvider(new TransientAuthenticationProvider());
}

View File

@@ -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);
}

View File

@@ -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("");
}
}

View File

@@ -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

View File

@@ -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'> "

View File

@@ -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)));

View File

@@ -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() )

View File

@@ -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"));

View File

@@ -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();

View File

@@ -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);

View File

@@ -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());
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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()
+ "'/>"

View File

@@ -103,7 +103,7 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements
}
@Test(expected = AuthenticationException.class)
public void transactionalMethodsShouldBeSecured() throws Exception {
public void transactionalMethodsShouldBeSecured() {
transactionalTarget.doSomething();
}

View File

@@ -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")

View File

@@ -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);
}
});

View File

@@ -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 });
}

View File

@@ -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

View File

@@ -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");

View File

@@ -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 ->

View File

@@ -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

View File

@@ -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

View File

@@ -121,7 +121,7 @@ public class LogoutSpecTests {
}
@Test
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() throws Exception {
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(authorizeExchange ->
authorizeExchange

View File

@@ -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(

View File

@@ -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()

View File

@@ -105,7 +105,7 @@ public class RequestCacheTests {
}
@Test
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() throws Exception {
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
SecurityWebFilterChain securityWebFilter = this.http
.authorizeExchange(authorizeExchange ->
authorizeExchange

View File

@@ -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

View File

@@ -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("");
}
}

View File

@@ -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);