From 34dd5fea30d4e3d862dfc675cb97cf967a6ad25b Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Fri, 23 Aug 2019 01:03:54 +0200 Subject: [PATCH] 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. --- .../security/acls/jdbc/AclClassIdUtils.java | 2 +- .../acls/AclFormattingUtilsTests.java | 10 ++--- .../AclPermissionCacheOptimizerTests.java | 2 +- .../acls/AclPermissionEvaluatorTests.java | 2 +- ...ationCollectionFilteringProviderTests.java | 6 +-- .../AclEntryAfterInvocationProviderTests.java | 8 ++-- .../security/acls/domain/AclImplTests.java | 45 +++++++++---------- .../AclImplementationSecurityCheckTests.java | 12 ++--- .../acls/domain/AuditLoggerTests.java | 12 ++--- .../acls/domain/ObjectIdentityImplTests.java | 16 +++---- ...ectIdentityRetrievalStrategyImplTests.java | 2 +- .../AbstractBasicLookupStrategyTests.java | 6 +-- .../acls/jdbc/AclClassIdUtilsTest.java | 4 +- .../acls/jdbc/BasicLookupStrategyTests.java | 2 +- ...icLookupStrategyWithAclClassTypeTests.java | 2 +- .../acls/jdbc/EhCacheBasedAclCacheTests.java | 22 ++++----- .../acls/jdbc/JdbcMutableAclServiceTests.java | 22 ++++----- ...cMutableAclServiceTestsWithAclClassId.java | 2 +- .../jdbc/SpringCacheBasedAclCacheTests.java | 4 +- .../acls/sid/SidRetrievalStrategyTests.java | 4 +- .../security/acls/sid/SidTests.java | 14 +++--- .../aspect/AnnotationSecurityAspect.aj | 2 +- .../aspect/AnnotationSecurityAspectTests.java | 16 +++---- .../security/cas/ServiceProperties.java | 2 +- .../CasAuthenticationProvider.java | 2 +- .../EhCacheBasedTicketCache.java | 2 +- .../SpringCacheBasedTicketCache.java | 2 +- .../cas/web/CasAuthenticationEntryPoint.java | 5 +-- .../CasAuthenticationProviderTests.java | 3 +- .../CasAuthenticationTokenMixinTests.java | 2 +- ...pUserServiceBeanDefinitionParserTests.java | 12 ++--- .../AbstractConfiguredSecurityBuilder.java | 5 +-- .../AuthenticationManagerBuilder.java | 2 +- .../AuthenticationConfiguration.java | 2 +- ...ticationProviderBeanManagerConfigurer.java | 2 +- .../JdbcUserDetailsManagerConfigurer.java | 24 +++------- ...utowireBeanFactoryObjectPostProcessor.java | 2 +- .../ReactiveMethodSecurityConfiguration.java | 2 +- .../annotation/web/builders/HttpSecurity.java | 5 +-- .../WebSecurityConfiguration.java | 3 +- .../WebSecurityConfigurerAdapter.java | 2 +- .../web/configurers/AnonymousConfigurer.java | 4 +- .../ChannelSecurityConfigurer.java | 2 +- .../web/configurers/CorsConfigurer.java | 2 +- .../web/configurers/CsrfConfigurer.java | 2 +- .../DefaultLoginPageConfigurer.java | 4 +- .../ExceptionHandlingConfigurer.java | 2 +- .../web/configurers/HeadersConfigurer.java | 2 +- .../web/configurers/HttpBasicConfigurer.java | 7 ++- .../web/configurers/JeeConfigurer.java | 4 +- .../web/configurers/LogoutConfigurer.java | 5 +-- .../web/configurers/PortMapperConfigurer.java | 2 +- .../web/configurers/RememberMeConfigurer.java | 8 ++-- .../configurers/RequestCacheConfigurer.java | 4 +- .../SecurityContextConfigurer.java | 2 +- .../web/configurers/ServletApiConfigurer.java | 2 +- .../SessionManagementConfigurer.java | 4 +- .../web/configurers/X509Configurer.java | 4 +- .../client/ImplicitGrantConfigurer.java | 2 +- .../oauth2/client/OAuth2ClientConfigurer.java | 8 ++-- .../OAuth2ResourceServerConfigurer.java | 4 +- .../UserDetailsMapFactoryBean.java | 2 +- .../security/config/DataSourcePopulator.java | 2 +- .../config/FilterChainProxyConfigTests.java | 7 ++- .../config/SecurityNamespaceHandlerTests.java | 2 +- .../ConcereteSecurityConfigurerAdapter.java | 2 +- .../NamespaceAuthenticationProviderTests.java | 2 +- .../PasswordEncoderConfigurerTests.java | 2 +- .../AuthenticationConfigurationTests.java | 8 ++-- ...reBeanFactoryObjectPostProcessorTests.java | 2 +- .../annotation/issue50/SecurityConfig.java | 2 +- ...lobalMethodSecurityConfigurationTests.java | 2 +- ...bstractConfiguredSecurityBuilderTests.java | 4 +- .../web/HttpSecurityHeadersTests.java | 4 +- ...mpleWebSecurityConfigurerAdapterTests.java | 4 +- ...curityConfigurerAdapterPowermockTests.java | 6 +-- .../WebSecurityConfigurerAdapterTests.java | 16 +++---- .../web/builders/HttpConfigurationTests.java | 6 +-- .../web/builders/NamespaceHttpTests.java | 26 +++++------ .../web/builders/WebSecurityTests.java | 4 +- .../configuration/EnableWebSecurityTests.java | 6 +-- .../OAuth2ClientConfigurationTests.java | 2 +- .../web/configuration/Sec2515Tests.java | 8 ++-- .../WebSecurityConfigurationTests.java | 26 +++++------ .../CsrfConfigurerNoWebMvcTests.java | 4 +- .../web/configurers/CsrfConfigurerTests.java | 2 +- .../configurers/FormLoginConfigurerTests.java | 2 +- .../NamespaceHttpCustomFilterTests.java | 7 ++- .../NamespaceHttpFirewallTests.java | 4 +- .../NamespaceHttpFormLoginTests.java | 2 +- .../configurers/NamespaceHttpLogoutTests.java | 2 +- .../RememberMeConfigurerTests.java | 4 +- .../ServletApiConfigurerTests.java | 2 +- .../SessionManagementConfigurerTests.java | 2 +- ...onfigurerTransientAuthenticationTests.java | 2 +- .../OAuth2ResourceServerConfigurerTests.java | 2 +- ...WebSocketMessageBrokerConfigurerTests.java | 26 +++++------ ...ationManagerBeanDefinitionParserTests.java | 6 +-- ...tionProviderBeanDefinitionParserTests.java | 12 ++--- ...cUserServiceBeanDefinitionParserTests.java | 2 +- .../UserDetailsResourceFactoryBeanTest.java | 6 +-- .../http/CsrfBeanDefinitionParserTests.java | 2 +- .../security/config/http/CsrfConfigTests.java | 2 +- .../DefaultFilterChainValidatorTests.java | 2 +- .../config/http/FormLoginConfigTests.java | 4 +- .../config/http/MiscHttpConfigTests.java | 8 ++-- .../config/http/OpenIDConfigTests.java | 3 +- ...thodSecurityBeanDefinitionParserTests.java | 10 ++--- ...ptMethodsBeanDefinitionDecoratorTests.java | 2 +- .../client/CommonOAuth2ProviderTests.java | 8 ++-- .../config/test/SpringTestContext.java | 5 +-- .../InMemoryXmlWebApplicationContext.java | 2 +- .../server/AuthorizeExchangeSpecTests.java | 4 +- .../config/web/server/CorsSpecTests.java | 2 +- .../server/ExceptionHandlingSpecTests.java | 11 ++--- .../config/web/server/FormLoginTests.java | 4 +- .../config/web/server/HeaderSpecTests.java | 28 ++++++------ .../config/web/server/LogoutSpecTests.java | 2 +- .../config/web/server/OAuth2LoginTests.java | 2 +- .../server/OAuth2ResourceServerSpecTests.java | 2 +- .../config/web/server/RequestCacheTests.java | 2 +- .../web/server/ServerHttpSecurityTests.java | 14 +++--- .../WebSocketMessageBrokerConfigTests.java | 4 +- .../server/MockWebResponseBuilder.java | 2 +- .../AbstractSecurityInterceptor.java | 2 +- .../AfterInvocationProviderManager.java | 2 +- .../MethodInvocationPrivilegeEvaluator.java | 2 +- .../RunAsImplAuthenticationProvider.java | 2 +- .../access/intercept/RunAsManagerImpl.java | 2 +- ...rePostAdviceReactiveMethodInterceptor.java | 3 +- .../vote/AbstractAccessDecisionManager.java | 2 +- .../authentication/ProviderManager.java | 2 +- .../RememberMeAuthenticationProvider.java | 2 +- ...ractUserDetailsAuthenticationProvider.java | 2 +- .../dao/DaoAuthenticationProvider.java | 2 +- .../JaasAuthenticationCallbackHandler.java | 5 +-- .../jaas/JaasNameCallbackHandler.java | 5 +-- .../jaas/JaasPasswordCallbackHandler.java | 5 +-- .../jaas/SecurityContextLoginModule.java | 6 +-- .../rcp/RemoteAuthenticationManagerImpl.java | 2 +- .../rcp/RemoteAuthenticationProvider.java | 2 +- ...edAttributes2GrantedAuthoritiesMapper.java | 2 +- ...leAttributes2GrantedAuthoritiesMapper.java | 2 +- .../mapping/SimpleAuthorityMapper.java | 2 +- .../KeyBasedPersistenceTokenService.java | 2 +- .../UserDetailsByNameServiceWrapper.java | 2 +- .../cache/EhCacheBasedUserCache.java | 2 +- .../cache/SpringCacheBasedUserCache.java | 2 +- .../security/util/InMemoryResource.java | 2 +- .../security/util/SimpleMethodInvocation.java | 2 +- .../security/TestDataSource.java | 2 +- .../AuthorizationFailureEventTests.java | 2 +- .../security/access/SecurityConfigTests.java | 2 +- .../access/annotation/Jsr250VoterTests.java | 2 +- ...AnnotationSecurityMetadataSourceTests.java | 2 +- ...bstractSecurityExpressionHandlerTests.java | 4 +- .../SecurityExpressionRootTests.java | 25 +++++------ ...pressionBasedPreInvocationAdviceTests.java | 2 +- .../MethodSecurityExpressionRootTests.java | 12 +++-- ...AnnotationSecurityMetadataSourceTests.java | 9 ++-- .../RoleHierarchyUtilsTests.java | 14 +++--- .../AbstractSecurityInterceptorTests.java | 2 +- .../intercept/RunAsManagerImplTests.java | 9 ++-- .../MethodSecurityInterceptorTests.java | 17 ++++--- ...AspectJMethodSecurityInterceptorTests.java | 11 +++-- ...asedMethodSecurityMetadataSourceTests.java | 2 +- ...thodInvocationPrivilegeEvaluatorTests.java | 8 ++-- .../method/MockMethodInvocation.java | 2 +- .../AbstractAccessDecisionManagerTests.java | 12 ++--- .../access/vote/AbstractAclVoterTests.java | 7 ++- .../access/vote/AffirmativeBasedTests.java | 12 +++-- .../access/vote/ConsensusBasedTests.java | 16 +++---- .../access/vote/UnanimousBasedTests.java | 15 +++---- .../AbstractAuthenticationTokenTests.java | 10 ++--- ...aultAuthenticationEventPublisherTests.java | 4 +- .../authentication/ProviderManagerTests.java | 29 +++++------- .../AnonymousAuthenticationProviderTests.java | 10 ++--- .../AnonymousAuthenticationTokenTests.java | 6 +-- ...efaultJaasAuthenticationProviderTests.java | 4 +- .../jaas/JaasAuthenticationProviderTests.java | 8 ++-- .../jaas/JaasGrantedAuthorityTests.java | 6 +-- .../jaas/SecurityContextLoginModuleTests.java | 8 ++-- .../jaas/TestCallbackHandler.java | 3 +- .../authentication/jaas/TestLoginModule.java | 6 +-- ...RememberMeAuthenticationProviderTests.java | 8 ++-- ...ngSecurityContextExecutorServiceTests.java | 8 ++-- ...elegatingSecurityContextRunnableTests.java | 2 +- .../core/SpringSecurityCoreVersionTests.java | 6 +-- .../SimpleGrantedAuthorityTests.java | 2 +- .../mapping/SimpleAuthoritiesMapperTests.java | 2 +- .../context/SecurityContextHolderTests.java | 2 +- ...nnotationParameterNameDiscovererTests.java | 6 +-- .../session/SessionRegistryImplTests.java | 8 ++-- .../security/core/userdetails/UserTests.java | 14 +++--- .../userdetails/cache/NullUserCacheTests.java | 2 +- .../userdetails/jdbc/JdbcDaoImplTests.java | 12 ++--- ...memberMeAuthenticationTokenMixinTests.java | 4 +- .../SecurityJackson2ModulesTests.java | 2 +- ...PasswordAuthenticationTokenMixinTests.java | 2 +- .../JdbcUserDetailsManagerTests.java | 20 ++++----- .../security/util/InMemoryResourceTests.java | 2 +- .../util/MethodInvocationUtilsTests.java | 2 +- .../argon2/Argon2EncodingUtilsTests.java | 8 ++-- .../argon2/Argon2PasswordEncoderTests.java | 12 ++--- ...astleAesBytesEncryptorEquivalencyTest.java | 6 +-- .../BouncyCastleAesBytesEncryptorTest.java | 8 ++-- .../crypto/keygen/KeyGeneratorsTests.java | 2 +- .../password/LdapShaPasswordEncoderTests.java | 2 +- .../MessageDigestPasswordEncoderTests.java | 12 ++--- .../integration/MultiAnnotationTests.java | 4 +- .../SEC933ApplicationContextTests.java | 2 +- .../PythonInterpreterBasedSecurityTests.java | 2 +- .../AbstractWebServerIntegrationTests.java | 2 +- .../security/itest/web/TestController.java | 2 +- ...faultSpringSecurityContextSourceTests.java | 16 +++---- .../SpringSecurityLdapTemplateITests.java | 4 +- .../PasswordComparisonAuthenticatorTests.java | 4 +- .../FilterBasedLdapUserSearchTests.java | 4 +- .../server/ApacheDSEmbeddedLdifTests.java | 2 +- .../DefaultLdapAuthoritiesPopulatorTests.java | 6 +-- .../LdapUserDetailsManagerTests.java | 4 +- .../NestedLdapAuthoritiesPopulatorTests.java | 2 +- .../AbstractLdapAuthenticator.java | 2 +- .../ldap/server/ApacheDSContainer.java | 2 +- .../ldap/server/UnboundIdContainer.java | 4 +- ...ectoryLdapAuthenticationProviderTests.java | 13 +++--- ...PasswordPolicyAwareContextSourceTests.java | 5 +-- .../PasswordPolicyControlFactoryTests.java | 4 +- .../ldap/userdetails/InetOrgPersonTests.java | 2 +- .../ldap/userdetails/LdapAuthorityTests.java | 6 +-- .../LdapUserDetailsMapperTests.java | 6 +-- .../LdapUserDetailsServiceTests.java | 2 +- ...sServiceLdapAuthoritiesPopulatorTests.java | 2 +- ...thenticationPrincipalArgumentResolver.java | 5 +-- .../server/CsrfTokenHandshakeInterceptor.java | 2 +- .../ChannelSecurityInterceptorTests.java | 22 ++++----- ...icationPrincipalArgumentResolverTests.java | 6 +-- ...ecurityContextChannelInterceptorTests.java | 31 +++++++------ .../SimpDestinationMessageMatcherTests.java | 22 ++++----- .../OAuth2AuthorizationCodeGrantFilter.java | 2 +- ...th2AuthorizationRequestRedirectFilter.java | 4 +- .../web/OAuth2LoginAuthenticationFilter.java | 2 +- ...Auth2AuthorizedClientArgumentResolver.java | 2 +- ...uthorizedClientExchangeFilterFunction.java | 4 +- ...Auth2LoginAuthenticationProviderTests.java | 2 +- ...orizationCodeTokenResponseClientTests.java | 8 ++-- ...orizationCodeTokenResponseClientTests.java | 10 ++--- .../registration/ClientRegistrationsTest.java | 14 +++--- ...DefaultReactiveOAuth2UserServiceTests.java | 8 ++-- ...izedClientExchangeFilterFunctionTests.java | 2 +- ...cessTokenResponseHttpMessageConverter.java | 4 +- .../OAuth2ErrorHttpMessageConverter.java | 4 +- .../function/OAuth2BodyExtractorsTests.java | 4 +- .../jwt/MappedJwtClaimSetConverterTests.java | 4 +- .../jwt/NimbusJwtDecoderJwkSupportTests.java | 2 +- .../oauth2/jwt/NimbusJwtDecoderTests.java | 2 +- .../BearerTokenAuthenticationEntryPoint.java | 3 +- .../BearerTokenAccessDeniedHandler.java | 3 +- .../security/openid/OpenID4JavaConsumer.java | 2 +- .../openid/OpenIDAuthenticationProvider.java | 2 +- .../security/openid/MockOpenIDConsumer.java | 5 +-- .../OpenIDAuthenticationFilterTests.java | 5 +-- ...ationSimpleHttpInvokerRequestExecutor.java | 4 +- ...SimpleHttpInvokerRequestExecutorTests.java | 4 +- ...ntextPropagatingRemoteInvocationTests.java | 2 +- .../HelloWebfluxMethodApplicationITests.java | 6 +-- .../src/main/java/sample/SecurityConfig.java | 2 +- .../HelloWebfluxMethodApplicationTests.java | 14 +++--- .../sample/HelloWebfluxApplicationITests.java | 6 +-- .../sample/HelloWebfluxApplicationTests.java | 10 ++--- .../HelloWebfluxFnApplicationITests.java | 6 +-- .../HelloWebfluxFnApplicationTests.java | 10 ++--- .../AuthorizationServerConfiguration.java | 2 +- .../samples/OAuth2LoginApplicationTests.java | 4 +- .../boot/env/MockWebServerPropertySource.java | 2 +- .../boot/env/MockWebServerPropertySource.java | 2 +- .../src/main/java/sample/SecurityConfig.java | 2 +- .../boot/env/MockWebServerPropertySource.java | 2 +- .../java/sample/config/SecurityConfig.java | 2 +- .../sample/WebfluxFormApplicationTests.java | 4 +- .../aspectj/AspectJInterceptorTests.java | 16 +++---- .../samples/config/SecurityConfig.java | 2 +- .../samples/config/SecurityConfig.java | 4 +- .../aspectj/AspectJInterceptorTests.java | 16 +++---- .../cas/web/ProxyTicketSampleServlet.java | 2 +- .../sample/contact/ContactManagerBackend.java | 2 +- .../sample/contact/DataSourcePopulator.java | 2 +- .../java/sample/dms/DataSourcePopulator.java | 2 +- .../gae/security/GaeAuthenticationFilter.java | 2 +- ...oogleAccountsAuthenticationEntryPoint.java | 2 +- .../samples/gae/security/AppRoleTests.java | 2 +- .../users/GaeDataStoreUserRegistryTests.java | 4 +- .../UsernameEqualsPasswordLoginModule.java | 6 +-- .../servletapi/mvc/ServletApiController.java | 4 +- .../src/main/java/bigbank/SeedData.java | 2 +- .../main/java/bigbank/web/ListAccounts.java | 2 +- .../taglibs/authz/AuthenticationTag.java | 2 +- .../taglibs/authz/AuthenticationTagTests.java | 2 +- .../taglibs/authz/AuthorizeTagTests.java | 4 +- .../ReactorContextTestExecutionListener.java | 4 +- ...hSecurityContextTestExecutionListener.java | 4 +- .../SecurityMockMvcResultMatchers.java | 4 +- ...rityContextTestExecutionListenerTests.java | 4 +- ...yMockMvcRequestBuildersFormLoginTests.java | 8 ++-- ...MockMvcRequestBuildersFormLogoutTests.java | 4 +- ...estPostProcessorsCsrfDebugFilterTests.java | 6 +-- ...MockMvcRequestPostProcessorsCsrfTests.java | 6 +-- ...ckMvcRequestPostProcessorsDigestTests.java | 3 +- .../setup/SecurityMockMvcConfigurerTests.java | 4 +- .../showcase/csrf/CsrfShowcaseTests.java | 2 +- .../csrf/DefaultCsrfShowcaseTests.java | 2 +- .../test/web/support/WebTestUtilsTests.java | 2 +- .../security/web/FilterInvocation.java | 2 +- .../channel/AbstractRetryEntryPoint.java | 2 +- .../channel/ChannelDecisionManagerImpl.java | 2 +- .../web/access/channel/ChannelEntryPoint.java | 2 +- .../channel/InsecureChannelProcessor.java | 2 +- .../channel/SecureChannelProcessor.java | 2 +- .../intercept/FilterSecurityInterceptor.java | 3 +- ...bstractAuthenticationProcessingFilter.java | 3 +- ...AuthenticationTargetUrlRequestHandler.java | 2 +- .../authentication/AuthenticationFilter.java | 2 +- .../DelegatingAuthenticationEntryPoint.java | 2 +- .../Http403ForbiddenEntryPoint.java | 4 +- .../authentication/HttpStatusEntryPoint.java | 2 +- .../LoginUrlAuthenticationEntryPoint.java | 5 +-- ...tpStatusReturningLogoutSuccessHandler.java | 2 +- ...ticatedWebAuthenticationDetailsSource.java | 2 +- .../WebXmlMappableAttributesRetriever.java | 3 +- .../AbstractRememberMeServices.java | 2 +- .../www/BasicAuthenticationEntryPoint.java | 2 +- .../www/BasicAuthenticationFilter.java | 5 +-- .../www/DigestAuthenticationEntryPoint.java | 4 +- ...thenticationPrincipalArgumentResolver.java | 4 +- ...urrentSecurityContextArgumentResolver.java | 2 +- ...ractSecurityWebApplicationInitializer.java | 2 +- ...yContextCallableProcessingInterceptor.java | 8 ++-- .../security/web/debug/DebugFilter.java | 2 +- ...thenticationPrincipalArgumentResolver.java | 4 +- .../annotation/CsrfTokenArgumentResolver.java | 4 +- .../web/session/ConcurrentSessionFilter.java | 2 +- .../web/session/InvalidSessionStrategy.java | 2 +- .../SessionInformationExpiredStrategy.java | 2 +- .../security/web/FilterChainProxyTests.java | 2 +- .../security/web/FilterInvocationTests.java | 2 +- .../security/web/PortMapperImplTests.java | 6 +-- .../security/web/PortResolverImplTests.java | 10 ++--- ...tWebInvocationPrivilegeEvaluatorTests.java | 12 +++-- .../ExceptionTranslationFilterTests.java | 8 ++-- .../ChannelDecisionManagerImplTests.java | 5 +-- .../channel/ChannelProcessingFilterTests.java | 13 +++--- .../channel/RetryWithHttpEntryPointTests.java | 4 +- .../RetryWithHttpsEntryPointTests.java | 4 +- ...aultWebSecurityExpressionHandlerTests.java | 2 +- ...InvocationSecurityMetadataSourceTests.java | 2 +- .../expression/WebExpressionVoterTests.java | 2 +- .../WebSecurityExpressionRootTests.java | 4 +- ...InvocationSecurityMetadataSourceTests.java | 2 +- .../FilterSecurityInterceptorTests.java | 4 +- .../web/access/intercept/RequestKeyTests.java | 3 +- ...ctAuthenticationProcessingFilterTests.java | 15 +++---- .../AnonymousAuthenticationFilterTests.java | 9 ++-- .../AuthenticationFilterTests.java | 2 +- ...LoginUrlAuthenticationEntryPointTests.java | 6 +-- ...namePasswordAuthenticationFilterTests.java | 12 ++--- ...tusReturningLogoutSuccessHandlerTests.java | 2 +- .../logout/LogoutHandlerTests.java | 2 +- ...PreAuthenticatedProcessingFilterTests.java | 5 +-- ...henticatedAuthenticationProviderTests.java | 5 +-- .../SubjectDnX509PrincipalExtractorTests.java | 2 +- .../AbstractRememberMeServicesTests.java | 14 +++--- .../JdbcTokenRepositoryImplTests.java | 2 +- ...tentTokenBasedRememberMeServicesTests.java | 2 +- .../TokenBasedRememberMeServicesTests.java | 26 +++++------ ...ionControlAuthenticationStrategyTests.java | 2 +- .../switchuser/SwitchUserFilterTests.java | 22 ++++----- .../SwitchUserGrantedAuthorityTests.java | 6 +-- .../BasicAuthenticationConverterTests.java | 8 ++-- .../BasicAuthenticationEntryPointTests.java | 2 +- .../www/BasicAuthenticationFilterTests.java | 8 ++-- .../www/DigestAuthenticationFilterTests.java | 4 +- ...icationPrincipalArgumentResolverTests.java | 6 +-- ...tSecurityContextArgumentResolverTests.java | 10 ++--- .../ConcurrentSessionFilterTests.java | 2 +- ...SessionSecurityContextRepositoryTests.java | 32 ++++++------- ...WebAsyncManagerIntegrationFilterTests.java | 6 +-- .../firewall/DefaultHttpFirewallTests.java | 2 +- .../web/firewall/FirewalledResponseTests.java | 4 +- .../web/firewall/StrictHttpFirewallTests.java | 30 ++++++------- .../web/header/HeaderWriterFilterTests.java | 4 +- .../header/writers/HpkpHeaderWriterTests.java | 2 +- .../JaasApiIntegrationFilterTests.java | 2 +- .../web/jackson2/SavedCookieMixinTests.java | 2 +- .../WebAuthenticationDetailsMixinTests.java | 2 +- .../security/web/method/ResolvableMethod.java | 2 +- ...icationPrincipalArgumentResolverTests.java | 6 +-- ...icationPrincipalArgumentResolverTests.java | 24 +++++----- ...tSecurityContextArgumentResolverTests.java | 38 ++++++++-------- .../DefaultSavedRequestTests.java | 6 +-- .../HttpSessionRequestCacheTests.java | 4 +- .../web/savedrequest/SavedCookieTests.java | 20 ++++----- .../SavedRequestAwareWrapperTests.java | 10 ++--- .../AndServerWebExchangeMatcherTests.java | 10 ++--- .../NegatedServerWebExchangeMatcherTests.java | 6 +-- .../OrServerWebExchangeMatcherTests.java | 8 ++-- .../ServerWebExchangeMatchersTests.java | 10 ++--- .../util/matcher/MvcRequestMatcherTests.java | 11 +++-- ...ContextHolderAwareRequestWrapperTests.java | 10 ++--- ...ultSessionAuthenticationStrategyTests.java | 16 +++---- .../util/OnCommittedResponseWrapperTests.java | 2 +- .../web/util/TextEscapeUtilsTests.java | 12 ++--- .../web/util/ThrowableAnalyzerTests.java | 2 +- .../security/web/util/UrlUtilsTests.java | 2 +- .../matcher/AntPathRequestMatcherTests.java | 11 +++-- .../util/matcher/ELRequestMatcherTests.java | 12 ++--- .../util/matcher/IpAddressMatcherTests.java | 6 +-- .../matcher/MediaTypeRequestMatcherTests.java | 20 ++++----- .../matcher/RegexRequestMatcherTests.java | 6 +-- 418 files changed, 1146 insertions(+), 1273 deletions(-) diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java b/acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java index 1726048015..677dbb5cb8 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java @@ -74,7 +74,7 @@ class AclClassIdUtils { return identifier; } - private boolean hasValidClassIdType(ResultSet resultSet) throws SQLException { + private boolean hasValidClassIdType(ResultSet resultSet) { boolean hasClassIdType = false; try { hasClassIdType = classIdTypeFrom(resultSet) != null; diff --git a/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java b/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java index f63a22bd62..acf951ef06 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java @@ -32,7 +32,7 @@ public class AclFormattingUtilsTests { // ~ Methods // ======================================================================================================== @Test - public final void testDemergePatternsParametersConstraints() throws Exception { + public final void testDemergePatternsParametersConstraints() { try { AclFormattingUtils.demergePatterns(null, "SOME STRING"); fail("It should have thrown IllegalArgumentException"); @@ -63,7 +63,7 @@ public class AclFormattingUtilsTests { } @Test - public final void testDemergePatterns() throws Exception { + public final void testDemergePatterns() { String original = "...........................A...R"; String removeBits = "...............................R"; assertThat(AclFormattingUtils.demergePatterns(original, removeBits)).isEqualTo( @@ -76,7 +76,7 @@ public class AclFormattingUtilsTests { } @Test - public final void testMergePatternsParametersConstraints() throws Exception { + public final void testMergePatternsParametersConstraints() { try { AclFormattingUtils.mergePatterns(null, "SOME STRING"); fail("It should have thrown IllegalArgumentException"); @@ -106,7 +106,7 @@ public class AclFormattingUtilsTests { } @Test - public final void testMergePatterns() throws Exception { + public final void testMergePatterns() { String original = "...............................R"; String extraBits = "...........................A...."; assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo( @@ -119,7 +119,7 @@ public class AclFormattingUtilsTests { } @Test - public final void testBinaryPrints() throws Exception { + public final void testBinaryPrints() { assertThat(AclFormattingUtils.printBinary(15)).isEqualTo( "............................****"); diff --git a/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java b/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java index 14dbd99f54..d499a79ca7 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java @@ -36,7 +36,7 @@ import java.util.List; public class AclPermissionCacheOptimizerTests { @Test - public void eagerlyLoadsRequiredAcls() throws Exception { + public void eagerlyLoadsRequiredAcls() { AclService service = mock(AclService.class); AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service); ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class); diff --git a/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java b/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java index 5eb40b387b..47df332908 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java @@ -37,7 +37,7 @@ import org.springframework.security.core.Authentication; public class AclPermissionEvaluatorTests { @Test - public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception { + public void hasPermissionReturnsTrueIfAclGrantsPermission() { AclService service = mock(AclService.class); AclPermissionEvaluator pe = new AclPermissionEvaluator(service); ObjectIdentity oid = mock(ObjectIdentity.class); diff --git a/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java b/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java index b365976a08..b85b01d3dd 100644 --- a/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java +++ b/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java @@ -37,7 +37,7 @@ import java.util.List; @SuppressWarnings({ "unchecked" }) public class AclEntryAfterInvocationCollectionFilteringProviderTests { @Test - public void objectsAreRemovedIfPermissionDenied() throws Exception { + public void objectsAreRemovedIfPermissionDenied() { AclService service = mock(AclService.class); Acl acl = mock(Acl.class); when(acl.isGranted(any(), any(), anyBoolean())).thenReturn( @@ -63,7 +63,7 @@ public class AclEntryAfterInvocationCollectionFilteringProviderTests { } @Test - public void accessIsGrantedIfNoAttributesDefined() throws Exception { + public void accessIsGrantedIfNoAttributesDefined() { AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider( mock(AclService.class), Arrays.asList(mock(Permission.class))); Object returned = new Object(); @@ -75,7 +75,7 @@ public class AclEntryAfterInvocationCollectionFilteringProviderTests { } @Test - public void nullReturnObjectIsIgnored() throws Exception { + public void nullReturnObjectIsIgnored() { AclService service = mock(AclService.class); AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider( service, Arrays.asList(mock(Permission.class))); diff --git a/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java b/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java index 9ceefb66dc..322bb3d11f 100644 --- a/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java +++ b/acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java @@ -37,7 +37,7 @@ import java.util.List; public class AclEntryAfterInvocationProviderTests { @Test(expected = IllegalArgumentException.class) - public void rejectsMissingPermissions() throws Exception { + public void rejectsMissingPermissions() { try { new AclEntryAfterInvocationProvider(mock(AclService.class), null); fail("Exception expected"); @@ -72,7 +72,7 @@ public class AclEntryAfterInvocationProviderTests { } @Test - public void accessIsGrantedIfNoAttributesDefined() throws Exception { + public void accessIsGrantedIfNoAttributesDefined() { AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( mock(AclService.class), Arrays.asList(mock(Permission.class))); Object returned = new Object(); @@ -85,7 +85,7 @@ public class AclEntryAfterInvocationProviderTests { } @Test - public void accessIsGrantedIfObjectTypeNotSupported() throws Exception { + public void accessIsGrantedIfObjectTypeNotSupported() { AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( mock(AclService.class), Arrays.asList(mock(Permission.class))); provider.setProcessDomainObjectClass(String.class); @@ -131,7 +131,7 @@ public class AclEntryAfterInvocationProviderTests { } @Test - public void nullReturnObjectIsIgnored() throws Exception { + public void nullReturnObjectIsIgnored() { AclService service = mock(AclService.class); AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( service, Arrays.asList(mock(Permission.class))); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java index 149bbe9db1..c0d6b7a49b 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java @@ -54,7 +54,7 @@ public class AclImplTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { SecurityContextHolder.getContext().setAuthentication(auth); authzStrategy = mock(AclAuthorizationStrategy.class); mockAuditLogger = mock(AuditLogger.class); @@ -63,12 +63,12 @@ public class AclImplTests { } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @Test(expected = IllegalArgumentException.class) - public void constructorsRejectNullObjectIdentity() throws Exception { + public void constructorsRejectNullObjectIdentity() { try { new AclImpl(null, 1, authzStrategy, pgs, null, null, true, new PrincipalSid( "joe")); @@ -80,7 +80,7 @@ public class AclImplTests { } @Test(expected = IllegalArgumentException.class) - public void constructorsRejectNullId() throws Exception { + public void constructorsRejectNullId() { try { new AclImpl(objectIdentity, null, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); @@ -93,7 +93,7 @@ public class AclImplTests { @SuppressWarnings("deprecation") @Test(expected = IllegalArgumentException.class) - public void constructorsRejectNullAclAuthzStrategy() throws Exception { + public void constructorsRejectNullAclAuthzStrategy() { try { new AclImpl(objectIdentity, 1, null, new DefaultPermissionGrantingStrategy( mockAuditLogger), null, null, true, new PrincipalSid("joe")); @@ -105,7 +105,7 @@ public class AclImplTests { } @Test - public void insertAceRejectsNullParameters() throws Exception { + public void insertAceRejectsNullParameters() { MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); try { @@ -123,7 +123,7 @@ public class AclImplTests { } @Test - public void insertAceAddsElementAtCorrectIndex() throws Exception { + public void insertAceAddsElementAtCorrectIndex() { MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); MockAclService service = new MockAclService(); @@ -166,7 +166,7 @@ public class AclImplTests { } @Test(expected = NotFoundException.class) - public void insertAceFailsForNonExistentElement() throws Exception { + public void insertAceFailsForNonExistentElement() { MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); MockAclService service = new MockAclService(); @@ -180,7 +180,7 @@ public class AclImplTests { } @Test - public void deleteAceKeepsInitialOrdering() throws Exception { + public void deleteAceKeepsInitialOrdering() { MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); MockAclService service = new MockAclService(); @@ -217,7 +217,7 @@ public class AclImplTests { } @Test - public void deleteAceFailsForNonExistentElement() throws Exception { + public void deleteAceFailsForNonExistentElement() { AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl( new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority( "ROLE_AUDITING"), new SimpleGrantedAuthority("ROLE_GENERAL")); @@ -232,7 +232,7 @@ public class AclImplTests { } @Test - public void isGrantingRejectsEmptyParameters() throws Exception { + public void isGrantingRejectsEmptyParameters() { MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); Sid ben = new PrincipalSid("ben"); @@ -251,7 +251,7 @@ public class AclImplTests { } @Test - public void isGrantingGrantsAccessForAclWithNoParent() throws Exception { + public void isGrantingGrantsAccessForAclWithNoParent() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL", "ROLE_GUEST"); auth.setAuthenticated(true); @@ -297,7 +297,7 @@ public class AclImplTests { } @Test - public void isGrantingGrantsAccessForInheritableAcls() throws Exception { + public void isGrantingGrantsAccessForInheritableAcls() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL"); auth.setAuthenticated(true); @@ -379,7 +379,7 @@ public class AclImplTests { } @Test - public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception { + public void updatedAceValuesAreCorrectlyReflectedInAcl() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL"); auth.setAuthenticated(true); @@ -411,7 +411,7 @@ public class AclImplTests { } @Test - public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception { + public void auditableEntryFlagsAreUpdatedCorrectly() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_AUDITING", "ROLE_GENERAL"); auth.setAuthenticated(true); @@ -449,7 +449,7 @@ public class AclImplTests { } @Test - public void gettersAndSettersAreConsistent() throws Exception { + public void gettersAndSettersAreConsistent() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL"); auth.setAuthenticated(true); @@ -485,7 +485,7 @@ public class AclImplTests { } @Test - public void isSidLoadedBehavesAsExpected() throws Exception { + public void isSidLoadedBehavesAsExpected() { List loadedSids = Arrays.asList(new PrincipalSid("ben"), new GrantedAuthoritySid("ROLE_IGNORED")); MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, @@ -513,22 +513,21 @@ public class AclImplTests { } @Test(expected = NotFoundException.class) - public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { + public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() { AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true); } @Test(expected = NotFoundException.class) - public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { + public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() { AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); acl.deleteAce(-1); } @Test(expected = NotFoundException.class) - public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() - throws Exception { + public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() { AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); // Insert at zero, OK. @@ -539,7 +538,7 @@ public class AclImplTests { // SEC-1151 @Test(expected = NotFoundException.class) - public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception { + public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() { AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe")); acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); @@ -549,7 +548,7 @@ public class AclImplTests { // SEC-1795 @Test - public void changingParentIsSuccessful() throws Exception { + public void changingParentIsSuccessful() { AclImpl parentAcl = new AclImpl(objectIdentity, 1L, authzStrategy, mockAuditLogger); AclImpl childAcl = new AclImpl(objectIdentity, 2L, authzStrategy, mockAuditLogger); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java index b482de6abc..0eab9940ac 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java @@ -41,17 +41,17 @@ public class AclImplementationSecurityCheckTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { SecurityContextHolder.clearContext(); } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @Test - public void testSecurityCheckNoACEs() throws Exception { + public void testSecurityCheckNoACEs() { Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL", "ROLE_AUDITING", "ROLE_OWNERSHIP"); auth.setAuthenticated(true); @@ -103,7 +103,7 @@ public class AclImplementationSecurityCheckTests { } @Test - public void testSecurityCheckWithMultipleACEs() throws Exception { + public void testSecurityCheckWithMultipleACEs() { // Create a simple authentication with ROLE_GENERAL Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL"); @@ -206,7 +206,7 @@ public class AclImplementationSecurityCheckTests { } @Test - public void testSecurityCheckWithInheritableACEs() throws Exception { + public void testSecurityCheckWithInheritableACEs() { // Create a simple authentication with ROLE_GENERAL Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL"); @@ -273,7 +273,7 @@ public class AclImplementationSecurityCheckTests { } @Test - public void testSecurityCheckPrincipalOwner() throws Exception { + public void testSecurityCheckPrincipalOwner() { Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_ONE"); auth.setAuthenticated(true); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java index ace6007935..001e0450e3 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java @@ -44,7 +44,7 @@ public class AuditLoggerTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { logger = new ConsoleAuditLogger(); ace = mock(AuditableAccessControlEntry.class); console = System.out; @@ -52,7 +52,7 @@ public class AuditLoggerTests { } @After - public void tearDown() throws Exception { + public void tearDown() { System.setOut(console); bytes.reset(); } @@ -65,14 +65,14 @@ public class AuditLoggerTests { } @Test - public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception { + public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() { when(ace.isAuditSuccess()).thenReturn(false); logger.logIfNeeded(true, ace); assertThat(bytes.size()).isZero(); } @Test - public void successIsLoggedIfAceRequiresSuccessAudit() throws Exception { + public void successIsLoggedIfAceRequiresSuccessAudit() { when(ace.isAuditSuccess()).thenReturn(true); logger.logIfNeeded(true, ace); @@ -80,14 +80,14 @@ public class AuditLoggerTests { } @Test - public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception { + public void failureIsntLoggedIfAceDoesntRequireFailureAudit() { when(ace.isAuditFailure()).thenReturn(false); logger.logIfNeeded(false, ace); assertThat(bytes.size()).isZero(); } @Test - public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception { + public void failureIsLoggedIfAceRequiresFailureAudit() { when(ace.isAuditFailure()).thenReturn(true); logger.logIfNeeded(false, ace); assertThat(bytes.toString()).startsWith("DENIED due to ACE"); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java index f87207963f..93adac3837 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java @@ -36,7 +36,7 @@ public class ObjectIdentityImplTests { // ======================================================================================================== @Test - public void constructorsRespectRequiredFields() throws Exception { + public void constructorsRespectRequiredFields() { // Check one-argument constructor required field try { new ObjectIdentityImpl(null); @@ -79,14 +79,14 @@ public class ObjectIdentityImplTests { } @Test - public void gettersReturnExpectedValues() throws Exception { + public void gettersReturnExpectedValues() { ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L); assertThat(obj.getIdentifier()).isEqualTo(1L); assertThat(obj.getType()).isEqualTo(MockIdDomainObject.class.getName()); } @Test - public void testGetIdMethodConstraints() throws Exception { + public void testGetIdMethodConstraints() { // Check the getId() method is present try { new ObjectIdentityImpl("A_STRING_OBJECT"); @@ -125,12 +125,12 @@ public class ObjectIdentityImplTests { } @Test(expected = IllegalArgumentException.class) - public void constructorRejectsInvalidTypeParameter() throws Exception { + public void constructorRejectsInvalidTypeParameter() { new ObjectIdentityImpl("", 1L); } @Test - public void testEquals() throws Exception { + public void testEquals() { ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L); MockIdDomainObject mockObj = new MockIdDomainObject(); mockObj.setId(1L); @@ -148,7 +148,7 @@ public class ObjectIdentityImplTests { } @Test - public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception { + public void hashcodeIsDifferentForDifferentJavaTypes() { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, 1L); ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, 1L); assertThat(obj.hashCode()).isNotEqualTo(obj2.hashCode()); @@ -164,7 +164,7 @@ public class ObjectIdentityImplTests { } @Test - public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception { + public void equalStringIdsAreEqualAndHaveSameHashcode() { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000"); assertThat(obj2).isEqualTo(obj); @@ -172,7 +172,7 @@ public class ObjectIdentityImplTests { } @Test - public void stringAndNumericIdsAreNotEqual() throws Exception { + public void stringAndNumericIdsAreNotEqual() { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, 1000L); assertThat(obj).isNotEqualTo(obj2); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java index 16e6bb3238..67e068c947 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java @@ -31,7 +31,7 @@ public class ObjectIdentityRetrievalStrategyImplTests { // ~ Methods // ======================================================================================================== @Test - public void testObjectIdentityCreation() throws Exception { + public void testObjectIdentityCreation() { MockIdDomainObject domain = new MockIdDomainObject(); domain.setId(1); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/AbstractBasicLookupStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/AbstractBasicLookupStrategyTests.java index 62f92428ae..a2cefecab5 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/AbstractBasicLookupStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/AbstractBasicLookupStrategyTests.java @@ -171,7 +171,7 @@ public abstract class AbstractBasicLookupStrategyTests { } private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid, - Map map) throws Exception { + Map map) { assertThat(map).hasSize(3); MutableAcl topParent = (MutableAcl) map.get(topParentOid); @@ -238,7 +238,7 @@ public abstract class AbstractBasicLookupStrategyTests { } @Test - public void testAllParentsAreRetrievedWhenChildIsLoaded() throws Exception { + public void testAllParentsAreRetrievedWhenChildIsLoaded() { String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,103,1,1,1);"; getJdbcTemplate().execute(query); @@ -266,7 +266,7 @@ public abstract class AbstractBasicLookupStrategyTests { * Test created from SEC-590. */ @Test - public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() throws Exception { + public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() { String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,105,null,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,106,6,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (8,2,107,6,1,1);" diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/AclClassIdUtilsTest.java b/acl/src/test/java/org/springframework/security/acls/jdbc/AclClassIdUtilsTest.java index 26b2b9bf98..65e7fd83fc 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/AclClassIdUtilsTest.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/AclClassIdUtilsTest.java @@ -151,13 +151,13 @@ public class AclClassIdUtilsTest { } @Test(expected = IllegalArgumentException.class) - public void shouldNotAcceptNullConversionServiceInConstruction() throws SQLException { + public void shouldNotAcceptNullConversionServiceInConstruction() { // when new AclClassIdUtils(null); } @Test(expected = IllegalArgumentException.class) - public void shouldNotAcceptNullConversionServiceInSetter() throws SQLException { + public void shouldNotAcceptNullConversionServiceInSetter() { // when aclClassIdUtils.setConversionService(null); } diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java index 700075df00..4f5f7c13a7 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java @@ -37,7 +37,7 @@ public class BasicLookupStrategyTests extends AbstractBasicLookupStrategyTests { } @AfterClass - public static void dropDatabase() throws Exception { + public static void dropDatabase() { DATABASE_HELPER.getDataSource().destroy(); } diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyWithAclClassTypeTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyWithAclClassTypeTests.java index 85617968aa..60ca2508f7 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyWithAclClassTypeTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyWithAclClassTypeTests.java @@ -63,7 +63,7 @@ public class BasicLookupStrategyWithAclClassTypeTests extends AbstractBasicLooku } @AfterClass - public static void dropDatabase() throws Exception { + public static void dropDatabase() { DATABASE_HELPER.getDataSource().destroy(); } diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java index b73944154f..1e90a4ddc0 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java @@ -86,14 +86,14 @@ public class EhCacheBasedAclCacheTests { } @Test(expected = IllegalArgumentException.class) - public void constructorRejectsNullParameters() throws Exception { + public void constructorRejectsNullParameters() { new EhCacheBasedAclCache(null, new DefaultPermissionGrantingStrategy( new ConsoleAuditLogger()), new AclAuthorizationStrategyImpl( new SimpleGrantedAuthority("ROLE_USER"))); } @Test - public void methodsRejectNullParameters() throws Exception { + public void methodsRejectNullParameters() { try { Serializable id = null; myCache.evictFromCache(id); @@ -162,14 +162,14 @@ public class EhCacheBasedAclCacheTests { } @Test - public void clearCache() throws Exception { + public void clearCache() { myCache.clearCache(); verify(cache).removeAll(); } @Test - public void putInCache() throws Exception { + public void putInCache() { myCache.putInCache(acl); verify(cache, times(2)).put(element.capture()); @@ -181,7 +181,7 @@ public class EhCacheBasedAclCacheTests { } @Test - public void putInCacheAclWithParent() throws Exception { + public void putInCacheAclWithParent() { Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL"); auth.setAuthenticated(true); @@ -216,14 +216,14 @@ public class EhCacheBasedAclCacheTests { } @Test - public void getFromCacheSerializable() throws Exception { + public void getFromCacheSerializable() { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); } @Test - public void getFromCacheSerializablePopulatesTransient() throws Exception { + public void getFromCacheSerializablePopulatesTransient() { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); myCache.putInCache(acl); @@ -240,14 +240,14 @@ public class EhCacheBasedAclCacheTests { } @Test - public void getFromCacheObjectIdentity() throws Exception { + public void getFromCacheObjectIdentity() { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); } @Test - public void getFromCacheObjectIdentityPopulatesTransient() throws Exception { + public void getFromCacheObjectIdentityPopulatesTransient() { when(cache.get(acl.getObjectIdentity())) .thenReturn(new Element(acl.getId(), acl)); @@ -265,7 +265,7 @@ public class EhCacheBasedAclCacheTests { } @Test - public void evictCacheSerializable() throws Exception { + public void evictCacheSerializable() { when(cache.get(acl.getObjectIdentity())) .thenReturn(new Element(acl.getId(), acl)); @@ -276,7 +276,7 @@ public class EhCacheBasedAclCacheTests { } @Test - public void evictCacheObjectIdentity() throws Exception { + public void evictCacheObjectIdentity() { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); myCache.evictFromCache(acl.getId()); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java index 8e6e21cb32..0e54ed8f58 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java @@ -132,7 +132,7 @@ public class JdbcMutableAclServiceTests extends } @AfterTransaction - public void clearContextAndData() throws Exception { + public void clearContextAndData() { SecurityContextHolder.clearContext(); jdbcTemplate.execute("drop table acl_entry"); jdbcTemplate.execute("drop table acl_object_identity"); @@ -285,7 +285,7 @@ public class JdbcMutableAclServiceTests extends */ @Test @Transactional - public void deleteAclAlsoDeletesChildren() throws Exception { + public void deleteAclAlsoDeletesChildren() { SecurityContextHolder.getContext().setAuthentication(auth); jdbcMutableAclService.createAcl(getTopParentOid()); @@ -323,7 +323,7 @@ public class JdbcMutableAclServiceTests extends } @Test - public void constructorRejectsNullParameters() throws Exception { + public void constructorRejectsNullParameters() { try { new JdbcMutableAclService(null, lookupStrategy, aclCache); fail("It should have thrown IllegalArgumentException"); @@ -347,7 +347,7 @@ public class JdbcMutableAclServiceTests extends } @Test - public void createAclRejectsNullParameter() throws Exception { + public void createAclRejectsNullParameter() { try { jdbcMutableAclService.createAcl(null); fail("It should have thrown IllegalArgumentException"); @@ -358,7 +358,7 @@ public class JdbcMutableAclServiceTests extends @Test @Transactional - public void createAclForADuplicateDomainObject() throws Exception { + public void createAclForADuplicateDomainObject() { SecurityContextHolder.getContext().setAuthentication(auth); ObjectIdentity duplicateOid = new ObjectIdentityImpl(TARGET_CLASS, 100L); @@ -374,7 +374,7 @@ public class JdbcMutableAclServiceTests extends @Test @Transactional - public void deleteAclRejectsNullParameters() throws Exception { + public void deleteAclRejectsNullParameters() { try { jdbcMutableAclService.deleteAcl(null, true); fail("It should have thrown IllegalArgumentException"); @@ -385,7 +385,7 @@ public class JdbcMutableAclServiceTests extends @Test @Transactional - public void deleteAclWithChildrenThrowsException() throws Exception { + public void deleteAclWithChildrenThrowsException() { SecurityContextHolder.getContext().setAuthentication(auth); MutableAcl parent = jdbcMutableAclService.createAcl(getTopParentOid()); MutableAcl child = jdbcMutableAclService.createAcl(getMiddleParentOid()); @@ -411,7 +411,7 @@ public class JdbcMutableAclServiceTests extends @Test @Transactional - public void deleteAclRemovesRowsFromDatabase() throws Exception { + public void deleteAclRemovesRowsFromDatabase() { SecurityContextHolder.getContext().setAuthentication(auth); MutableAcl child = jdbcMutableAclService.createAcl(getChildOid()); child.insertAce(0, BasePermission.DELETE, new PrincipalSid(auth), false); @@ -434,7 +434,7 @@ public class JdbcMutableAclServiceTests extends /** SEC-1107 */ @Test @Transactional - public void identityWithIntegerIdIsSupportedByCreateAcl() throws Exception { + public void identityWithIntegerIdIsSupportedByCreateAcl() { SecurityContextHolder.getContext().setAuthentication(auth); ObjectIdentity oid = new ObjectIdentityImpl(TARGET_CLASS, 101); jdbcMutableAclService.createAcl(oid); @@ -448,7 +448,7 @@ public class JdbcMutableAclServiceTests extends */ @Test @Transactional - public void childrenAreClearedFromCacheWhenParentIsUpdated() throws Exception { + public void childrenAreClearedFromCacheWhenParentIsUpdated() { Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_ADMINISTRATOR"); auth.setAuthenticated(true); @@ -486,7 +486,7 @@ public class JdbcMutableAclServiceTests extends */ @Test @Transactional - public void childrenAreClearedFromCacheWhenParentisUpdated2() throws Exception { + public void childrenAreClearedFromCacheWhenParentisUpdated2() { Authentication auth = new TestingAuthenticationToken("system", "secret", "ROLE_IGNORED"); SecurityContextHolder.getContext().setAuthentication(auth); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTestsWithAclClassId.java b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTestsWithAclClassId.java index 2dc716851b..1d45b033aa 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTestsWithAclClassId.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTestsWithAclClassId.java @@ -70,7 +70,7 @@ public class JdbcMutableAclServiceTestsWithAclClassId extends JdbcMutableAclServ @Test @Transactional - public void identityWithUuidIdIsSupportedByCreateAcl() throws Exception { + public void identityWithUuidIdIsSupportedByCreateAcl() { SecurityContextHolder.getContext().setAuthentication(getAuth()); UUID id = UUID.randomUUID(); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java index d1c070db78..4d9de2f556 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java @@ -65,13 +65,13 @@ public class SpringCacheBasedAclCacheTests { } @Test(expected = IllegalArgumentException.class) - public void constructorRejectsNullParameters() throws Exception { + public void constructorRejectsNullParameters() { new SpringCacheBasedAclCache(null, null, null); } @SuppressWarnings("rawtypes") @Test - public void cacheOperationsAclWithoutParent() throws Exception { + public void cacheOperationsAclWithoutParent() { Cache cache = getCache(); Map realCache = (Map) cache.getNativeCache(); ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100L); diff --git a/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java index f8a6d5fd78..ba61b41d01 100644 --- a/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java @@ -46,7 +46,7 @@ public class SidRetrievalStrategyTests { // ======================================================================================================== @Test - public void correctSidsAreRetrieved() throws Exception { + public void correctSidsAreRetrieved() { SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl(); List sids = retrStrategy.getSids(authentication); @@ -66,7 +66,7 @@ public class SidRetrievalStrategyTests { } @Test - public void roleHierarchyIsUsedWhenSet() throws Exception { + public void roleHierarchyIsUsedWhenSet() { RoleHierarchy rh = mock(RoleHierarchy.class); List rhAuthorities = AuthorityUtils.createAuthorityList("D"); when(rh.getReachableGrantedAuthorities(anyCollection())) diff --git a/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java b/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java index 7788c04b4f..0bd147ce41 100644 --- a/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java +++ b/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java @@ -32,7 +32,7 @@ public class SidTests { // ~ Methods // ======================================================================================================== @Test - public void testPrincipalSidConstructorsRequiredFields() throws Exception { + public void testPrincipalSidConstructorsRequiredFields() { // Check one String-argument constructor try { String string = null; @@ -77,7 +77,7 @@ public class SidTests { } @Test - public void testGrantedAuthoritySidConstructorsRequiredFields() throws Exception { + public void testGrantedAuthoritySidConstructorsRequiredFields() { // Check one String-argument constructor try { String string = null; @@ -134,7 +134,7 @@ public class SidTests { } @Test - public void testPrincipalSidEquals() throws Exception { + public void testPrincipalSidEquals() { Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); Sid principalSid = new PrincipalSid(authentication); @@ -152,7 +152,7 @@ public class SidTests { } @Test - public void testGrantedAuthoritySidEquals() throws Exception { + public void testGrantedAuthoritySidEquals() { GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); Sid gaSid = new GrantedAuthoritySid(ga); @@ -169,7 +169,7 @@ public class SidTests { } @Test - public void testPrincipalSidHashCode() throws Exception { + public void testPrincipalSidHashCode() { Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); Sid principalSid = new PrincipalSid(authentication); @@ -184,7 +184,7 @@ public class SidTests { } @Test - public void testGrantedAuthoritySidHashCode() throws Exception { + public void testGrantedAuthoritySidHashCode() { GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); Sid gaSid = new GrantedAuthoritySid(ga); @@ -198,7 +198,7 @@ public class SidTests { } @Test - public void testGetters() throws Exception { + public void testGetters() { Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); PrincipalSid principalSid = new PrincipalSid(authentication); diff --git a/aspects/src/main/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspect.aj b/aspects/src/main/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspect.aj index 3459f96f55..cdbbdad0a1 100644 --- a/aspects/src/main/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspect.aj +++ b/aspects/src/main/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspect.aj @@ -81,7 +81,7 @@ public aspect AnnotationSecurityAspect implements InitializingBean { this.securityInterceptor = securityInterceptor; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { if (this.securityInterceptor == null) { throw new IllegalArgumentException("securityInterceptor required"); } diff --git a/aspects/src/test/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspectTests.java b/aspects/src/test/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspectTests.java index 3e087a1db9..f0d7570722 100644 --- a/aspects/src/test/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspectTests.java +++ b/aspects/src/test/java/org/springframework/security/access/intercept/aspectj/aspect/AnnotationSecurityAspectTests.java @@ -67,7 +67,7 @@ public class AnnotationSecurityAspectTests { private PrePostSecured prePostSecured = new PrePostSecured(); @Before - public final void setUp() throws Exception { + public final void setUp() { MockitoAnnotations.initMocks(this); interceptor = new AspectJMethodSecurityInterceptor(); AccessDecisionVoter[] voters = new AccessDecisionVoter[] { @@ -90,17 +90,17 @@ public class AnnotationSecurityAspectTests { } @Test - public void securedInterfaceMethodAllowsAllAccess() throws Exception { + public void securedInterfaceMethodAllowsAllAccess() { secured.securedMethod(); } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void securedClassMethodDeniesUnauthenticatedAccess() throws Exception { + public void securedClassMethodDeniesUnauthenticatedAccess() { secured.securedClassMethod(); } @Test - public void securedClassMethodAllowsAccessToRoleA() throws Exception { + public void securedClassMethodAllowsAccessToRoleA() { SecurityContextHolder.getContext().setAuthentication(anne); secured.securedClassMethod(); } @@ -119,28 +119,28 @@ public class AnnotationSecurityAspectTests { } @Test(expected = AccessDeniedException.class) - public void protectedMethodIsIntercepted() throws Exception { + public void protectedMethodIsIntercepted() { SecurityContextHolder.getContext().setAuthentication(anne); secured.protectedMethod(); } @Test - public void overriddenProtectedMethodIsNotIntercepted() throws Exception { + public void overriddenProtectedMethodIsNotIntercepted() { // AspectJ doesn't inherit annotations securedSub.protectedMethod(); } // SEC-1262 @Test(expected = AccessDeniedException.class) - public void denyAllPreAuthorizeDeniesAccess() throws Exception { + public void denyAllPreAuthorizeDeniesAccess() { configureForElAnnotations(); SecurityContextHolder.getContext().setAuthentication(anne); prePostSecured.denyAllMethod(); } @Test - public void postFilterIsApplied() throws Exception { + public void postFilterIsApplied() { configureForElAnnotations(); SecurityContextHolder.getContext().setAuthentication(anne); List objects = prePostSecured.postFilterMethod(); diff --git a/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java b/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java index 6b07ce8503..e63742222c 100644 --- a/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java +++ b/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java @@ -50,7 +50,7 @@ public class ServiceProperties implements InitializingBean { // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasLength(this.service, "service cannot be empty."); Assert.hasLength(this.artifactParameter, "artifactParameter cannot be empty."); Assert.hasLength(this.serviceParameter, "serviceParameter cannot be empty."); diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java index f9182bc988..226a786d6b 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java @@ -77,7 +77,7 @@ public class CasAuthenticationProvider implements AuthenticationProvider, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.authenticationUserDetailsService, "An authenticationUserDetailsService must be set"); Assert.notNull(this.ticketValidator, "A ticketValidator must be set"); diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java index a530a88e2d..e424d512de 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java @@ -44,7 +44,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(cache, "cache mandatory"); } diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java index da6f84dcc3..171792448d 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java @@ -42,7 +42,7 @@ public class SpringCacheBasedTicketCache implements StatelessTicketCache { // ~ Constructors // =================================================================================================== - public SpringCacheBasedTicketCache(Cache cache) throws Exception { + public SpringCacheBasedTicketCache(Cache cache) { Assert.notNull(cache, "cache mandatory"); this.cache = cache; } diff --git a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java index 1dfb965d26..617a7be69d 100644 --- a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java +++ b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java @@ -65,7 +65,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasLength(this.loginUrl, "loginUrl must be specified"); Assert.notNull(this.serviceProperties, "serviceProperties must be specified"); Assert.notNull(this.serviceProperties.getService(), @@ -74,8 +74,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse response, - final AuthenticationException authenticationException) throws IOException, - ServletException { + final AuthenticationException authenticationException) throws IOException { final String urlEncodedService = createServiceUrl(servletRequest, response); final String redirectUrl = createRedirectUrl(urlEncodedService); diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java index 230a29c031..01fff900a4 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java @@ -418,8 +418,7 @@ public class CasAuthenticationProviderTests { this.returnTicket = returnTicket; } - public Assertion validate(final String ticket, final String service) - throws TicketValidationException { + public Assertion validate(final String ticket, final String service) { if (returnTicket) { return new AssertionImpl("rod"); } diff --git a/cas/src/test/java/org/springframework/security/cas/jackson2/CasAuthenticationTokenMixinTests.java b/cas/src/test/java/org/springframework/security/cas/jackson2/CasAuthenticationTokenMixinTests.java index fccca6eb8f..933be2cf14 100644 --- a/cas/src/test/java/org/springframework/security/cas/jackson2/CasAuthenticationTokenMixinTests.java +++ b/cas/src/test/java/org/springframework/security/cas/jackson2/CasAuthenticationTokenMixinTests.java @@ -128,7 +128,7 @@ public class CasAuthenticationTokenMixinTests { } @Test - public void deserializeCasAuthenticationTest() throws IOException, JSONException { + public void deserializeCasAuthenticationTest() throws IOException { CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_JSON, CasAuthenticationToken.class); assertThat(token).isNotNull(); assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class); diff --git a/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java index 6fa37740cb..caff4c8757 100644 --- a/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java +++ b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java @@ -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(""); } @Test - public void userServiceReturnsExpectedData() throws Exception { + public void userServiceReturnsExpectedData() { setContext(""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); @@ -86,7 +86,7 @@ public class LdapUserServiceBeanDefinitionParserTests { } @Test - public void differentUserSearchBaseWorksAsExpected() throws Exception { + public void differentUserSearchBaseWorksAsExpected() { setContext("" @@ -117,7 +117,7 @@ public class LdapUserServiceBeanDefinitionParserTests { } @Test - public void differentGroupRoleAttributeWorksAsExpected() throws Exception { + public void differentGroupRoleAttributeWorksAsExpected() { setContext(""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); diff --git a/config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java b/config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java index 2e0567a817..7cd1ffd22b 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java +++ b/config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java @@ -183,10 +183,9 @@ public abstract class AbstractConfiguredSecurityBuilder> void add(C configurer) throws Exception { + private > void add(C configurer) { Assert.notNull(configurer, "configurer cannot be null"); Class> clazz = (Class>) configurer @@ -344,7 +343,7 @@ public abstract class AbstractConfiguredSecurityBuilder configurers) throws Exception { + List configurers) { configurers.sort(AnnotationAwareOrderComparator.INSTANCE); this.globalAuthConfigurers = configurers; } diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java index c24aa3ea24..62fb6e9b48 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java @@ -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; } diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java index e1af639341..035bd7877f 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/JdbcUserDetailsManagerConfigurer.java @@ -64,10 +64,8 @@ public class JdbcUserDetailsManagerConfigurer dataSource(DataSource dataSource) - throws Exception { + public JdbcUserDetailsManagerConfigurer dataSource(DataSource dataSource) { this.dataSource = dataSource; getUserDetailsService().setDataSource(dataSource); return this; @@ -83,10 +81,8 @@ public class JdbcUserDetailsManagerConfigurer usersByUsernameQuery(String query) - throws Exception { + public JdbcUserDetailsManagerConfigurer usersByUsernameQuery(String query) { getUserDetailsService().setUsersByUsernameQuery(query); return this; } @@ -103,10 +99,8 @@ public class JdbcUserDetailsManagerConfigurer authoritiesByUsernameQuery(String query) - throws Exception { + public JdbcUserDetailsManagerConfigurer authoritiesByUsernameQuery(String query) { getUserDetailsService().setAuthoritiesByUsernameQuery(query); return this; } @@ -127,10 +121,8 @@ public class JdbcUserDetailsManagerConfigurer groupAuthoritiesByUsername(String query) - throws Exception { + public JdbcUserDetailsManagerConfigurer groupAuthoritiesByUsername(String query) { JdbcUserDetailsManager userDetailsService = getUserDetailsService(); userDetailsService.setEnableGroups(true); userDetailsService.setGroupAuthoritiesByUsernameQuery(query); @@ -143,10 +135,8 @@ public class JdbcUserDetailsManagerConfigurer rolePrefix(String rolePrefix) - throws Exception { + public JdbcUserDetailsManagerConfigurer rolePrefix(String rolePrefix) { getUserDetailsService().setRolePrefix(rolePrefix); return this; } @@ -156,10 +146,8 @@ public class JdbcUserDetailsManagerConfigurer userCache(UserCache userCache) - throws Exception { + public JdbcUserDetailsManagerConfigurer userCache(UserCache userCache) { getUserDetailsService().setUserCache(userCache); return this; } diff --git a/config/src/main/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessor.java b/config/src/main/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessor.java index a4c193b4a5..813e05684c 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessor.java +++ b/config/src/main/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessor.java @@ -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(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/method/configuration/ReactiveMethodSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/method/configuration/ReactiveMethodSecurityConfiguration.java index 8b4895bb60..8c95784c98 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/method/configuration/ReactiveMethodSecurityConfiguration.java +++ b/config/src/main/java/org/springframework/security/config/annotation/method/configuration/ReactiveMethodSecurityConfiguration.java @@ -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); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java b/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java index 8cf1552664..52946e015a 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java @@ -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 requestMatcherCustomizer) throws Exception { + public HttpSecurity requestMatchers(Customizer requestMatcherCustomizer) { requestMatcherCustomizer.customize(requestMatcherConfigurer); return HttpSecurity.this; } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java index fda96fa934..4d64b7c4c3 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java @@ -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(); } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.java b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.java index 46e5fce86f..5c5976f746 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.java @@ -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) { } /** diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java index f22aacae2b..d597618b0e 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java @@ -145,7 +145,7 @@ public final class AnonymousConfigurer> 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> extends } @Override - public void configure(H http) throws Exception { + public void configure(H http) { authenticationFilter.afterPropertiesSet(); http.addFilter(authenticationFilter); } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java index ca0937f8dd..1d3b99b5ef 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java @@ -98,7 +98,7 @@ public final class ChannelSecurityConfigurer> 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); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurer.java index 31436cf42d..449061d49f 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurer.java @@ -60,7 +60,7 @@ public class CorsConfigurer> } @Override - public void configure(H http) throws Exception { + public void configure(H http) { ApplicationContext context = http.getSharedObject(ApplicationContext.class); CorsFilter corsFilter = getCorsFilter(context); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java index 8725936f5e..33b34bcef5 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java @@ -203,7 +203,7 @@ public final class CsrfConfigurer> @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) { diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java index 8cf04d71ac..251c586f3e 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java @@ -73,7 +73,7 @@ public final class DefaultLoginPageConfigurer> private DefaultLogoutPageGeneratingFilter logoutPageGeneratingFilter = new DefaultLogoutPageGeneratingFilter(); @Override - public void init(H http) throws Exception { + public void init(H http) { Function> hiddenInputs = request -> { CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (token == null) { @@ -89,7 +89,7 @@ public final class DefaultLoginPageConfigurer> @Override @SuppressWarnings("unchecked") - public void configure(H http) throws Exception { + public void configure(H http) { AuthenticationEntryPoint authenticationEntryPoint = null; ExceptionHandlingConfigurer exceptionConf = http .getConfigurer(ExceptionHandlingConfigurer.class); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java index 82c17843ea..72d0359714 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java @@ -188,7 +188,7 @@ public final class ExceptionHandlingConfigurer> } @Override - public void configure(H http) throws Exception { + public void configure(H http) { AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http); ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter( entryPoint, getRequestCache(http)); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java index b53a7961f6..adcffa0648 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java @@ -899,7 +899,7 @@ public class HeadersConfigurer> extends } @Override - public void configure(H http) throws Exception { + public void configure(H http) { HeaderWriterFilter headersFilter = createHeaderWriterFilter(); http.addFilter(headersFilter); } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java index b81344c213..e4defae601 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java @@ -91,10 +91,9 @@ public final class HttpBasicConfigurer> extends /** * Creates a new instance - * @throws Exception * @see HttpSecurity#httpBasic() */ - public HttpBasicConfigurer() throws Exception { + public HttpBasicConfigurer() { realmName(DEFAULT_REALM); LinkedHashMap entryPoints = new LinkedHashMap<>(); @@ -150,7 +149,7 @@ public final class HttpBasicConfigurer> extends } @Override - public void init(B http) throws Exception { + public void init(B http) { registerDefaults(http); } @@ -204,7 +203,7 @@ public final class HttpBasicConfigurer> extends } @Override - public void configure(B http) throws Exception { + public void configure(B http) { AuthenticationManager authenticationManager = http .getSharedObject(AuthenticationManager.class); BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter( diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java index ff247b304a..45abc6b156 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java @@ -192,7 +192,7 @@ public final class JeeConfigurer> 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> extends } @Override - public void configure(H http) throws Exception { + public void configure(H http) { J2eePreAuthenticatedProcessingFilter filter = getFilter(http .getSharedObject(AuthenticationManager.class)); http.addFilter(filter); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java index d919bfd71d..53b69c18e8 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java @@ -270,7 +270,7 @@ public final class LogoutConfigurer> 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> 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]); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java index aa5edd8510..74f77c1b57 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java @@ -62,7 +62,7 @@ public final class PortMapperConfigurer> extend } @Override - public void init(H http) throws Exception { + public void init(H http) { http.setSharedObject(PortMapper.class, getPortMapper()); } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java index a7cd270a18..9722432a68 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java @@ -282,7 +282,7 @@ public final class RememberMeConfigurer> } @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> * @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> } return this.key; } -} \ No newline at end of file +} diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java index 3a21c2d927..0e5322634a 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java @@ -95,12 +95,12 @@ public final class RequestCacheConfigurer> 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); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java index cad63f7784..c514989fe9 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java @@ -82,7 +82,7 @@ public final class SecurityContextConfigurer> e @Override @SuppressWarnings("unchecked") - public void configure(H http) throws Exception { + public void configure(H http) { SecurityContextRepository securityContextRepository = http .getSharedObject(SecurityContextRepository.class); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java index 606be5737d..73dccbfea2 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java @@ -75,7 +75,7 @@ public final class ServletApiConfigurer> extend @Override @SuppressWarnings("unchecked") - public void configure(H http) throws Exception { + public void configure(H http) { securityContextRequestFilter.setAuthenticationManager(http .getSharedObject(AuthenticationManager.class)); ExceptionHandlingConfigurer exceptionConf = http diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java index fd4cf8db40..75062bfee8 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java @@ -441,7 +441,7 @@ public final class SessionManagementConfigurer> } @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> } @Override - public void configure(H http) throws Exception { + public void configure(H http) { SecurityContextRepository securityContextRepository = http .getSharedObject(SecurityContextRepository.class); SessionManagementFilter sessionManagementFilter = new SessionManagementFilter( diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java index 63839b4cd7..7b35c367ad 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java @@ -171,7 +171,7 @@ public final class X509Configurer> 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> 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); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/ImplicitGrantConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/ImplicitGrantConfigurer.java index a86b3f6931..55a83e9335 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/ImplicitGrantConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/ImplicitGrantConfigurer.java @@ -83,7 +83,7 @@ public final class ImplicitGrantConfigurer> 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)); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java index 066ca0c692..b5c0db06bf 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java @@ -142,10 +142,8 @@ public final class OAuth2ClientConfigurer> 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 authorizationCodeGrant(Customizer authorizationCodeGrantCustomizer) - throws Exception { + public OAuth2ClientConfigurer authorizationCodeGrant(Customizer authorizationCodeGrantCustomizer) { authorizationCodeGrantCustomizer.customize(this.authorizationCodeGrantConfigurer); return this; } @@ -270,12 +268,12 @@ public final class OAuth2ClientConfigurer> 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); } } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java index 28e59020dc..2f24001ee9 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java @@ -221,14 +221,14 @@ public final class OAuth2ResourceServerConfigurer getObject() throws Exception { + public Collection getObject() { Collection users = new ArrayList<>(this.userProperties.size()); UserAttributeEditor editor = new UserAttributeEditor(); diff --git a/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java b/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java index b9b13cc0c8..212e2ad6b6 100644 --- a/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java +++ b/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java @@ -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);"); diff --git a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java index 9fa0fbb30c..42a6eba6d5 100644 --- a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java @@ -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 filters = filterChainProxy.getFilters("/foo/blah;x=1"); assertThat(filters).hasSize(1); assertThat(filters.get(0) instanceof SecurityContextHolderAwareRequestFilter).isTrue(); diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java index 681135c168..a2d17aa5dc 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java @@ -72,7 +72,7 @@ public class SecurityNamespaceHandlerTests { } @Test - public void pre32SchemaAreNotSupported() throws Exception { + public void pre32SchemaAreNotSupported() { try { new InMemoryXmlApplicationContext( "" diff --git a/config/src/test/java/org/springframework/security/config/annotation/ConcereteSecurityConfigurerAdapter.java b/config/src/test/java/org/springframework/security/config/annotation/ConcereteSecurityConfigurerAdapter.java index 67f19e916b..78c12afeea 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/ConcereteSecurityConfigurerAdapter.java +++ b/config/src/test/java/org/springframework/security/config/annotation/ConcereteSecurityConfigurerAdapter.java @@ -27,7 +27,7 @@ class ConcereteSecurityConfigurerAdapter extends private List list = new ArrayList<>(); @Override - public void configure(SecurityBuilder builder) throws Exception { + public void configure(SecurityBuilder builder) { list = postProcess(list); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/authentication/NamespaceAuthenticationProviderTests.java b/config/src/test/java/org/springframework/security/config/annotation/authentication/NamespaceAuthenticationProviderTests.java index d528482349..b26b9fc2c6 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/authentication/NamespaceAuthenticationProviderTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/authentication/NamespaceAuthenticationProviderTests.java @@ -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()); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/authentication/PasswordEncoderConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/authentication/PasswordEncoderConfigurerTests.java index 8c4dec6327..e145d411c5 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/authentication/PasswordEncoderConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/authentication/PasswordEncoderConfigurerTests.java @@ -60,7 +60,7 @@ public class PasswordEncoderConfigurerTests { // @formatter:on @Override - protected void configure(HttpSecurity http) throws Exception { + protected void configure(HttpSecurity http) { } @Bean diff --git a/config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java index b52fdf51f7..3ba459170f 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfigurationTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessorTests.java b/config/src/test/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessorTests.java index f4b1d734df..9f51ff9038 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessorTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/configuration/AutowireBeanFactoryObjectPostProcessorTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/annotation/issue50/SecurityConfig.java b/config/src/test/java/org/springframework/security/config/annotation/issue50/SecurityConfig.java index bea070fcc6..434cc6b790 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/issue50/SecurityConfig.java +++ b/config/src/test/java/org/springframework/security/config/annotation/issue50/SecurityConfig.java @@ -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()); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfigurationTests.java index a8be287c18..221a63d24c 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfigurationTests.java @@ -251,7 +251,7 @@ public class GlobalMethodSecurityConfigurationTests { } @Test - public void multiPermissionEvaluatorConfig() throws Exception { + public void multiPermissionEvaluatorConfig() { this.spring.register(MultiPermissionEvaluatorConfig.class).autowire(); // no exception diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/AbstractConfiguredSecurityBuilderTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/AbstractConfiguredSecurityBuilderTests.java index 50f918e8e5..4f6fa4a613 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/AbstractConfiguredSecurityBuilderTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/AbstractConfiguredSecurityBuilderTests.java @@ -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"; } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/HttpSecurityHeadersTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/HttpSecurityHeadersTests.java index 142d5ed669..9a7a66ec64 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/HttpSecurityHeadersTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/HttpSecurityHeadersTests.java @@ -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) { } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java index 173baef162..b8304f9e13 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java @@ -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/**"); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java index 4242ff2bbc..9343497e7d 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java @@ -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; } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java index c6b0ae7c1f..d5bd274086 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java @@ -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(), diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/builders/HttpConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/builders/HttpConfigurationTests.java index 247376e43b..dbeda6bdd2 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/builders/HttpConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/builders/HttpConfigurationTests.java @@ -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); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java index f3bca1d8df..d219a50dbe 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/builders/WebSecurityTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/builders/WebSecurityTests.java index 3199197be5..60552a0e45 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/builders/WebSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/builders/WebSecurityTests.java @@ -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() diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/EnableWebSecurityTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/EnableWebSecurityTests.java index ddd7d49628..ce6e8d29c8 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/EnableWebSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/EnableWebSecurityTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java index 91340300e7..8c42b037d7 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java @@ -133,7 +133,7 @@ public class OAuth2ClientConfigurationTests { static OAuth2AccessTokenResponseClient ACCESS_TOKEN_RESPONSE_CLIENT; @Override - protected void configure(HttpSecurity http) throws Exception { + protected void configure(HttpSecurity http) { } @RestController diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/Sec2515Tests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/Sec2515Tests.java index 9dfb42c245..845488117c 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/Sec2515Tests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/Sec2515Tests.java @@ -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(); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurationTests.java index 3c4a497e54..230d3839d9 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurationTests.java @@ -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"); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerNoWebMvcTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerNoWebMvcTests.java index 9368c5664b..61df857d62 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerNoWebMvcTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerNoWebMvcTests.java @@ -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) { } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.java index 4880b178cf..7165b06422 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.java @@ -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) { } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java index f7b9c1635e..991e598581 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java @@ -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() diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpCustomFilterTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpCustomFilterTests.java index ee6f7f06ed..b4d07cc1ab 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpCustomFilterTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpCustomFilterTests.java @@ -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(); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFirewallTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFirewallTests.java index 5be01cee2f..63876be7f9 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFirewallTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFirewallTests.java @@ -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()); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFormLoginTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFormLoginTests.java index 81fa1e4b07..f33623f1ce 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFormLoginTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpFormLoginTests.java @@ -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/**"); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpLogoutTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpLogoutTests.java index a1ad03748d..f0edd6301c 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpLogoutTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpLogoutTests.java @@ -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) { } } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java index 0722da31b2..1323ce442d 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java @@ -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))); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurerTests.java index b390d00493..6f2c160b13 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurerTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTests.java index 5eaa4d78a7..a5e2cdf160 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTransientAuthenticationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTransientAuthenticationTests.java index 4112e62efd..184943bec6 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTransientAuthenticationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerTransientAuthenticationTests.java @@ -76,7 +76,7 @@ public class SessionManagementConfigurerTransientAuthenticationTests { } @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { + protected void configure(AuthenticationManagerBuilder auth) { auth .authenticationProvider(new TransientAuthenticationProvider()); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java index aee7f9cf80..c2252b4579 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java @@ -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); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurerTests.java index b1b0617eef..2b4887acd6 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurerTests.java @@ -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(""); } } diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java index cdccfdeb8c..6d64ca25eb 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java @@ -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("") .getContext(); ProviderManager pm = (ProviderManager) appContext diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java index 46f3334227..968f1f9ae1 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java @@ -57,7 +57,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { } @Test - public void externalUserServiceRefWorks() throws Exception { + public void externalUserServiceRefWorks() { appContext = new InMemoryXmlApplicationContext( " " + " " @@ -69,7 +69,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { } @Test - public void providerWithBCryptPasswordEncoderWorks() throws Exception { + public void providerWithBCryptPasswordEncoderWorks() { setContext(" " + " " + " " @@ -80,7 +80,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { } @Test - public void providerWithMd5PasswordEncoderWorks() throws Exception { + public void providerWithMd5PasswordEncoderWorks() { appContext = new InMemoryXmlApplicationContext( " " + " " @@ -99,7 +99,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { } @Test - public void providerWithShaPasswordEncoderWorks() throws Exception { + public void providerWithShaPasswordEncoderWorks() { appContext = new InMemoryXmlApplicationContext( " " + " " @@ -116,7 +116,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { } @Test - public void passwordIsBase64EncodedWhenBase64IsEnabled() throws Exception { + public void passwordIsBase64EncodedWhenBase64IsEnabled() { appContext = new InMemoryXmlApplicationContext( " " + " " @@ -137,7 +137,7 @@ public class AuthenticationProviderBeanDefinitionParserTests { // SEC-1466 @Test(expected = BeanDefinitionParsingException.class) - public void exernalProviderDoesNotSupportChildElements() throws Exception { + public void exernalProviderDoesNotSupportChildElements() { appContext = new InMemoryXmlApplicationContext( " " + " " diff --git a/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java index f78c41665f..14b833cd24 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java @@ -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))); diff --git a/config/src/test/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBeanTest.java b/config/src/test/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBeanTest.java index ed8c97e21c..8b53fc0e34 100644 --- a/config/src/test/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBeanTest.java +++ b/config/src/test/java/org/springframework/security/config/core/userdetails/UserDetailsResourceFactoryBeanTest.java @@ -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() ) diff --git a/config/src/test/java/org/springframework/security/config/http/CsrfBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/http/CsrfBeanDefinitionParserTests.java index a0a4b3e93e..145547c52a 100644 --- a/config/src/test/java/org/springframework/security/config/http/CsrfBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/http/CsrfBeanDefinitionParserTests.java @@ -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")); diff --git a/config/src/test/java/org/springframework/security/config/http/CsrfConfigTests.java b/config/src/test/java/org/springframework/security/config/http/CsrfConfigTests.java index d98f89227f..fa4b41b400 100644 --- a/config/src/test/java/org/springframework/security/config/http/CsrfConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/CsrfConfigTests.java @@ -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(); diff --git a/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java b/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java index 206a2855a5..2e87b07360 100644 --- a/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java +++ b/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/http/FormLoginConfigTests.java b/config/src/test/java/org/springframework/security/config/http/FormLoginConfigTests.java index 15ae21b295..24e8f0998d 100644 --- a/config/src/test/java/org/springframework/security/config/http/FormLoginConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/FormLoginConfigTests.java @@ -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()); } diff --git a/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java b/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java index d42c37f15b..12d562d4e2 100644 --- a/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java @@ -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; } } diff --git a/config/src/test/java/org/springframework/security/config/http/OpenIDConfigTests.java b/config/src/test/java/org/springframework/security/config/http/OpenIDConfigTests.java index 56f851ffd1..b13678789c 100644 --- a/config/src/test/java/org/springframework/security/config/http/OpenIDConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/OpenIDConfigTests.java @@ -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); diff --git a/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java index 573037c722..38b75d7743 100644 --- a/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java @@ -314,7 +314,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests { // SEC-1392 @Test - public void customPermissionEvaluatorIsSupported() throws Exception { + public void customPermissionEvaluatorIsSupported() { setContext("" + " " + "" @@ -328,7 +328,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests { // SEC-1450 @Test(expected = AuthenticationException.class) @SuppressWarnings("unchecked") - public void genericsAreMatchedByProtectPointcut() throws Exception { + public void genericsAreMatchedByProtectPointcut() { setContext("" + "" + " " @@ -340,7 +340,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests { // SEC-1448 @Test @SuppressWarnings("unchecked") - public void genericsMethodArgumentNamesAreResolved() throws Exception { + public void genericsMethodArgumentNamesAreResolved() { setContext("" + "" + AUTH_PROVIDER_XML); @@ -368,7 +368,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests { @Test @SuppressWarnings("unchecked") - public void supportsExternalMetadataSource() throws Exception { + public void supportsExternalMetadataSource() { setContext("" @@ -394,7 +394,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests { } @Test - public void supportsCustomAuthenticationManager() throws Exception { + public void supportsCustomAuthenticationManager() { setContext("" diff --git a/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java b/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java index ae9b53a0b3..087d0e1bdc 100644 --- a/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java +++ b/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java @@ -103,7 +103,7 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements } @Test(expected = AuthenticationException.class) - public void transactionalMethodsShouldBeSecured() throws Exception { + public void transactionalMethodsShouldBeSecured() { transactionalTarget.doSomething(); } diff --git a/config/src/test/java/org/springframework/security/config/oauth2/client/CommonOAuth2ProviderTests.java b/config/src/test/java/org/springframework/security/config/oauth2/client/CommonOAuth2ProviderTests.java index 8f59e4397c..89111a9f54 100644 --- a/config/src/test/java/org/springframework/security/config/oauth2/client/CommonOAuth2ProviderTests.java +++ b/config/src/test/java/org/springframework/security/config/oauth2/client/CommonOAuth2ProviderTests.java @@ -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") diff --git a/config/src/test/java/org/springframework/security/config/test/SpringTestContext.java b/config/src/test/java/org/springframework/security/config/test/SpringTestContext.java index 19fa379127..ac9cc05b52 100644 --- a/config/src/test/java/org/springframework/security/config/test/SpringTestContext.java +++ b/config/src/test/java/org/springframework/security/config/test/SpringTestContext.java @@ -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); } }); diff --git a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlWebApplicationContext.java b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlWebApplicationContext.java index 64f7e4f05c..6b7d7a4faf 100644 --- a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlWebApplicationContext.java +++ b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlWebApplicationContext.java @@ -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 }); } diff --git a/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java index bfc9b3a077..d19e5e953f 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/web/server/CorsSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/CorsSpecTests.java index 7689f539cb..9cac1da459 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/CorsSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/CorsSpecTests.java @@ -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"); diff --git a/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java index 1b0dcce0e1..beae57c576 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java @@ -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 -> diff --git a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java index ac85c3d691..5135246be9 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java index 22cd608217..6ef72db0d1 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java index 9a01fba23f..4840ba5499 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java @@ -121,7 +121,7 @@ public class LogoutSpecTests { } @Test - public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() throws Exception { + public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() { SecurityWebFilterChain securityWebFilter = this.http .authorizeExchange(authorizeExchange -> authorizeExchange diff --git a/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java b/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java index 667d79c010..d8a9e9abc5 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java @@ -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( diff --git a/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java index 2d547016a3..c292faf14f 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java @@ -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() diff --git a/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java b/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java index 3a26d32856..9f0d9a09ec 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java @@ -105,7 +105,7 @@ public class RequestCacheTests { } @Test - public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() throws Exception { + public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() { SecurityWebFilterChain securityWebFilter = this.http .authorizeExchange(authorizeExchange -> authorizeExchange diff --git a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java index 646f86e588..7a96412b8f 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java @@ -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 diff --git a/config/src/test/java/org/springframework/security/config/websocket/WebSocketMessageBrokerConfigTests.java b/config/src/test/java/org/springframework/security/config/websocket/WebSocketMessageBrokerConfigTests.java index 707da8d891..a693eaf96a 100644 --- a/config/src/test/java/org/springframework/security/config/websocket/WebSocketMessageBrokerConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/websocket/WebSocketMessageBrokerConfigTests.java @@ -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(""); } } diff --git a/config/src/test/java/org/springframework/security/htmlunit/server/MockWebResponseBuilder.java b/config/src/test/java/org/springframework/security/htmlunit/server/MockWebResponseBuilder.java index e2c37fe390..15022b4596 100644 --- a/config/src/test/java/org/springframework/security/htmlunit/server/MockWebResponseBuilder.java +++ b/config/src/test/java/org/springframework/security/htmlunit/server/MockWebResponseBuilder.java @@ -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 responseHeaders = responseHeaders(); HttpStatus status = this.exchangeResult.getStatus(); return new WebResponseData(this.exchangeResult.getResponseBodyContent(), status.value(), status.getReasonPhrase(), responseHeaders); diff --git a/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java b/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java index 40145ac33f..2f3d9e7b76 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java @@ -125,7 +125,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(getSecureObjectClass(), "Subclass must provide a non-null response to getSecureObjectClass()"); Assert.notNull(this.messages, "A message source must be set"); diff --git a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java index f2e9241f48..bc8bea7fb3 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java +++ b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java @@ -61,7 +61,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { checkIfValidList(this.providers); } diff --git a/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java b/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java index decf81ab8c..e8551ca0ae 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java +++ b/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java @@ -57,7 +57,7 @@ public class MethodInvocationPrivilegeEvaluator implements InitializingBean { // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(securityInterceptor, "SecurityInterceptor required"); } diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsImplAuthenticationProvider.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsImplAuthenticationProvider.java index 714154a993..4a1096a1eb 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsImplAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsImplAuthenticationProvider.java @@ -54,7 +54,7 @@ public class RunAsImplAuthenticationProvider implements InitializingBean, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(key, "A Key is required and should match that configured for the RunAsManagerImpl"); } diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java index 6c1b7a17a3..5efcd78d40 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java @@ -63,7 +63,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean { // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull( key, "A Key is required and should match that configured for the RunAsImplAuthenticationProvider"); diff --git a/core/src/main/java/org/springframework/security/access/prepost/PrePostAdviceReactiveMethodInterceptor.java b/core/src/main/java/org/springframework/security/access/prepost/PrePostAdviceReactiveMethodInterceptor.java index 1e9c3a9007..98ef8d43e1 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PrePostAdviceReactiveMethodInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PrePostAdviceReactiveMethodInterceptor.java @@ -69,8 +69,7 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor } @Override - public Object invoke(final MethodInvocation invocation) - throws Throwable { + public Object invoke(final MethodInvocation invocation) { Method method = invocation.getMethod(); Class returnType = method.getReturnType(); if (!Publisher.class.isAssignableFrom(returnType)) { diff --git a/core/src/main/java/org/springframework/security/access/vote/AbstractAccessDecisionManager.java b/core/src/main/java/org/springframework/security/access/vote/AbstractAccessDecisionManager.java index e68629ab93..3cec181713 100644 --- a/core/src/main/java/org/springframework/security/access/vote/AbstractAccessDecisionManager.java +++ b/core/src/main/java/org/springframework/security/access/vote/AbstractAccessDecisionManager.java @@ -60,7 +60,7 @@ public abstract class AbstractAccessDecisionManager implements AccessDecisionMan // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notEmpty(this.decisionVoters, "A list of AccessDecisionVoters is required"); Assert.notNull(this.messages, "A message source must be set"); } diff --git a/core/src/main/java/org/springframework/security/authentication/ProviderManager.java b/core/src/main/java/org/springframework/security/authentication/ProviderManager.java index b483670950..ee487d472b 100644 --- a/core/src/main/java/org/springframework/security/authentication/ProviderManager.java +++ b/core/src/main/java/org/springframework/security/authentication/ProviderManager.java @@ -115,7 +115,7 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { checkState(); } diff --git a/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationProvider.java index 4d49f1b602..0b44ba0fb1 100644 --- a/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationProvider.java @@ -48,7 +48,7 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.messages, "A message source must be set"); } diff --git a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java index c752c81197..4fc122a5cb 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java @@ -228,7 +228,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider implements return result; } - protected void doAfterPropertiesSet() throws Exception { + protected void doAfterPropertiesSet() { } public UserCache getUserCache() { diff --git a/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java index 377b43ccd2..2771f9790a 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java @@ -96,7 +96,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication } } - protected void doAfterPropertiesSet() throws Exception { + protected void doAfterPropertiesSet() { Assert.notNull(this.userDetailsService, "A UserDetailsService must be set"); } diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java index 101bdcef9e..af0fc1086f 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java @@ -60,9 +60,6 @@ public interface JaasAuthenticationCallbackHandler { * @param callback * @param auth The Authentication object currently being authenticated. * - * @throws IOException - * @throws UnsupportedCallbackException */ - void handle(Callback callback, Authentication auth) throws IOException, - UnsupportedCallbackException; + void handle(Callback callback, Authentication auth); } diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java index fe068805ba..c47eac8eff 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java @@ -49,11 +49,8 @@ public class JaasNameCallbackHandler implements JaasAuthenticationCallbackHandle * @param callback * @param authentication * - * @throws IOException - * @throws UnsupportedCallbackException */ - public void handle(Callback callback, Authentication authentication) - throws IOException, UnsupportedCallbackException { + public void handle(Callback callback, Authentication authentication) { if (callback instanceof NameCallback) { NameCallback ncb = (NameCallback) callback; String username; diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasPasswordCallbackHandler.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasPasswordCallbackHandler.java index bf5d69b167..e52a15c4ac 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasPasswordCallbackHandler.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasPasswordCallbackHandler.java @@ -49,11 +49,8 @@ public class JaasPasswordCallbackHandler implements JaasAuthenticationCallbackHa * @param callback * @param auth * - * @throws IOException - * @throws UnsupportedCallbackException */ - public void handle(Callback callback, Authentication auth) throws IOException, - UnsupportedCallbackException { + public void handle(Callback callback, Authentication auth) { if (callback instanceof PasswordCallback) { PasswordCallback pc = (PasswordCallback) callback; pc.setPassword(auth.getCredentials().toString().toCharArray()); diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/SecurityContextLoginModule.java b/core/src/main/java/org/springframework/security/authentication/jaas/SecurityContextLoginModule.java index 6e8b23fa98..38756da657 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/SecurityContextLoginModule.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/SecurityContextLoginModule.java @@ -76,7 +76,7 @@ public class SecurityContextLoginModule implements LoginModule { * * @exception LoginException if the abort fails */ - public boolean abort() throws LoginException { + public boolean abort() { if (authen == null) { return false; } @@ -95,7 +95,7 @@ public class SecurityContextLoginModule implements LoginModule { * * @exception LoginException if the commit fails */ - public boolean commit() throws LoginException { + public boolean commit() { if (authen == null) { return false; } @@ -171,7 +171,7 @@ public class SecurityContextLoginModule implements LoginModule { * * @exception LoginException if the logout fails */ - public boolean logout() throws LoginException { + public boolean logout() { if (authen == null) { return false; } diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java index a8f419d0db..35e1a6d556 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java @@ -43,7 +43,7 @@ public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationMana // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.authenticationManager, "authenticationManager is required"); } diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java index 620378c87d..7e6b8c6b15 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java @@ -60,7 +60,7 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory"); } diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java index c6da2c140e..dd3eb7e0cf 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java @@ -38,7 +38,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper implements private String stringSeparator = ","; private Set mappableAttributes = null; - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(attributes2grantedAuthoritiesMap, "attributes2grantedAuthoritiesMap must be set"); } diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java index c9355f13e6..b3c0a92109 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java @@ -51,7 +51,7 @@ public class SimpleAttributes2GrantedAuthoritiesMapper implements /** * Check whether all properties have been set to correct values. */ - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.isTrue( !(isConvertAttributeToUpperCase() && isConvertAttributeToLowerCase()), "Either convertAttributeToUpperCase or convertAttributeToLowerCase can be set to true, but not both"); diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAuthorityMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAuthorityMapper.java index bda5a900e2..b381d8fcb9 100644 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAuthorityMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAuthorityMapper.java @@ -37,7 +37,7 @@ public final class SimpleAuthorityMapper implements GrantedAuthoritiesMapper, private boolean convertToUpperCase = false; private boolean convertToLowerCase = false; - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.isTrue(!(convertToUpperCase && convertToLowerCase), "Either convertToUpperCase or convertToLowerCase can be set to true, but not both"); } diff --git a/core/src/main/java/org/springframework/security/core/token/KeyBasedPersistenceTokenService.java b/core/src/main/java/org/springframework/security/core/token/KeyBasedPersistenceTokenService.java index 4896e9d4b3..b38b078665 100644 --- a/core/src/main/java/org/springframework/security/core/token/KeyBasedPersistenceTokenService.java +++ b/core/src/main/java/org/springframework/security/core/token/KeyBasedPersistenceTokenService.java @@ -173,7 +173,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi this.serverInteger = serverInteger; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasText(serverSecret, "Server secret required"); Assert.notNull(serverInteger, "Server integer required"); Assert.notNull(secureRandom, "SecureRandom instance required"); diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java index ed98c6e351..daea7fa063 100755 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java @@ -57,7 +57,7 @@ public class UserDetailsByNameServiceWrapper implement * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.userDetailsService, "UserDetailsService must be set"); } diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java index 196136b389..dacd1c69cf 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java @@ -46,7 +46,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean { // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(cache, "cache mandatory"); } diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java index 89009bfc69..8150bd9023 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java @@ -43,7 +43,7 @@ public class SpringCacheBasedUserCache implements UserCache { // ~ Constructors // =================================================================================================== - public SpringCacheBasedUserCache(Cache cache) throws Exception { + public SpringCacheBasedUserCache(Cache cache) { Assert.notNull(cache, "cache mandatory"); this.cache = cache; } diff --git a/core/src/main/java/org/springframework/security/util/InMemoryResource.java b/core/src/main/java/org/springframework/security/util/InMemoryResource.java index 6226b1f0dc..c20d458295 100644 --- a/core/src/main/java/org/springframework/security/util/InMemoryResource.java +++ b/core/src/main/java/org/springframework/security/util/InMemoryResource.java @@ -66,7 +66,7 @@ public class InMemoryResource extends AbstractResource { } @Override - public InputStream getInputStream() throws IOException { + public InputStream getInputStream() { return new ByteArrayInputStream(source); } diff --git a/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java b/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java index f659d87f26..a930b22f2f 100644 --- a/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java +++ b/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java @@ -65,7 +65,7 @@ public class SimpleMethodInvocation implements MethodInvocation { return targetObject; } - public Object proceed() throws Throwable { + public Object proceed() { throw new UnsupportedOperationException("mock method not implemented"); } } diff --git a/core/src/test/java/org/springframework/security/TestDataSource.java b/core/src/test/java/org/springframework/security/TestDataSource.java index cafef4ceb9..53e79e12f0 100644 --- a/core/src/test/java/org/springframework/security/TestDataSource.java +++ b/core/src/test/java/org/springframework/security/TestDataSource.java @@ -37,7 +37,7 @@ public class TestDataSource extends DriverManagerDataSource implements Disposabl setPassword(""); } - public void destroy() throws Exception { + public void destroy() { System.out.println("Shutting down database: " + name); new JdbcTemplate(this).execute("SHUTDOWN"); } diff --git a/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java b/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java index 2a6931d5a7..31a198fddf 100644 --- a/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java +++ b/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java @@ -59,7 +59,7 @@ public class AuthorizationFailureEventTests { } @Test - public void gettersReturnCtorSuppliedData() throws Exception { + public void gettersReturnCtorSuppliedData() { AuthorizationFailureEvent event = new AuthorizationFailureEvent(new Object(), attributes, foo, exception); assertThat(event.getConfigAttributes()).isSameAs(attributes); diff --git a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java index 0d44a8b576..3dc60932fd 100644 --- a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java +++ b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java @@ -55,7 +55,7 @@ public class SecurityConfigTests { } @Test - public void testObjectEquals() throws Exception { + public void testObjectEquals() { SecurityConfig security1 = new SecurityConfig("TEST"); SecurityConfig security2 = new SecurityConfig("TEST"); assertThat(security2).isEqualTo(security1); diff --git a/core/src/test/java/org/springframework/security/access/annotation/Jsr250VoterTests.java b/core/src/test/java/org/springframework/security/access/annotation/Jsr250VoterTests.java index e5b5e427de..6157b00309 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/Jsr250VoterTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/Jsr250VoterTests.java @@ -34,7 +34,7 @@ public class Jsr250VoterTests { // SEC-1443 @Test - public void supportsMultipleRolesCorrectly() throws Exception { + public void supportsMultipleRolesCorrectly() { List attrs = new ArrayList<>(); Jsr250Voter voter = new Jsr250Voter(); diff --git a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSourceTests.java b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSourceTests.java index d8cd444d34..ad60044daa 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSourceTests.java @@ -161,7 +161,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests { // SEC-1491 @Test - public void customAnnotationAttributesAreFound() throws Exception { + public void customAnnotationAttributesAreFound() { SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource( new CustomSecurityAnnotationMetadataExtractor()); Collection attrs = mds.findAttributes( diff --git a/core/src/test/java/org/springframework/security/access/expression/AbstractSecurityExpressionHandlerTests.java b/core/src/test/java/org/springframework/security/access/expression/AbstractSecurityExpressionHandlerTests.java index d0174aad97..7b371e123c 100644 --- a/core/src/test/java/org/springframework/security/access/expression/AbstractSecurityExpressionHandlerTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/AbstractSecurityExpressionHandlerTests.java @@ -35,7 +35,7 @@ public class AbstractSecurityExpressionHandlerTests { private AbstractSecurityExpressionHandler handler; @Before - public void setUp() throws Exception { + public void setUp() { handler = new AbstractSecurityExpressionHandler() { @Override protected SecurityExpressionOperations createSecurityExpressionRoot( @@ -47,7 +47,7 @@ public class AbstractSecurityExpressionHandlerTests { } @Test - public void beanNamesAreCorrectlyResolved() throws Exception { + public void beanNamesAreCorrectlyResolved() { handler.setApplicationContext(new AnnotationConfigApplicationContext( TestConfiguration.class)); diff --git a/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java b/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java index 32d3de6089..3efa1cefc1 100644 --- a/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java @@ -45,7 +45,7 @@ public class SecurityExpressionRootTests { } @Test - public void denyAllIsFalsePermitAllTrue() throws Exception { + public void denyAllIsFalsePermitAllTrue() { assertThat(root.denyAll()).isFalse(); assertThat(root.denyAll).isFalse(); assertThat(root.permitAll()).isTrue(); @@ -53,7 +53,7 @@ public class SecurityExpressionRootTests { } @Test - public void rememberMeIsCorrectlyDetected() throws Exception { + public void rememberMeIsCorrectlyDetected() { AuthenticationTrustResolver atr = mock(AuthenticationTrustResolver.class); root.setTrustResolver(atr); when(atr.isRememberMe(JOE)).thenReturn(true); @@ -62,7 +62,7 @@ public class SecurityExpressionRootTests { } @Test - public void roleHierarchySupportIsCorrectlyUsedInEvaluatingRoles() throws Exception { + public void roleHierarchySupportIsCorrectlyUsedInEvaluatingRoles() { root.setRoleHierarchy(authorities -> AuthorityUtils.createAuthorityList("ROLE_C")); assertThat(root.hasRole("C")).isTrue(); @@ -75,27 +75,27 @@ public class SecurityExpressionRootTests { } @Test - public void hasRoleAddsDefaultPrefix() throws Exception { + public void hasRoleAddsDefaultPrefix() { assertThat(root.hasRole("A")).isTrue(); assertThat(root.hasRole("NO")).isFalse(); } @Test - public void hasRoleEmptyPrefixDoesNotAddsDefaultPrefix() throws Exception { + public void hasRoleEmptyPrefixDoesNotAddsDefaultPrefix() { root.setDefaultRolePrefix(""); assertThat(root.hasRole("A")).isFalse(); assertThat(root.hasRole("ROLE_A")).isTrue(); } @Test - public void hasRoleNullPrefixDoesNotAddsDefaultPrefix() throws Exception { + public void hasRoleNullPrefixDoesNotAddsDefaultPrefix() { root.setDefaultRolePrefix(null); assertThat(root.hasRole("A")).isFalse(); assertThat(root.hasRole("ROLE_A")).isTrue(); } @Test - public void hasRoleDoesNotAddDefaultPrefixForAlreadyPrefixedRoles() throws Exception { + public void hasRoleDoesNotAddDefaultPrefixForAlreadyPrefixedRoles() { SecurityExpressionRoot root = new SecurityExpressionRoot(JOE) { }; @@ -104,34 +104,33 @@ public class SecurityExpressionRootTests { } @Test - public void hasAnyRoleAddsDefaultPrefix() throws Exception { + public void hasAnyRoleAddsDefaultPrefix() { assertThat(root.hasAnyRole("NO", "A")).isTrue(); assertThat(root.hasAnyRole("NO", "NOT")).isFalse(); } @Test - public void hasAnyRoleDoesNotAddDefaultPrefixForAlreadyPrefixedRoles() - throws Exception { + public void hasAnyRoleDoesNotAddDefaultPrefixForAlreadyPrefixedRoles() { assertThat(root.hasAnyRole("ROLE_NO", "ROLE_A")).isTrue(); assertThat(root.hasAnyRole("ROLE_NO", "ROLE_NOT")).isFalse(); } @Test - public void hasAnyRoleEmptyPrefixDoesNotAddsDefaultPrefix() throws Exception { + public void hasAnyRoleEmptyPrefixDoesNotAddsDefaultPrefix() { root.setDefaultRolePrefix(""); assertThat(root.hasRole("A")).isFalse(); assertThat(root.hasRole("ROLE_A")).isTrue(); } @Test - public void hasAnyRoleNullPrefixDoesNotAddsDefaultPrefix() throws Exception { + public void hasAnyRoleNullPrefixDoesNotAddsDefaultPrefix() { root.setDefaultRolePrefix(null); assertThat(root.hasAnyRole("A")).isFalse(); assertThat(root.hasAnyRole("ROLE_A")).isTrue(); } @Test - public void hasAuthorityDoesNotAddDefaultPrefix() throws Exception { + public void hasAuthorityDoesNotAddDefaultPrefix() { assertThat(root.hasAuthority("A")).isFalse(); assertThat(root.hasAnyAuthority("NO", "A")).isFalse(); assertThat(root.hasAnyAuthority("ROLE_A", "NOT")).isTrue(); diff --git a/core/src/test/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdviceTests.java b/core/src/test/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdviceTests.java index 08591c6f62..27095641d8 100644 --- a/core/src/test/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdviceTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdviceTests.java @@ -44,7 +44,7 @@ public class ExpressionBasedPreInvocationAdviceTests { private ExpressionBasedPreInvocationAdvice expressionBasedPreInvocationAdvice; @Before - public void setUp() throws Exception { + public void setUp() { expressionBasedPreInvocationAdvice = new ExpressionBasedPreInvocationAdvice(); } diff --git a/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java b/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java index 19a6965719..2899956888 100644 --- a/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java @@ -51,7 +51,7 @@ public class MethodSecurityExpressionRootTests { } @Test - public void canCallMethodsOnVariables() throws Exception { + public void canCallMethodsOnVariables() { ctx.setVariable("var", "somestring"); Expression e = parser.parseExpression("#var.length() == 10"); @@ -71,8 +71,7 @@ public class MethodSecurityExpressionRootTests { } @Test - public void hasPermissionOnDomainObjectReturnsFalseIfPermissionEvaluatorDoes() - throws Exception { + public void hasPermissionOnDomainObjectReturnsFalseIfPermissionEvaluatorDoes() { final Object dummyDomainObject = new Object(); final PermissionEvaluator pe = mock(PermissionEvaluator.class); ctx.setVariable("domainObject", dummyDomainObject); @@ -84,8 +83,7 @@ public class MethodSecurityExpressionRootTests { } @Test - public void hasPermissionOnDomainObjectReturnsTrueIfPermissionEvaluatorDoes() - throws Exception { + public void hasPermissionOnDomainObjectReturnsTrueIfPermissionEvaluatorDoes() { final Object dummyDomainObject = new Object(); final PermissionEvaluator pe = mock(PermissionEvaluator.class); ctx.setVariable("domainObject", dummyDomainObject); @@ -96,7 +94,7 @@ public class MethodSecurityExpressionRootTests { } @Test - public void hasPermissionOnDomainObjectWorksWithIntegerExpressions() throws Exception { + public void hasPermissionOnDomainObjectWorksWithIntegerExpressions() { final Object dummyDomainObject = new Object(); ctx.setVariable("domainObject", dummyDomainObject); final PermissionEvaluator pe = mock(PermissionEvaluator.class); @@ -116,7 +114,7 @@ public class MethodSecurityExpressionRootTests { } @Test - public void hasPermissionWorksWithThisObject() throws Exception { + public void hasPermissionWorksWithThisObject() { Object targetObject = new Object() { public String getX() { return "x"; diff --git a/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java b/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java index 27eed45a8d..5c0cc78c49 100644 --- a/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java @@ -84,8 +84,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests { } @Test - public void classLevelPreAnnotationIsPickedUpWhenNoMethodLevelExists() - throws Exception { + public void classLevelPreAnnotationIsPickedUpWhenNoMethodLevelExists() { ConfigAttribute[] attrs = mds.getAttributes(voidImpl1).toArray( new ConfigAttribute[0]); @@ -167,7 +166,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests { } @Test - public void customAnnotationAtClassLevelIsDetected() throws Exception { + public void customAnnotationAtClassLevelIsDetected() { ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray( new ConfigAttribute[0]); @@ -175,7 +174,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests { } @Test - public void customAnnotationAtInterfaceLevelIsDetected() throws Exception { + public void customAnnotationAtInterfaceLevelIsDetected() { ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray( new ConfigAttribute[0]); @@ -183,7 +182,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests { } @Test - public void customAnnotationAtMethodLevelIsDetected() throws Exception { + public void customAnnotationAtMethodLevelIsDetected() { ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray( new ConfigAttribute[0]); diff --git a/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyUtilsTests.java b/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyUtilsTests.java index bb235b5a0b..2fb503fa95 100644 --- a/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyUtilsTests.java +++ b/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyUtilsTests.java @@ -31,7 +31,7 @@ public class RoleHierarchyUtilsTests { private static final String EOL = System.lineSeparator(); @Test - public void roleHierarchyFromMapWhenMapValidThenConvertsCorrectly() throws Exception { + public void roleHierarchyFromMapWhenMapValidThenConvertsCorrectly() { // @formatter:off String expectedRoleHierarchy = "ROLE_A > ROLE_B" + EOL + "ROLE_A > ROLE_C" + EOL + @@ -50,17 +50,17 @@ public class RoleHierarchyUtilsTests { } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenMapNullThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenMapNullThenThrowsIllegalArgumentException() { RoleHierarchyUtils.roleHierarchyFromMap(null); } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenMapEmptyThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenMapEmptyThenThrowsIllegalArgumentException() { RoleHierarchyUtils.roleHierarchyFromMap(Collections.>emptyMap()); } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenRoleNullThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenRoleNullThenThrowsIllegalArgumentException() { Map> roleHierarchyMap = new HashMap<>(); roleHierarchyMap.put(null, asList("ROLE_B", "ROLE_C")); @@ -68,7 +68,7 @@ public class RoleHierarchyUtilsTests { } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenRoleEmptyThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenRoleEmptyThenThrowsIllegalArgumentException() { Map> roleHierarchyMap = new HashMap<>(); roleHierarchyMap.put("", asList("ROLE_B", "ROLE_C")); @@ -76,7 +76,7 @@ public class RoleHierarchyUtilsTests { } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenImpliedRolesNullThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenImpliedRolesNullThenThrowsIllegalArgumentException() { Map> roleHierarchyMap = new HashMap<>(); roleHierarchyMap.put("ROLE_A", null); @@ -84,7 +84,7 @@ public class RoleHierarchyUtilsTests { } @Test(expected = IllegalArgumentException.class) - public void roleHierarchyFromMapWhenImpliedRolesEmptyThenThrowsIllegalArgumentException() throws Exception { + public void roleHierarchyFromMapWhenImpliedRolesEmptyThenThrowsIllegalArgumentException() { Map> roleHierarchyMap = new HashMap<>(); roleHierarchyMap.put("ROLE_A", Collections.emptyList()); diff --git a/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java index 4b76462639..e9bd20de69 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java @@ -35,7 +35,7 @@ public class AbstractSecurityInterceptorTests { // ======================================================================================================== @Test(expected = IllegalArgumentException.class) - public void detectsIfInvocationPassedIncompatibleSecureObject() throws Exception { + public void detectsIfInvocationPassedIncompatibleSecureObject() { MockSecurityInterceptorWhichOnlySupportsStrings si = new MockSecurityInterceptorWhichOnlySupportsStrings(); si.setRunAsManager(mock(RunAsManager.class)); diff --git a/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java b/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java index c3831b8330..be93663948 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java @@ -41,8 +41,7 @@ public class RunAsManagerImplTests { } @Test - public void testDoesNotReturnAdditionalAuthoritiesIfCalledWithoutARunAsSetting() - throws Exception { + public void testDoesNotReturnAdditionalAuthoritiesIfCalledWithoutARunAsSetting() { UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken( "Test", "Password", AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO")); @@ -56,7 +55,7 @@ public class RunAsManagerImplTests { } @Test - public void testRespectsRolePrefix() throws Exception { + public void testRespectsRolePrefix() { UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken( "Test", "Password", AuthorityUtils.createAuthorityList("ONE", "TWO")); @@ -83,7 +82,7 @@ public class RunAsManagerImplTests { } @Test - public void testReturnsAdditionalGrantedAuthorities() throws Exception { + public void testReturnsAdditionalGrantedAuthorities() { UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken( "Test", "Password", AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO")); @@ -133,7 +132,7 @@ public class RunAsManagerImplTests { } @Test - public void testSupports() throws Exception { + public void testSupports() { RunAsManager runAs = new RunAsManagerImpl(); assertThat(runAs.supports(new SecurityConfig("RUN_AS_SOMETHING"))).isTrue(); assertThat(!runAs.supports(new SecurityConfig("ROLE_WHICH_IS_IGNORED"))).isTrue(); diff --git a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java index afa6819abb..b4e1f61c64 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java @@ -67,7 +67,7 @@ public class MethodSecurityInterceptorTests { // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { SecurityContextHolder.clearContext(); token = new TestingAuthenticationToken("Test", "Password"); interceptor = new MethodSecurityInterceptor(); @@ -83,7 +83,7 @@ public class MethodSecurityInterceptorTests { } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @@ -210,8 +210,7 @@ public class MethodSecurityInterceptorTests { } @Test(expected = AuthenticationException.class) - public void callIsntMadeWhenAuthenticationManagerRejectsAuthentication() - throws Exception { + public void callIsntMadeWhenAuthenticationManagerRejectsAuthentication() { final TestingAuthenticationToken token = new TestingAuthenticationToken("Test", "Password"); SecurityContextHolder.getContext().setAuthentication(token); @@ -224,7 +223,7 @@ public class MethodSecurityInterceptorTests { } @Test - public void callSucceedsIfAccessDecisionManagerGrantsAccess() throws Exception { + public void callSucceedsIfAccessDecisionManagerGrantsAccess() { token.setAuthenticated(true); interceptor.setPublishAuthorizationSuccess(true); SecurityContextHolder.getContext().setAuthentication(token); @@ -238,7 +237,7 @@ public class MethodSecurityInterceptorTests { } @Test - public void callIsntMadeWhenAccessDecisionManagerRejectsAccess() throws Exception { + public void callIsntMadeWhenAccessDecisionManagerRejectsAccess() { SecurityContextHolder.getContext().setAuthentication(token); // Use mocked target to make sure invocation doesn't happen (not in expectations // so test would fail) @@ -263,7 +262,7 @@ public class MethodSecurityInterceptorTests { } @Test - public void runAsReplacementIsCorrectlySet() throws Exception { + public void runAsReplacementIsCorrectlySet() { SecurityContext ctx = SecurityContextHolder.getContext(); ctx.setAuthentication(token); token.setAuthenticated(true); @@ -284,7 +283,7 @@ public class MethodSecurityInterceptorTests { // SEC-1967 @Test - public void runAsReplacementCleansAfterException() throws Exception { + public void runAsReplacementCleansAfterException() { createTarget(true); when(realTarget.makeUpperCase(anyString())).thenThrow(new RuntimeException()); SecurityContext ctx = SecurityContextHolder.getContext(); @@ -311,7 +310,7 @@ public class MethodSecurityInterceptorTests { } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void emptySecurityContextIsRejected() throws Exception { + public void emptySecurityContextIsRejected() { mdsReturnsUserRole(); advisedTarget.makeUpperCase("hello"); } diff --git a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java index 71948e5264..e98c5764a6 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java @@ -66,7 +66,7 @@ public class AspectJMethodSecurityInterceptorTests { // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { MockitoAnnotations.initMocks(this); SecurityContextHolder.clearContext(); token = new TestingAuthenticationToken("Test", "Password"); @@ -109,7 +109,7 @@ public class AspectJMethodSecurityInterceptorTests { @SuppressWarnings("unchecked") @Test - public void callbackIsNotInvokedWhenPermissionDenied() throws Exception { + public void callbackIsNotInvokedWhenPermissionDenied() { doThrow(new AccessDeniedException("denied")).when(adm).decide( any(), any(), any()); @@ -124,7 +124,7 @@ public class AspectJMethodSecurityInterceptorTests { } @Test - public void adapterHoldsCorrectData() throws Exception { + public void adapterHoldsCorrectData() { TargetObject to = new TargetObject(); Method m = ClassUtils.getMethodIfAvailable(TargetObject.class, "countLength", new Class[] { String.class }); @@ -139,7 +139,7 @@ public class AspectJMethodSecurityInterceptorTests { } @Test - public void afterInvocationManagerIsNotInvokedIfExceptionIsRaised() throws Throwable { + public void afterInvocationManagerIsNotInvokedIfExceptionIsRaised() { token.setAuthenticated(true); SecurityContextHolder.getContext().setAuthentication(token); @@ -161,8 +161,7 @@ public class AspectJMethodSecurityInterceptorTests { // SEC-1967 @Test @SuppressWarnings("unchecked") - public void invokeWithAspectJCallbackRunAsReplacementCleansAfterException() - throws Exception { + public void invokeWithAspectJCallbackRunAsReplacementCleansAfterException() { SecurityContext ctx = SecurityContextHolder.getContext(); ctx.setAuthentication(token); token.setAuthenticated(true); diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MapBasedMethodSecurityMetadataSourceTests.java b/core/src/test/java/org/springframework/security/access/intercept/method/MapBasedMethodSecurityMetadataSourceTests.java index 0d47c9d342..89ae4f9822 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MapBasedMethodSecurityMetadataSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MapBasedMethodSecurityMetadataSourceTests.java @@ -54,7 +54,7 @@ public class MapBasedMethodSecurityMetadataSourceTests { } @Test - public void methodsWithDifferentArgumentsAreMatchedCorrectly() throws Exception { + public void methodsWithDifferentArgumentsAreMatchedCorrectly() { mds.addSecureMethod(MockService.class, someMethodInteger, ROLE_A); mds.addSecureMethod(MockService.class, someMethodString, ROLE_B); diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java b/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java index 7e12c3bc99..80b6b3ac4d 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java @@ -57,7 +57,7 @@ public class MethodInvocationPrivilegeEvaluatorTests { // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { SecurityContextHolder.clearContext(); interceptor = new MethodSecurityInterceptor(); token = new TestingAuthenticationToken("Test", "Password", "ROLE_SOMETHING"); @@ -85,7 +85,7 @@ public class MethodInvocationPrivilegeEvaluatorTests { } @Test - public void allowsAccessUsingCreateFromClass() throws Exception { + public void allowsAccessUsingCreateFromClass() { final MethodInvocation mi = MethodInvocationUtils.createFromClass( new OtherTargetObject(), ITargetObject.class, "makeLowerCase", new Class[] { String.class }, new Object[] { "Hello world" }); @@ -97,7 +97,7 @@ public class MethodInvocationPrivilegeEvaluatorTests { } @Test - public void declinesAccessUsingCreate() throws Exception { + public void declinesAccessUsingCreate() { Object object = new TargetObject(); final MethodInvocation mi = MethodInvocationUtils.create(object, "makeLowerCase", "foobar"); @@ -110,7 +110,7 @@ public class MethodInvocationPrivilegeEvaluatorTests { } @Test - public void declinesAccessUsingCreateFromClass() throws Exception { + public void declinesAccessUsingCreateFromClass() { final MethodInvocation mi = MethodInvocationUtils.createFromClass( new OtherTargetObject(), ITargetObject.class, "makeLowerCase", new Class[] { String.class }, new Object[] { "helloWorld" }); diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodInvocation.java b/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodInvocation.java index 3c4704fb3a..8c295000ff 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodInvocation.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodInvocation.java @@ -54,7 +54,7 @@ public class MockMethodInvocation implements MethodInvocation { return targetObject; } - public Object proceed() throws Throwable { + public Object proceed() { return null; } } diff --git a/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java b/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java index 2ed0ac0f4e..e3fb32d6bb 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java @@ -51,7 +51,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testDelegatesSupportsClassRequests() throws Exception { + public void testDelegatesSupportsClassRequests() { List list = new Vector(); list.add(new DenyVoter()); list.add(new MockStringOnlyVoter()); @@ -63,7 +63,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testDelegatesSupportsRequests() throws Exception { + public void testDelegatesSupportsRequests() { List list = new Vector(); DenyVoter voter = new DenyVoter(); DenyAgainVoter denyVoter = new DenyAgainVoter(); @@ -80,7 +80,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testProperlyStoresListOfVoters() throws Exception { + public void testProperlyStoresListOfVoters() { List list = new Vector(); DenyVoter voter = new DenyVoter(); DenyAgainVoter denyVoter = new DenyAgainVoter(); @@ -91,7 +91,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testRejectsEmptyList() throws Exception { + public void testRejectsEmptyList() { List list = new Vector(); try { @@ -104,7 +104,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testRejectsNullVotersList() throws Exception { + public void testRejectsNullVotersList() { try { new MockDecisionManagerImpl(null); fail("Should have thrown IllegalArgumentException"); @@ -121,7 +121,7 @@ public class AbstractAccessDecisionManagerTests { } @Test - public void testWillNotStartIfDecisionVotersNotSet() throws Exception { + public void testWillNotStartIfDecisionVotersNotSet() { try { new MockDecisionManagerImpl(null); fail("Should have thrown IllegalArgumentException"); diff --git a/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java index cf56374fb1..4f66e67244 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java @@ -42,14 +42,13 @@ public class AbstractAclVoterTests { }; @Test - public void supportsMethodInvocations() throws Exception { + public void supportsMethodInvocations() { assertThat(voter.supports(MethodInvocation.class)).isTrue(); assertThat(voter.supports(String.class)).isFalse(); } @Test - public void expectedDomainObjectArgumentIsReturnedFromMethodInvocation() - throws Exception { + public void expectedDomainObjectArgumentIsReturnedFromMethodInvocation() { voter.setProcessDomainObjectClass(String.class); MethodInvocation mi = MethodInvocationUtils.create(new TestClass(), "methodTakingAString", "The Argument"); @@ -57,7 +56,7 @@ public class AbstractAclVoterTests { } @Test - public void correctArgumentIsSelectedFromMultipleArgs() throws Exception { + public void correctArgumentIsSelectedFromMultipleArgs() { voter.setProcessDomainObjectClass(String.class); MethodInvocation mi = MethodInvocationUtils.create(new TestClass(), "methodTakingAListAndAString", new ArrayList<>(), "The Argument"); diff --git a/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java index 240a8e6ac1..bf237fb51b 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java @@ -73,29 +73,28 @@ public class AffirmativeBasedTests { } @Test - public void oneDenyVoteOneAbstainVoteOneAffirmativeVoteGrantsAccess() - throws Exception { + public void oneDenyVoteOneAbstainVoteOneAffirmativeVoteGrantsAccess() { mgr = new AffirmativeBased(Arrays.> asList( deny, abstain, grant)); mgr.decide(user, new Object(), attrs); } @Test - public void oneAffirmativeVoteTwoAbstainVotesGrantsAccess() throws Exception { + public void oneAffirmativeVoteTwoAbstainVotesGrantsAccess() { mgr = new AffirmativeBased(Arrays.> asList( grant, abstain, abstain)); mgr.decide(user, new Object(), attrs); } @Test(expected = AccessDeniedException.class) - public void oneDenyVoteTwoAbstainVotesDeniesAccess() throws Exception { + public void oneDenyVoteTwoAbstainVotesDeniesAccess() { mgr = new AffirmativeBased(Arrays.> asList( deny, abstain, abstain)); mgr.decide(user, new Object(), attrs); } @Test(expected = AccessDeniedException.class) - public void onlyAbstainVotesDeniesAccessWithDefault() throws Exception { + public void onlyAbstainVotesDeniesAccessWithDefault() { mgr = new AffirmativeBased(Arrays.> asList( abstain, abstain, abstain)); assertThat(!mgr.isAllowIfAllAbstainDecisions()).isTrue(); // check default @@ -104,8 +103,7 @@ public class AffirmativeBasedTests { } @Test - public void testThreeAbstainVotesGrantsAccessIfAllowIfAllAbstainDecisionsIsSet() - throws Exception { + public void testThreeAbstainVotesGrantsAccessIfAllowIfAllAbstainDecisionsIsSet() { mgr = new AffirmativeBased(Arrays.> asList( abstain, abstain, abstain)); mgr.setAllowIfAllAbstainDecisions(true); diff --git a/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java index 494d66b07a..e8fca78fc2 100644 --- a/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java @@ -35,8 +35,7 @@ import java.util.*; public class ConsensusBasedTests { @Test(expected = AccessDeniedException.class) - public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteDeniesAccessWithoutDefault() - throws Exception { + public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteDeniesAccessWithoutDefault() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); mgr.setAllowIfEqualGrantedDeniedDecisions(false); @@ -49,8 +48,7 @@ public class ConsensusBasedTests { } @Test - public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteGrantsAccessWithDefault() - throws Exception { + public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteGrantsAccessWithDefault() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); @@ -64,7 +62,7 @@ public class ConsensusBasedTests { } @Test - public void testOneAffirmativeVoteTwoAbstainVotesGrantsAccess() throws Exception { + public void testOneAffirmativeVoteTwoAbstainVotesGrantsAccess() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); @@ -73,7 +71,7 @@ public class ConsensusBasedTests { } @Test(expected = AccessDeniedException.class) - public void testOneDenyVoteTwoAbstainVotesDeniesAccess() throws Exception { + public void testOneDenyVoteTwoAbstainVotesDeniesAccess() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); @@ -82,7 +80,7 @@ public class ConsensusBasedTests { } @Test(expected = AccessDeniedException.class) - public void testThreeAbstainVotesDeniesAccessWithDefault() throws Exception { + public void testThreeAbstainVotesDeniesAccessWithDefault() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); @@ -92,7 +90,7 @@ public class ConsensusBasedTests { } @Test - public void testThreeAbstainVotesGrantsAccessWithoutDefault() throws Exception { + public void testThreeAbstainVotesGrantsAccessWithoutDefault() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); mgr.setAllowIfAllAbstainDecisions(true); @@ -102,7 +100,7 @@ public class ConsensusBasedTests { } @Test - public void testTwoAffirmativeVotesTwoAbstainVotesGrantsAccess() throws Exception { + public void testTwoAffirmativeVotesTwoAbstainVotesGrantsAccess() { TestingAuthenticationToken auth = makeTestToken(); ConsensusBased mgr = makeDecisionManager(); diff --git a/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java index b861cebd90..a00a611850 100644 --- a/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java @@ -73,8 +73,7 @@ public class UnanimousBasedTests { } @Test - public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteDeniesAccess() - throws Exception { + public void testOneAffirmativeVoteOneDenyVoteOneAbstainVoteDeniesAccess() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); @@ -90,7 +89,7 @@ public class UnanimousBasedTests { } @Test - public void testOneAffirmativeVoteTwoAbstainVotesGrantsAccess() throws Exception { + public void testOneAffirmativeVoteTwoAbstainVotesGrantsAccess() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); @@ -100,7 +99,7 @@ public class UnanimousBasedTests { } @Test - public void testOneDenyVoteTwoAbstainVotesDeniesAccess() throws Exception { + public void testOneDenyVoteTwoAbstainVotesDeniesAccess() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); @@ -115,7 +114,7 @@ public class UnanimousBasedTests { } @Test - public void testRoleVoterPrefixObserved() throws Exception { + public void testRoleVoterPrefixObserved() { TestingAuthenticationToken auth = makeTestTokenWithFooBarPrefix(); UnanimousBased mgr = makeDecisionManagerWithFooBarPrefix(); @@ -126,7 +125,7 @@ public class UnanimousBasedTests { } @Test - public void testThreeAbstainVotesDeniesAccessWithDefault() throws Exception { + public void testThreeAbstainVotesDeniesAccessWithDefault() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); @@ -143,7 +142,7 @@ public class UnanimousBasedTests { } @Test - public void testThreeAbstainVotesGrantsAccessWithoutDefault() throws Exception { + public void testThreeAbstainVotesGrantsAccessWithoutDefault() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); mgr.setAllowIfAllAbstainDecisions(true); @@ -155,7 +154,7 @@ public class UnanimousBasedTests { } @Test - public void testTwoAffirmativeVotesTwoAbstainVotesGrantsAccess() throws Exception { + public void testTwoAffirmativeVotesTwoAbstainVotesGrantsAccess() { TestingAuthenticationToken auth = makeTestToken(); UnanimousBased mgr = makeDecisionManager(); diff --git a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java index dc6b6db183..7f5638b31e 100644 --- a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java @@ -42,7 +42,7 @@ public class AbstractAuthenticationTokenTests { // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { authorities = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"); } @@ -58,7 +58,7 @@ public class AbstractAuthenticationTokenTests { } @Test - public void testGetters() throws Exception { + public void testGetters() { MockAuthenticationImpl token = new MockAuthenticationImpl("Test", "Password", authorities); assertThat(token.getPrincipal()).isEqualTo("Test"); @@ -67,7 +67,7 @@ public class AbstractAuthenticationTokenTests { } @Test - public void testHashCode() throws Exception { + public void testHashCode() { MockAuthenticationImpl token1 = new MockAuthenticationImpl("Test", "Password", authorities); MockAuthenticationImpl token2 = new MockAuthenticationImpl("Test", "Password", @@ -83,7 +83,7 @@ public class AbstractAuthenticationTokenTests { } @Test - public void testObjectsEquals() throws Exception { + public void testObjectsEquals() { MockAuthenticationImpl token1 = new MockAuthenticationImpl("Test", "Password", authorities); MockAuthenticationImpl token2 = new MockAuthenticationImpl("Test", "Password", @@ -115,7 +115,7 @@ public class AbstractAuthenticationTokenTests { } @Test - public void testSetAuthenticated() throws Exception { + public void testSetAuthenticated() { MockAuthenticationImpl token = new MockAuthenticationImpl("Test", "Password", authorities); assertThat(!token.isAuthenticated()).isTrue(); diff --git a/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java b/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java index fc7866e15c..ae84a545e8 100644 --- a/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java +++ b/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java @@ -40,7 +40,7 @@ public class DefaultAuthenticationEventPublisherTests { DefaultAuthenticationEventPublisher publisher; @Test - public void expectedDefaultMappingsAreSatisfied() throws Exception { + public void expectedDefaultMappingsAreSatisfied() { publisher = new DefaultAuthenticationEventPublisher(); ApplicationEventPublisher appPublisher = mock(ApplicationEventPublisher.class); publisher.setApplicationEventPublisher(appPublisher); @@ -123,7 +123,7 @@ public class DefaultAuthenticationEventPublisherTests { } @Test - public void unknownFailureExceptionIsIgnored() throws Exception { + public void unknownFailureExceptionIsIgnored() { publisher = new DefaultAuthenticationEventPublisher(); Properties p = new Properties(); p.put(MockAuthenticationException.class.getName(), diff --git a/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java b/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java index 24872762c0..d15a84915b 100644 --- a/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java +++ b/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java @@ -69,8 +69,7 @@ public class ProviderManagerTests { } @Test - public void authenticationSucceedsWithSupportedTokenAndReturnsExpectedObject() - throws Exception { + public void authenticationSucceedsWithSupportedTokenAndReturnsExpectedObject() { final Authentication a = mock(Authentication.class); ProviderManager mgr = new ProviderManager( Arrays.asList(createProviderWhichReturns(a))); @@ -96,13 +95,12 @@ public class ProviderManagerTests { } @Test(expected = IllegalArgumentException.class) - public void testStartupFailsIfProvidersNotSet() throws Exception { + public void testStartupFailsIfProvidersNotSet() { new ProviderManager(null); } @Test - public void detailsAreNotSetOnAuthenticationTokenIfAlreadySetByProvider() - throws Exception { + public void detailsAreNotSetOnAuthenticationTokenIfAlreadySetByProvider() { Object requestDetails = "(Request Details)"; final Object resultDetails = "(Result Details)"; @@ -143,8 +141,7 @@ public class ProviderManagerTests { } @Test - public void authenticationExceptionIsIgnoredIfLaterProviderAuthenticates() - throws Exception { + public void authenticationExceptionIsIgnoredIfLaterProviderAuthenticates() { final Authentication authReq = mock(Authentication.class); ProviderManager mgr = new ProviderManager( Arrays.asList(createProviderWhichThrows(new BadCredentialsException("", @@ -153,8 +150,7 @@ public class ProviderManagerTests { } @Test - public void authenticationExceptionIsRethrownIfNoLaterProviderAuthenticates() - throws Exception { + public void authenticationExceptionIsRethrownIfNoLaterProviderAuthenticates() { ProviderManager mgr = new ProviderManager(Arrays.asList( createProviderWhichThrows(new BadCredentialsException("")), @@ -169,8 +165,7 @@ public class ProviderManagerTests { // SEC-546 @Test - public void accountStatusExceptionPreventsCallsToSubsequentProviders() - throws Exception { + public void accountStatusExceptionPreventsCallsToSubsequentProviders() { AuthenticationProvider iThrowAccountStatusException = createProviderWhichThrows(new AccountStatusException( "") { }); @@ -189,7 +184,7 @@ public class ProviderManagerTests { } @Test - public void parentAuthenticationIsUsedIfProvidersDontAuthenticate() throws Exception { + public void parentAuthenticationIsUsedIfProvidersDontAuthenticate() { AuthenticationManager parent = mock(AuthenticationManager.class); Authentication authReq = mock(Authentication.class); when(parent.authenticate(authReq)).thenReturn(authReq); @@ -199,7 +194,7 @@ public class ProviderManagerTests { } @Test - public void parentIsNotCalledIfAccountStatusExceptionIsThrown() throws Exception { + public void parentIsNotCalledIfAccountStatusExceptionIsThrown() { AuthenticationProvider iThrowAccountStatusException = createProviderWhichThrows(new AccountStatusException( "", new Throwable()) { }); @@ -216,7 +211,7 @@ public class ProviderManagerTests { } @Test - public void providerNotFoundFromParentIsIgnored() throws Exception { + public void providerNotFoundFromParentIsIgnored() { final Authentication authReq = mock(Authentication.class); AuthenticationEventPublisher publisher = mock(AuthenticationEventPublisher.class); AuthenticationManager parent = mock(AuthenticationManager.class); @@ -239,7 +234,7 @@ public class ProviderManagerTests { } @Test - public void authenticationExceptionFromParentOverridesPreviousOnes() throws Exception { + public void authenticationExceptionFromParentOverridesPreviousOnes() { AuthenticationManager parent = mock(AuthenticationManager.class); ProviderManager mgr = new ProviderManager( Arrays.asList(createProviderWhichThrows(new BadCredentialsException(""))), @@ -263,7 +258,7 @@ public class ProviderManagerTests { @Test @SuppressWarnings("deprecation") - public void statusExceptionIsPublished() throws Exception { + public void statusExceptionIsPublished() { AuthenticationManager parent = mock(AuthenticationManager.class); final LockedException expected = new LockedException(""); ProviderManager mgr = new ProviderManager( @@ -347,7 +342,7 @@ public class ProviderManagerTests { new ArrayList<>(0)); } - private ProviderManager makeProviderManager() throws Exception { + private ProviderManager makeProviderManager() { MockProvider provider1 = new MockProvider(); List providers = new ArrayList<>(); providers.add(provider1); diff --git a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java index 7a54d2f4c6..11277b56bf 100644 --- a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java @@ -37,7 +37,7 @@ public class AnonymousAuthenticationProviderTests { // ======================================================================================================== @Test - public void testDetectsAnInvalidKey() throws Exception { + public void testDetectsAnInvalidKey() { AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider( "qwerty"); @@ -54,7 +54,7 @@ public class AnonymousAuthenticationProviderTests { } @Test - public void testDetectsMissingKey() throws Exception { + public void testDetectsMissingKey() { try { new AnonymousAuthenticationProvider(null); fail("Should have thrown IllegalArgumentException"); @@ -65,14 +65,14 @@ public class AnonymousAuthenticationProviderTests { } @Test - public void testGettersSetters() throws Exception { + public void testGettersSetters() { AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider( "qwerty"); assertThat(aap.getKey()).isEqualTo("qwerty"); } @Test - public void testIgnoresClassesItDoesNotSupport() throws Exception { + public void testIgnoresClassesItDoesNotSupport() { AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider( "qwerty"); @@ -85,7 +85,7 @@ public class AnonymousAuthenticationProviderTests { } @Test - public void testNormalOperation() throws Exception { + public void testNormalOperation() { AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider( "qwerty"); diff --git a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java index 40afdc6087..1fec11d0c4 100644 --- a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java @@ -149,17 +149,17 @@ public class AnonymousAuthenticationTokenTests { } @Test(expected = IllegalArgumentException.class) - public void constructorWhenNullAuthoritiesThenThrowIllegalArgumentException() throws Exception { + public void constructorWhenNullAuthoritiesThenThrowIllegalArgumentException() { new AnonymousAuthenticationToken("key", "principal", null); } @Test(expected = IllegalArgumentException.class) - public void constructorWhenEmptyAuthoritiesThenThrowIllegalArgumentException() throws Exception { + public void constructorWhenEmptyAuthoritiesThenThrowIllegalArgumentException() { new AnonymousAuthenticationToken("key", "principal", Collections.emptyList()); } @Test(expected = IllegalArgumentException.class) - public void constructorWhenPrincipalIsEmptyStringThenThrowIllegalArgumentException() throws Exception { + public void constructorWhenPrincipalIsEmptyStringThenThrowIllegalArgumentException() { new AnonymousAuthenticationToken("key", "", ROLES_12); } } diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/DefaultJaasAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/jaas/DefaultJaasAuthenticationProviderTests.java index 95bc9d11e3..66b117651a 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/DefaultJaasAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/DefaultJaasAuthenticationProviderTests.java @@ -96,7 +96,7 @@ public class DefaultJaasAuthenticationProviderTests { } @Test - public void authenticateSuccess() throws Exception { + public void authenticateSuccess() { Authentication auth = provider.authenticate(token); assertThat(auth.getPrincipal()).isEqualTo(token.getPrincipal()); assertThat(auth.getCredentials()).isEqualTo(token.getCredentials()); @@ -194,7 +194,7 @@ public class DefaultJaasAuthenticationProviderTests { } @Test - public void logoutNullLoginContext() throws Exception { + public void logoutNullLoginContext() { SessionDestroyedEvent event = mock(SessionDestroyedEvent.class); SecurityContext securityContext = mock(SecurityContext.class); JaasAuthenticationToken token = mock(JaasAuthenticationToken.class); diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java index ad1ff88ebc..ea794e8126 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java @@ -62,7 +62,7 @@ public class JaasAuthenticationProviderTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { String resName = "/" + getClass().getName().replace('.', '/') + ".xml"; context = new ClassPathXmlApplicationContext(resName); eventCheck = (JaasEventCheck) context.getBean("eventCheck"); @@ -190,7 +190,7 @@ public class JaasAuthenticationProviderTests { } @Test - public void testFull() throws Exception { + public void testFull() { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( "user", "password", AuthorityUtils.createAuthorityList("ROLE_ONE")); @@ -227,7 +227,7 @@ public class JaasAuthenticationProviderTests { } @Test - public void testGetApplicationEventPublisher() throws Exception { + public void testGetApplicationEventPublisher() { assertThat(jaasProvider.getApplicationEventPublisher()).isNotNull(); } @@ -294,7 +294,7 @@ public class JaasAuthenticationProviderTests { super(loginModule); } - public void logout() throws LoginException { + public void logout() { this.loggedOut = true; } } diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/JaasGrantedAuthorityTests.java b/core/src/test/java/org/springframework/security/authentication/jaas/JaasGrantedAuthorityTests.java index cc5aafbae1..9b952fd0ec 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/JaasGrantedAuthorityTests.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/JaasGrantedAuthorityTests.java @@ -29,20 +29,18 @@ import org.springframework.security.authentication.jaas.JaasGrantedAuthority; public class JaasGrantedAuthorityTests { /** - * @throws Exception */ @Test - public void authorityWithNullRoleFailsAssertion() throws Exception { + public void authorityWithNullRoleFailsAssertion() { assertThatThrownBy(() -> new JaasGrantedAuthority(null, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("role cannot be null"); } /** - * @throws Exception */ @Test - public void authorityWithNullPrincipleFailsAssertion() throws Exception { + public void authorityWithNullPrincipleFailsAssertion() { assertThatThrownBy(() -> new JaasGrantedAuthority("role", null)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("principal cannot be null"); diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/SecurityContextLoginModuleTests.java b/core/src/test/java/org/springframework/security/authentication/jaas/SecurityContextLoginModuleTests.java index e3a59886fe..f34222e28c 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/SecurityContextLoginModuleTests.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/SecurityContextLoginModuleTests.java @@ -52,14 +52,14 @@ public class SecurityContextLoginModuleTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { this.module = new SecurityContextLoginModule(); this.module.initialize(this.subject, null, null, null); SecurityContextHolder.clearContext(); } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); this.module = null; } @@ -75,7 +75,7 @@ public class SecurityContextLoginModuleTests { } @Test - public void testLoginException() throws Exception { + public void testLoginException() { try { this.module.login(); fail("LoginException expected, there is no Authentication in the SecurityContext"); @@ -112,7 +112,7 @@ public class SecurityContextLoginModuleTests { } @Test - public void testNullAuthenticationInSecurityContext() throws Exception { + public void testNullAuthenticationInSecurityContext() { try { SecurityContextHolder.getContext().setAuthentication(null); this.module.login(); diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java b/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java index 77523dfd6d..2abc0cb692 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java @@ -34,8 +34,7 @@ public class TestCallbackHandler implements JaasAuthenticationCallbackHandler { // ~ Methods // ======================================================================================================== - public void handle(Callback callback, Authentication auth) throws IOException, - UnsupportedCallbackException { + public void handle(Callback callback, Authentication auth) { if (callback instanceof TextInputCallback) { TextInputCallback tic = (TextInputCallback) callback; tic.setText(auth.getPrincipal().toString()); diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java b/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java index e9d1cf5504..53ff92c19b 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java @@ -37,11 +37,11 @@ public class TestLoginModule implements LoginModule { // ~ Methods // ======================================================================================================== - public boolean abort() throws LoginException { + public boolean abort() { return true; } - public boolean commit() throws LoginException { + public boolean commit() { return true; } @@ -82,7 +82,7 @@ public class TestLoginModule implements LoginModule { return true; } - public boolean logout() throws LoginException { + public boolean logout() { return true; } } diff --git a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java index f07e9f0ea6..c6a948e913 100644 --- a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java @@ -37,7 +37,7 @@ public class RememberMeAuthenticationProviderTests { // ~ Methods // ======================================================================================================== @Test - public void testDetectsAnInvalidKey() throws Exception { + public void testDetectsAnInvalidKey() { RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider( "qwerty"); @@ -54,7 +54,7 @@ public class RememberMeAuthenticationProviderTests { } @Test - public void testDetectsMissingKey() throws Exception { + public void testDetectsMissingKey() { try { new RememberMeAuthenticationProvider(null); fail("Should have thrown IllegalArgumentException"); @@ -73,7 +73,7 @@ public class RememberMeAuthenticationProviderTests { } @Test - public void testIgnoresClassesItDoesNotSupport() throws Exception { + public void testIgnoresClassesItDoesNotSupport() { RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider( "qwerty"); @@ -86,7 +86,7 @@ public class RememberMeAuthenticationProviderTests { } @Test - public void testNormalOperation() throws Exception { + public void testNormalOperation() { RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider( "qwerty"); diff --git a/core/src/test/java/org/springframework/security/concurrent/AbstractDelegatingSecurityContextExecutorServiceTests.java b/core/src/test/java/org/springframework/security/concurrent/AbstractDelegatingSecurityContextExecutorServiceTests.java index b099358a31..a88d1dadab 100644 --- a/core/src/test/java/org/springframework/security/concurrent/AbstractDelegatingSecurityContextExecutorServiceTests.java +++ b/core/src/test/java/org/springframework/security/concurrent/AbstractDelegatingSecurityContextExecutorServiceTests.java @@ -94,7 +94,7 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests exte } @Test - public void submitCallable() throws Exception { + public void submitCallable() { when(delegate.submit(wrappedCallable)).thenReturn(expectedFutureObject); Future result = executor.submit(callable); verify(delegate).submit(wrappedCallable); @@ -102,7 +102,7 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests exte } @Test - public void submitRunnableWithResult() throws Exception { + public void submitRunnableWithResult() { when(delegate.submit(wrappedRunnable, resultArg)) .thenReturn(expectedFutureObject); Future result = executor.submit(runnable, resultArg); @@ -112,7 +112,7 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests exte @Test @SuppressWarnings("unchecked") - public void submitRunnable() throws Exception { + public void submitRunnable() { when((Future) delegate.submit(wrappedRunnable)).thenReturn( expectedFutureObject); Future result = executor.submit(runnable); @@ -168,4 +168,4 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests exte } protected abstract DelegatingSecurityContextExecutorService create(); -} \ No newline at end of file +} diff --git a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java index 6858041035..0540b568a9 100644 --- a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java +++ b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java @@ -56,7 +56,7 @@ public class DelegatingSecurityContextRunnableTests { private SecurityContext originalSecurityContext; @Before - public void setUp() throws Exception { + public void setUp() { originalSecurityContext = SecurityContextHolder.createEmptyContext(); doAnswer((Answer) invocation -> { assertThat(SecurityContextHolder.getContext()).isEqualTo(securityContext); diff --git a/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java b/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java index 3cfe5d367d..27d137b690 100644 --- a/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java +++ b/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java @@ -59,7 +59,7 @@ public class SpringSecurityCoreVersionTests { } @Test - public void springVersionIsUpToDate() throws Exception { + public void springVersionIsUpToDate() { // Property is set by the build script String springVersion = System.getProperty("springVersion"); @@ -67,7 +67,7 @@ public class SpringSecurityCoreVersionTests { } @Test - public void serialVersionMajorAndMinorVersionMatchBuildVersion() throws Exception { + public void serialVersionMajorAndMinorVersionMatchBuildVersion() { String version = System.getProperty("springSecurityVersion"); // Strip patch version @@ -156,7 +156,7 @@ public class SpringSecurityCoreVersionTests { verifyZeroInteractions(logger); } - private String getDisableChecksProperty() throws Exception { + private String getDisableChecksProperty() { return SpringSecurityCoreVersion.class.getName().concat(".DISABLE_CHECKS"); } diff --git a/core/src/test/java/org/springframework/security/core/authority/SimpleGrantedAuthorityTests.java b/core/src/test/java/org/springframework/security/core/authority/SimpleGrantedAuthorityTests.java index 75dd614a73..ab065d1a9d 100644 --- a/core/src/test/java/org/springframework/security/core/authority/SimpleGrantedAuthorityTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/SimpleGrantedAuthorityTests.java @@ -30,7 +30,7 @@ import org.springframework.security.core.GrantedAuthority; public class SimpleGrantedAuthorityTests { @Test - public void equalsBehavesAsExpected() throws Exception { + public void equalsBehavesAsExpected() { SimpleGrantedAuthority auth1 = new SimpleGrantedAuthority("TEST"); assertThat(auth1).isEqualTo(auth1); assertThat(new SimpleGrantedAuthority("TEST")).isEqualTo(auth1); diff --git a/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleAuthoritiesMapperTests.java b/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleAuthoritiesMapperTests.java index 1cdf710697..c70474b70e 100644 --- a/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleAuthoritiesMapperTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleAuthoritiesMapperTests.java @@ -81,7 +81,7 @@ public class SimpleAuthoritiesMapperTests { } @Test - public void defaultAuthorityIsAssignedIfSet() throws Exception { + public void defaultAuthorityIsAssignedIfSet() { SimpleAuthorityMapper mapper = new SimpleAuthorityMapper(); mapper.setDefaultAuthority("ROLE_USER"); Set mapped = AuthorityUtils.authorityListToSet(mapper diff --git a/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java b/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java index d9824d448e..00a1b2cf6e 100644 --- a/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java +++ b/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java @@ -33,7 +33,7 @@ public class SecurityContextHolderTests { // ~ Methods // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { SecurityContextHolder .setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); } diff --git a/core/src/test/java/org/springframework/security/core/parameters/AnnotationParameterNameDiscovererTests.java b/core/src/test/java/org/springframework/security/core/parameters/AnnotationParameterNameDiscovererTests.java index e3b5cf5891..3627451887 100644 --- a/core/src/test/java/org/springframework/security/core/parameters/AnnotationParameterNameDiscovererTests.java +++ b/core/src/test/java/org/springframework/security/core/parameters/AnnotationParameterNameDiscovererTests.java @@ -89,7 +89,7 @@ public class AnnotationParameterNameDiscovererTests { } @Test - public void getParameterNamesClassAnnotationOnInterface() throws Exception { + public void getParameterNamesClassAnnotationOnInterface() { assertThat( discoverer.getParameterNames(ReflectionUtils.findMethod(DaoImpl.class, "findMessageByTo", String.class))).isEqualTo( @@ -101,7 +101,7 @@ public class AnnotationParameterNameDiscovererTests { } @Test - public void getParameterNamesClassAnnotationOnImpl() throws Exception { + public void getParameterNamesClassAnnotationOnImpl() { assertThat( discoverer.getParameterNames(ReflectionUtils.findMethod(Dao.class, "findMessageByToAndFrom", String.class, String.class))) @@ -113,7 +113,7 @@ public class AnnotationParameterNameDiscovererTests { } @Test - public void getParameterNamesClassAnnotationOnBaseClass() throws Exception { + public void getParameterNamesClassAnnotationOnBaseClass() { assertThat( discoverer.getParameterNames(ReflectionUtils.findMethod(Dao.class, "findMessageByIdNoAnnotation", String.class))).isNull(); diff --git a/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java b/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java index 3fc2dc6ed8..95ec0062e0 100644 --- a/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java +++ b/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java @@ -40,7 +40,7 @@ public class SessionRegistryImplTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { sessionRegistry = new SessionRegistryImpl(); } @@ -70,7 +70,7 @@ public class SessionRegistryImplTests { } @Test - public void testMultiplePrincipals() throws Exception { + public void testMultiplePrincipals() { Object principal1 = "principal_1"; Object principal2 = "principal_2"; String sessionId1 = "1234567890"; @@ -125,7 +125,7 @@ public class SessionRegistryImplTests { } @Test - public void testTwoSessionsOnePrincipalExpiring() throws Exception { + public void testTwoSessionsOnePrincipalExpiring() { Object principal = "Some principal object"; String sessionId1 = "1234567890"; String sessionId2 = "9876543210"; @@ -151,7 +151,7 @@ public class SessionRegistryImplTests { } @Test - public void testTwoSessionsOnePrincipalHandling() throws Exception { + public void testTwoSessionsOnePrincipalHandling() { Object principal = "Some principal object"; String sessionId1 = "1234567890"; String sessionId2 = "9876543210"; diff --git a/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java b/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java index dc81d2b977..00478f6474 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java @@ -54,7 +54,7 @@ public class UserTests { } @Test - public void hashLookupOnlyDependsOnUsername() throws Exception { + public void hashLookupOnlyDependsOnUsername() { User user1 = new User("rod", "koala", true, true, true, true, ROLE_12); Set users = new HashSet<>(); users.add(user1); @@ -80,7 +80,7 @@ public class UserTests { } @Test - public void testNullValuesRejected() throws Exception { + public void testNullValuesRejected() { try { new User(null, "koala", true, true, true, true, ROLE_12); fail("Should have thrown IllegalArgumentException"); @@ -106,7 +106,7 @@ public class UserTests { } @Test - public void testNullWithinGrantedAuthorityElementIsRejected() throws Exception { + public void testNullWithinGrantedAuthorityElementIsRejected() { try { List auths = AuthorityUtils.createAuthorityList("ROLE_ONE"); auths.add(null); @@ -119,7 +119,7 @@ public class UserTests { } @Test - public void testUserGettersSetter() throws Exception { + public void testUserGettersSetter() { UserDetails user = new User("rod", "koala", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_TWO", "ROLE_ONE")); assertThat(user.getUsername()).isEqualTo("rod"); @@ -133,7 +133,7 @@ public class UserTests { } @Test - public void enabledFlagIsFalseForDisabledAccount() throws Exception { + public void enabledFlagIsFalseForDisabledAccount() { UserDetails user = new User("rod", "koala", false, true, true, true, ROLE_12); assertThat(user.isEnabled()).isFalse(); } @@ -149,7 +149,7 @@ public class UserTests { } @Test - public void withUserDetailsWhenAllEnabled() throws Exception { + public void withUserDetailsWhenAllEnabled() { User expected = new User("rob", "pass", true, true, true, true, ROLE_12); UserDetails actual = User.withUserDetails(expected).build(); @@ -165,7 +165,7 @@ public class UserTests { @Test - public void withUserDetailsWhenAllDisabled() throws Exception { + public void withUserDetailsWhenAllDisabled() { User expected = new User("rob", "pass", false, false, false, false, ROLE_12); UserDetails actual = User.withUserDetails(expected).build(); diff --git a/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java b/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java index 5677fcc285..809edd2bca 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java @@ -38,7 +38,7 @@ public class NullUserCacheTests { } @Test - public void testCacheOperation() throws Exception { + public void testCacheOperation() { NullUserCache cache = new NullUserCache(); cache.putUserInCache(getUser()); assertThat(cache.getUserFromCache(null)).isNull(); diff --git a/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java b/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java index af8656ff6b..e7a479e2b6 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java @@ -42,7 +42,7 @@ public class JdbcDaoImplTests { // ~ Methods // ======================================================================================================== - private JdbcDaoImpl makePopulatedJdbcDao() throws Exception { + private JdbcDaoImpl makePopulatedJdbcDao() { JdbcDaoImpl dao = new JdbcDaoImpl(); dao.setDataSource(PopulatedDatabase.getDataSource()); dao.afterPropertiesSet(); @@ -50,7 +50,7 @@ public class JdbcDaoImplTests { return dao; } - private JdbcDaoImpl makePopulatedJdbcDaoWithRolePrefix() throws Exception { + private JdbcDaoImpl makePopulatedJdbcDaoWithRolePrefix() { JdbcDaoImpl dao = new JdbcDaoImpl(); dao.setDataSource(PopulatedDatabase.getDataSource()); dao.setRolePrefix("ARBITRARY_PREFIX_"); @@ -168,7 +168,7 @@ public class JdbcDaoImplTests { } @Test - public void testStartupFailsIfDataSourceNotSet() throws Exception { + public void testStartupFailsIfDataSourceNotSet() { JdbcDaoImpl dao = new JdbcDaoImpl(); try { @@ -181,7 +181,7 @@ public class JdbcDaoImplTests { } @Test - public void testStartupFailsIfUserMapSetToNull() throws Exception { + public void testStartupFailsIfUserMapSetToNull() { JdbcDaoImpl dao = new JdbcDaoImpl(); try { @@ -195,14 +195,14 @@ public class JdbcDaoImplTests { } @Test(expected = IllegalArgumentException.class) - public void setMessageSourceWhenNullThenThrowsException() throws Exception { + public void setMessageSourceWhenNullThenThrowsException() { JdbcDaoImpl dao = new JdbcDaoImpl(); dao.setMessageSource(null); } @Test - public void setMessageSourceWhenNotNullThenCanGet() throws Exception { + public void setMessageSourceWhenNotNullThenCanGet() { MessageSource source = mock(MessageSource.class); JdbcDaoImpl dao = new JdbcDaoImpl(); dao.setMessageSource(source); diff --git a/core/src/test/java/org/springframework/security/jackson2/RememberMeAuthenticationTokenMixinTests.java b/core/src/test/java/org/springframework/security/jackson2/RememberMeAuthenticationTokenMixinTests.java index 53edef1170..41a54b17c4 100644 --- a/core/src/test/java/org/springframework/security/jackson2/RememberMeAuthenticationTokenMixinTests.java +++ b/core/src/test/java/org/springframework/security/jackson2/RememberMeAuthenticationTokenMixinTests.java @@ -60,12 +60,12 @@ public class RememberMeAuthenticationTokenMixinTests extends AbstractMixinTests // @formatter:on @Test(expected = IllegalArgumentException.class) - public void testWithNullPrincipal() throws JsonProcessingException, JSONException { + public void testWithNullPrincipal() { new RememberMeAuthenticationToken("key", null, Collections.emptyList()); } @Test(expected = IllegalArgumentException.class) - public void testWithNullKey() throws JsonProcessingException, JSONException { + public void testWithNullKey() { new RememberMeAuthenticationToken(null, "principal", Collections.emptyList()); } diff --git a/core/src/test/java/org/springframework/security/jackson2/SecurityJackson2ModulesTests.java b/core/src/test/java/org/springframework/security/jackson2/SecurityJackson2ModulesTests.java index ef21ef9ffe..da7aac86f0 100644 --- a/core/src/test/java/org/springframework/security/jackson2/SecurityJackson2ModulesTests.java +++ b/core/src/test/java/org/springframework/security/jackson2/SecurityJackson2ModulesTests.java @@ -44,7 +44,7 @@ public class SecurityJackson2ModulesTests { } @Test - public void readValueWhenNotWhitelistedOrMappedThenThrowsException() throws Exception { + public void readValueWhenNotWhitelistedOrMappedThenThrowsException() { String content = "{\"@class\":\"org.springframework.security.jackson2.SecurityJackson2ModulesTests$NotWhitelisted\",\"property\":\"bar\"}"; assertThatThrownBy(() -> { mapper.readValue(content, Object.class); diff --git a/core/src/test/java/org/springframework/security/jackson2/UsernamePasswordAuthenticationTokenMixinTests.java b/core/src/test/java/org/springframework/security/jackson2/UsernamePasswordAuthenticationTokenMixinTests.java index 3275e92974..505c34b3ce 100644 --- a/core/src/test/java/org/springframework/security/jackson2/UsernamePasswordAuthenticationTokenMixinTests.java +++ b/core/src/test/java/org/springframework/security/jackson2/UsernamePasswordAuthenticationTokenMixinTests.java @@ -93,7 +93,7 @@ public class UsernamePasswordAuthenticationTokenMixinTests extends AbstractMixin } @Test - public void deserializeUnauthenticatedUsernamePasswordAuthenticationTokenMixinTest() throws IOException, JSONException { + public void deserializeUnauthenticatedUsernamePasswordAuthenticationTokenMixinTest() throws IOException { UsernamePasswordAuthenticationToken token = mapper .readValue(UNAUTHENTICATED_STRINGPRINCIPAL_JSON, UsernamePasswordAuthenticationToken.class); assertThat(token).isNotNull(); diff --git a/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java b/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java index b60826f0da..ebced08d6e 100644 --- a/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java +++ b/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java @@ -290,7 +290,7 @@ public class JdbcUserDetailsManagerTests { } @Test - public void deleteGroupRemovesData() throws Exception { + public void deleteGroupRemovesData() { manager.deleteGroup("GROUP_0"); manager.deleteGroup("GROUP_1"); manager.deleteGroup("GROUP_2"); @@ -302,7 +302,7 @@ public class JdbcUserDetailsManagerTests { } @Test - public void renameGroupIsSuccessful() throws Exception { + public void renameGroupIsSuccessful() { manager.renameGroup("GROUP_0", "GROUP_X"); assertThat(template.queryForObject("select id from groups where group_name = 'GROUP_X'", @@ -310,7 +310,7 @@ public class JdbcUserDetailsManagerTests { } @Test - public void addingGroupUserSetsCorrectData() throws Exception { + public void addingGroupUserSetsCorrectData() { manager.addUserToGroup("tom", "GROUP_0"); assertThat( @@ -319,7 +319,7 @@ public class JdbcUserDetailsManagerTests { } @Test - public void removeUserFromGroupDeletesGroupMemberRow() throws Exception { + public void removeUserFromGroupDeletesGroupMemberRow() { manager.removeUserFromGroup("jerry", "GROUP_1"); assertThat( @@ -328,12 +328,12 @@ public class JdbcUserDetailsManagerTests { } @Test - public void findGroupAuthoritiesReturnsCorrectAuthorities() throws Exception { + public void findGroupAuthoritiesReturnsCorrectAuthorities() { assertThat(AuthorityUtils.createAuthorityList("ROLE_A")).isEqualTo(manager.findGroupAuthorities("GROUP_0")); } @Test - public void addGroupAuthorityInsertsCorrectGroupAuthorityRow() throws Exception { + public void addGroupAuthorityInsertsCorrectGroupAuthorityRow() { GrantedAuthority auth = new SimpleGrantedAuthority("ROLE_X"); manager.addGroupAuthority("GROUP_0", auth); @@ -343,7 +343,7 @@ public class JdbcUserDetailsManagerTests { } @Test - public void deleteGroupAuthorityRemovesCorrectRows() throws Exception { + public void deleteGroupAuthorityRemovesCorrectRows() { GrantedAuthority auth = new SimpleGrantedAuthority("ROLE_A"); manager.removeGroupAuthority("GROUP_0", auth); assertThat( @@ -358,8 +358,7 @@ public class JdbcUserDetailsManagerTests { // SEC-1156 @Test - public void createUserDoesNotSaveAuthoritiesIfEnableAuthoritiesIsFalse() - throws Exception { + public void createUserDoesNotSaveAuthoritiesIfEnableAuthoritiesIsFalse() { manager.setEnableAuthorities(false); manager.createUser(joe); assertThat(template.queryForList(SELECT_JOE_AUTHORITIES_SQL)).isEmpty(); @@ -367,8 +366,7 @@ public class JdbcUserDetailsManagerTests { // SEC-1156 @Test - public void updateUserDoesNotSaveAuthoritiesIfEnableAuthoritiesIsFalse() - throws Exception { + public void updateUserDoesNotSaveAuthoritiesIfEnableAuthoritiesIsFalse() { manager.setEnableAuthorities(false); insertJoe(); template.execute("delete from authorities where username='joe'"); diff --git a/core/src/test/java/org/springframework/security/util/InMemoryResourceTests.java b/core/src/test/java/org/springframework/security/util/InMemoryResourceTests.java index a7ee355f80..b1b7fe8098 100644 --- a/core/src/test/java/org/springframework/security/util/InMemoryResourceTests.java +++ b/core/src/test/java/org/springframework/security/util/InMemoryResourceTests.java @@ -33,7 +33,7 @@ public class InMemoryResourceTests { } @Test - public void resourceIsEqualToOneWithSameContent() throws Exception { + public void resourceIsEqualToOneWithSameContent() { assertThat(new InMemoryResource("xxx")).isEqualTo(new InMemoryResource("xxx")); assertThat(new InMemoryResource("xxx").equals(new InMemoryResource("xxxx"))).isFalse(); assertThat(new InMemoryResource("xxx").equals(new Object())).isFalse(); diff --git a/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java b/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java index d832938494..2c055d33a3 100644 --- a/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java +++ b/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java @@ -60,7 +60,7 @@ public class MethodInvocationUtilsTests { } @Test - public void createFromObjectLocatesExistingMethods() throws Exception { + public void createFromObjectLocatesExistingMethods() { AdvisedTarget t = new AdvisedTarget(); // Just lie about interfaces t.setInterfaces(new Class[] { Serializable.class, MethodInvocation.class, diff --git a/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2EncodingUtilsTests.java b/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2EncodingUtilsTests.java index 41bc1d5a24..660bd5347f 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2EncodingUtilsTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2EncodingUtilsTests.java @@ -45,24 +45,24 @@ public class Argon2EncodingUtilsTests { )); @Test - public void decodeWhenValidEncodedHashWithIThenDecodeCorrectly() throws Exception { + public void decodeWhenValidEncodedHashWithIThenDecodeCorrectly() { assertArgon2HashEquals(testDataEntry1.decoded, Argon2EncodingUtils.decode(testDataEntry1.encoded)); } @Test - public void decodeWhenValidEncodedHashWithIDThenDecodeCorrectly() throws Exception { + public void decodeWhenValidEncodedHashWithIDThenDecodeCorrectly() { assertArgon2HashEquals(testDataEntry2.decoded, Argon2EncodingUtils.decode(testDataEntry2.encoded)); } @Test - public void encodeWhenValidArgumentsWithIThenEncodeToCorrectHash() throws Exception { + public void encodeWhenValidArgumentsWithIThenEncodeToCorrectHash() { assertThat(Argon2EncodingUtils .encode(testDataEntry1.decoded.getHash(), testDataEntry1.decoded.getParameters())) .isEqualTo(testDataEntry1.encoded); } @Test - public void encodeWhenValidArgumentsWithID2ThenEncodeToCorrectHash() throws Exception { + public void encodeWhenValidArgumentsWithID2ThenEncodeToCorrectHash() { assertThat(Argon2EncodingUtils .encode(testDataEntry2.decoded.getHash(), testDataEntry2.decoded.getParameters())) .isEqualTo(testDataEntry2.encoded); diff --git a/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2PasswordEncoderTests.java b/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2PasswordEncoderTests.java index a63cb5ed12..229b43227f 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2PasswordEncoderTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/argon2/Argon2PasswordEncoderTests.java @@ -128,14 +128,14 @@ public class Argon2PasswordEncoderTests { } @Test - public void upgradeEncodingWhenSameEncodingThenFalse() throws Exception { + public void upgradeEncodingWhenSameEncodingThenFalse() { String hash = encoder.encode("password"); assertThat(encoder.upgradeEncoding(hash)).isFalse(); } @Test - public void upgradeEncodingWhenSameStandardParamsThenFalse() throws Exception { + public void upgradeEncodingWhenSameStandardParamsThenFalse() { Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(); String hash = encoder.encode("password"); @@ -144,7 +144,7 @@ public class Argon2PasswordEncoderTests { } @Test - public void upgradeEncodingWhenSameCustomParamsThenFalse() throws Exception { + public void upgradeEncodingWhenSameCustomParamsThenFalse() { Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4); Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4); @@ -154,7 +154,7 @@ public class Argon2PasswordEncoderTests { } @Test - public void upgradeEncodingWhenHashHasLowerMemoryThenTrue() throws Exception { + public void upgradeEncodingWhenHashHasLowerMemoryThenTrue() { Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4); Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 512, 4); @@ -164,7 +164,7 @@ public class Argon2PasswordEncoderTests { } @Test - public void upgradeEncodingWhenHashHasLowerIterationsThenTrue() throws Exception { + public void upgradeEncodingWhenHashHasLowerIterationsThenTrue() { Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4); Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 5); @@ -174,7 +174,7 @@ public class Argon2PasswordEncoderTests { } @Test - public void upgradeEncodingWhenHashHasHigherParamsThenFalse() throws Exception { + public void upgradeEncodingWhenHashHasHigherParamsThenFalse() { Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4); Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 128, 3); diff --git a/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorEquivalencyTest.java b/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorEquivalencyTest.java index cb6e12a052..664b45051b 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorEquivalencyTest.java +++ b/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorEquivalencyTest.java @@ -83,8 +83,7 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTest { testCompatibility(bcEncryptor, jceEncryptor); } - private void testEquivalence(BytesEncryptor left, BytesEncryptor right) - throws Exception { + private void testEquivalence(BytesEncryptor left, BytesEncryptor right) { for (int size = 1; size < 2048; size++) { testData = new byte[size]; secureRandom.nextBytes(testData); @@ -101,8 +100,7 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTest { } - private void testCompatibility(BytesEncryptor left, BytesEncryptor right) - throws Exception { + private void testCompatibility(BytesEncryptor left, BytesEncryptor right) { // tests that right can decrypt what left encrypted and vice versa // and that the decypted data is the same as the original for (int size = 1; size < 2048; size++) { diff --git a/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorTest.java b/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorTest.java index 9012d75c7e..3efe507387 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorTest.java +++ b/crypto/src/test/java/org/springframework/security/crypto/encrypt/BouncyCastleAesBytesEncryptorTest.java @@ -44,13 +44,13 @@ public class BouncyCastleAesBytesEncryptorTest { } @Test - public void bcCbcWithSecureIvGeneratesDifferentMessages() throws Exception { + public void bcCbcWithSecureIvGeneratesDifferentMessages() { BytesEncryptor bcEncryptor = new BouncyCastleAesCbcBytesEncryptor(password, salt); generatesDifferentCipherTexts(bcEncryptor); } @Test - public void bcGcmWithSecureIvGeneratesDifferentMessages() throws Exception { + public void bcGcmWithSecureIvGeneratesDifferentMessages() { BytesEncryptor bcEncryptor = new BouncyCastleAesGcmBytesEncryptor(password, salt); generatesDifferentCipherTexts(bcEncryptor); } @@ -66,13 +66,13 @@ public class BouncyCastleAesBytesEncryptorTest { } @Test(expected = IllegalArgumentException.class) - public void bcCbcWithWrongLengthIv() throws Exception { + public void bcCbcWithWrongLengthIv() { new BouncyCastleAesCbcBytesEncryptor(password, salt, KeyGenerators.secureRandom(8)); } @Test(expected = IllegalArgumentException.class) - public void bcGcmWithWrongLengthIv() throws Exception { + public void bcGcmWithWrongLengthIv() { new BouncyCastleAesGcmBytesEncryptor(password, salt, KeyGenerators.secureRandom(8)); } diff --git a/crypto/src/test/java/org/springframework/security/crypto/keygen/KeyGeneratorsTests.java b/crypto/src/test/java/org/springframework/security/crypto/keygen/KeyGeneratorsTests.java index 3b3c519ac8..665323fe2e 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/keygen/KeyGeneratorsTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/keygen/KeyGeneratorsTests.java @@ -45,7 +45,7 @@ public class KeyGeneratorsTests { } @Test - public void shared() throws Exception { + public void shared() { BytesKeyGenerator keyGenerator = KeyGenerators.shared(21); assertThat(keyGenerator.getKeyLength()).isEqualTo(21); byte[] key = keyGenerator.generateKey(); diff --git a/crypto/src/test/java/org/springframework/security/crypto/password/LdapShaPasswordEncoderTests.java b/crypto/src/test/java/org/springframework/security/crypto/password/LdapShaPasswordEncoderTests.java index bb5fd2558d..36e900aabf 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/password/LdapShaPasswordEncoderTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/password/LdapShaPasswordEncoderTests.java @@ -75,7 +75,7 @@ public class LdapShaPasswordEncoderTests { @Test // SEC-1031 - public void fullLengthOfHashIsUsedInComparison() throws Exception { + public void fullLengthOfHashIsUsedInComparison() { assertThat(this.sha.matches("boabspasswurd", "{SSHA}25ro4PKC8jhQZ26jVsozhX/xaP0suHgX")).isTrue(); // Change the first hash character from '2' to '3' assertThat(this.sha.matches("boabspasswurd", "{SSHA}35ro4PKC8jhQZ26jVsozhX/xaP0suHgX")).isFalse(); diff --git a/crypto/src/test/java/org/springframework/security/crypto/password/MessageDigestPasswordEncoderTests.java b/crypto/src/test/java/org/springframework/security/crypto/password/MessageDigestPasswordEncoderTests.java index d1087c4f42..60d3001959 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/password/MessageDigestPasswordEncoderTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/password/MessageDigestPasswordEncoderTests.java @@ -43,7 +43,7 @@ public class MessageDigestPasswordEncoderTests { } @Test - public void md5NonAsciiPasswordHasCorrectHash() throws Exception { + public void md5NonAsciiPasswordHasCorrectHash() { MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5"); // $ echo -n "??" | md5 // 7eca689f0d3389d9dea66ae112e5cfd7 @@ -51,14 +51,14 @@ public class MessageDigestPasswordEncoderTests { } @Test - public void md5Base64() throws Exception { + public void md5Base64() { MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5"); pe.setEncodeHashAsBase64(true); assertThat(pe.matches("abc123", "{THIS_IS_A_SALT}poqv2QKZ0LE33ij7S7aFcw==")).isTrue(); } @Test - public void md5StretchFactorIsProcessedCorrectly() throws Exception { + public void md5StretchFactorIsProcessedCorrectly() { MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5"); pe.setIterations(2); // Calculate value using: @@ -101,7 +101,7 @@ public class MessageDigestPasswordEncoderTests { } @Test - public void testBase64() throws Exception { + public void testBase64() { MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("SHA-1"); pe.setEncodeHashAsBase64(true); String raw = "abc123"; @@ -109,14 +109,14 @@ public class MessageDigestPasswordEncoderTests { } @Test - public void test256() throws Exception { + public void test256() { MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("SHA-1"); String raw = "abc123"; assertThat(pe.matches(raw, "{THIS_IS_A_SALT}4b79b7de23eb23b78cc5ede227d532b8a51f89b2ec166f808af76b0dbedc47d7")); } @Test(expected = IllegalStateException.class) - public void testInvalidStrength() throws Exception { + public void testInvalidStrength() { new MessageDigestPasswordEncoder("SHA-666"); } } diff --git a/itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java index 55665855bb..724790c65a 100644 --- a/itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java +++ b/itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java @@ -90,13 +90,13 @@ public class MultiAnnotationTests { } @Test(expected = AccessDeniedException.class) - public void preAuthorizedOnlyServiceDeniesIfRoleMissing() throws Exception { + public void preAuthorizedOnlyServiceDeniesIfRoleMissing() { SecurityContextHolder.getContext().setAuthentication(joe_b); preService.preAuthorizedMethod(); } @Test(expected = AccessDeniedException.class) - public void securedOnlyRoleAServiceDeniesIfRoleMissing() throws Exception { + public void securedOnlyRoleAServiceDeniesIfRoleMissing() { SecurityContextHolder.getContext().setAuthentication(joe_b); secService.securedMethod(); } diff --git a/itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java index fc1e6d5555..00c4fc62e2 100644 --- a/itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java +++ b/itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java @@ -32,7 +32,7 @@ public class SEC933ApplicationContextTests { private UserDetailsService userDetailsService; @Test - public void testSimpleApplicationContextBootstrap() throws Exception { + public void testSimpleApplicationContextBootstrap() { assertThat(userDetailsService).isNotNull(); } } diff --git a/itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java index 3d57302eeb..df288f1f4e 100644 --- a/itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java +++ b/itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java @@ -31,7 +31,7 @@ public class PythonInterpreterBasedSecurityTests { private TestService service; @Test - public void serviceMethod() throws Exception { + public void serviceMethod() { SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken("bob", "bobspassword")); diff --git a/itest/web/src/integration-test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java b/itest/web/src/integration-test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java index 26e08e7a7d..2d61b7ee89 100644 --- a/itest/web/src/integration-test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java +++ b/itest/web/src/integration-test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java @@ -42,7 +42,7 @@ public abstract class AbstractWebServerIntegrationTests { } } - protected final MockMvc createMockMvc(String... configLocations) throws Exception { + protected final MockMvc createMockMvc(String... configLocations) { if (this.context != null) { throw new IllegalStateException("context is already loaded"); } diff --git a/itest/web/src/main/java/org/springframework/security/itest/web/TestController.java b/itest/web/src/main/java/org/springframework/security/itest/web/TestController.java index b75c1bdb5d..baf970439e 100644 --- a/itest/web/src/main/java/org/springframework/security/itest/web/TestController.java +++ b/itest/web/src/main/java/org/springframework/security/itest/web/TestController.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController; public class TestController { @RequestMapping(value = "/secure/file?with?special?chars.htm", method = RequestMethod.GET) - public String sec1255TestUrl() throws IOException { + public String sec1255TestUrl() { return "I'm file?with?special?chars.htm"; } diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java index dd31381ff0..e2da339fcf 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java @@ -58,8 +58,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test - public void poolingFlagIsSetWhenAuthenticationDnMatchesManagerUserDn() - throws Exception { + public void poolingFlagIsSetWhenAuthenticationDnMatchesManagerUserDn() { EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource( "ldap://blah:789/dc=springframework,dc=org"); ctxSrc.setUserDn("manager"); @@ -70,8 +69,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test - public void poolingFlagIsNotSetWhenAuthenticationDnIsNotManagerUserDn() - throws Exception { + public void poolingFlagIsNotSetWhenAuthenticationDnIsNotManagerUserDn() { EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource( "ldap://blah:789/dc=springframework,dc=org"); ctxSrc.setUserDn("manager"); @@ -103,7 +101,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test - public void serverUrlWithSpacesIsSupported() throws Exception { + public void serverUrlWithSpacesIsSupported() { DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource( this.contextSource.getUrls()[0] + "ou=space%20cadets,dc=springframework,dc=org"); @@ -114,7 +112,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test(expected = IllegalArgumentException.class) - public void instantiationFailsWithEmptyServerList() throws Exception { + public void instantiationFailsWithEmptyServerList() { List serverUrls = new ArrayList<>(); DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource( serverUrls, "dc=springframework,dc=org"); @@ -122,7 +120,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test - public void instantiationSuceedsWithProperServerList() throws Exception { + public void instantiationSuceedsWithProperServerList() { List serverUrls = new ArrayList<>(); serverUrls.add("ldap://foo:789"); serverUrls.add("ldap://bar:389"); @@ -136,7 +134,7 @@ public class DefaultSpringSecurityContextSourceTests { // SEC-2308 @Test - public void instantiationSuceedsWithEmtpyBaseDn() throws Exception { + public void instantiationSuceedsWithEmtpyBaseDn() { String baseDn = ""; List serverUrls = new ArrayList<>(); serverUrls.add("ldap://foo:789"); @@ -150,7 +148,7 @@ public class DefaultSpringSecurityContextSourceTests { } @Test(expected = IllegalArgumentException.class) - public void instantiationFailsWithIncorrectServerUrl() throws Exception { + public void instantiationFailsWithIncorrectServerUrl() { List serverUrls = new ArrayList<>(); // a simple trailing slash should be ok serverUrls.add("ldaps://blah:636/"); diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateITests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateITests.java index d5feae767d..697a9f9bfb 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateITests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateITests.java @@ -56,7 +56,7 @@ public class SpringSecurityLdapTemplateITests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { template = new SpringSecurityLdapTemplate(this.contextSource); } @@ -181,7 +181,7 @@ public class SpringSecurityLdapTemplateITests { } @Test - public void roleSearchWithEscapedCharacterSucceeds() throws Exception { + public void roleSearchWithEscapedCharacterSucceeds() { String param = "cn=mouse\\, jerry,ou=people,dc=springframework,dc=org"; Set values = template.searchForSingleAttributeValues("ou=groups", diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java index 6ec4df43ee..1fe8f97f8f 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java @@ -59,7 +59,7 @@ public class PasswordComparisonAuthenticatorTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { authenticator = new PasswordComparisonAuthenticator(this.contextSource); authenticator.setPasswordEncoder(NoOpPasswordEncoder.getInstance()); authenticator.setUserDnPatterns(new String[] { "uid={0},ou=people" }); @@ -106,7 +106,7 @@ public class PasswordComparisonAuthenticatorTests { } @Test - public void testOnlySpecifiedAttributesAreRetrieved() throws Exception { + public void testOnlySpecifiedAttributesAreRetrieved() { authenticator.setUserAttributes(new String[] { "uid", "userPassword" }); DirContextAdapter user = (DirContextAdapter) authenticator.authenticate(bob); diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java index 6b9f5e36ba..789e89f4ee 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java @@ -73,7 +73,7 @@ public class FilterBasedLdapUserSearchTests { // Try some funny business with filters. @Test - public void extraFilterPartToExcludeBob() throws Exception { + public void extraFilterPartToExcludeBob() { FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch( "ou=people", "(&(cn=*)(!(|(uid={0})(uid=rod)(uid=jerry)(uid=slashguy)(uid=javadude)(uid=groovydude)(uid=closuredude)(uid=scaladude))))", @@ -112,7 +112,7 @@ public class FilterBasedLdapUserSearchTests { } @Test - public void searchWithDifferentSearchBaseIsSuccessful() throws Exception { + public void searchWithDifferentSearchBaseIsSuccessful() { FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch( "ou=otherpeople", "(cn={0})", this.contextSource); DirContextOperations joe = locator.searchForUser("Joe Smeth"); diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSEmbeddedLdifTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSEmbeddedLdifTests.java index 876b7eb8f5..09556a01bb 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSEmbeddedLdifTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSEmbeddedLdifTests.java @@ -50,7 +50,7 @@ public class ApacheDSEmbeddedLdifTests { this.ldapTemplate = new SpringSecurityLdapTemplate(createLdapContextSource()); } - private LdapContextSource createLdapContextSource() throws Exception { + private LdapContextSource createLdapContextSource() { LdapContextSource ldapContextSource = new LdapContextSource(); ldapContextSource.setUrl("ldap://localhost:" + LDAP_PORT); ldapContextSource.setBase(LDAP_ROOT); diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java index ed5c9e9875..b96a69738e 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java @@ -52,7 +52,7 @@ public class DefaultLdapAuthoritiesPopulatorTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, "ou=groups"); populator.setIgnorePartialResultException(false); } @@ -72,7 +72,7 @@ public class DefaultLdapAuthoritiesPopulatorTests { } @Test - public void nullSearchBaseIsAccepted() throws Exception { + public void nullSearchBaseIsAccepted() { populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, null); populator.setDefaultRole("ROLE_USER"); @@ -154,7 +154,7 @@ public class DefaultLdapAuthoritiesPopulatorTests { } @Test - public void extraRolesAreAdded() throws Exception { + public void extraRolesAreAdded() { populator = new DefaultLdapAuthoritiesPopulator(this.contextSource, null) { @Override protected Set getAdditionalRoles(DirContextOperations user, diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java index 1dd6e7c317..eaf24d8b25 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java @@ -60,7 +60,7 @@ public class LdapUserDetailsManagerTests { private SpringSecurityLdapTemplate template; @Before - public void setUp() throws Exception { + public void setUp() { mgr = new LdapUserDetailsManager(this.contextSource); template = new SpringSecurityLdapTemplate(this.contextSource); DirContextAdapter ctx = new DirContextAdapter(); @@ -91,7 +91,7 @@ public class LdapUserDetailsManagerTests { } @After - public void onTearDown() throws Exception { + public void onTearDown() { // Iterator people = template.list("ou=testpeople").iterator(); // DirContext rootCtx = new DirContextAdapter(new diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulatorTests.java index 43ac398eae..70ff12f642 100644 --- a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulatorTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulatorTests.java @@ -55,7 +55,7 @@ public class NestedLdapAuthoritiesPopulatorTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { populator = new NestedLdapAuthoritiesPopulator(this.contextSource, "ou=jdeveloper"); populator.setGroupSearchFilter("(member={0})"); diff --git a/ldap/src/main/java/org/springframework/security/ldap/authentication/AbstractLdapAuthenticator.java b/ldap/src/main/java/org/springframework/security/ldap/authentication/AbstractLdapAuthenticator.java index a85be6a633..0fb836a6ae 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/authentication/AbstractLdapAuthenticator.java +++ b/ldap/src/main/java/org/springframework/security/ldap/authentication/AbstractLdapAuthenticator.java @@ -75,7 +75,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.isTrue((userDnFormat != null) || (userSearch != null), "Either an LdapUserSearch or DN pattern (or both) must be supplied."); } diff --git a/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java b/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java index a25dda711d..9aad174975 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java +++ b/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java @@ -153,7 +153,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life start(); } - public void destroy() throws Exception { + public void destroy() { stop(); } diff --git a/ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java b/ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java index bf9b7b4820..a533b029cb 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java +++ b/ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java @@ -66,12 +66,12 @@ public class UnboundIdContainer implements InitializingBean, DisposableBean, Lif } @Override - public void destroy() throws Exception { + public void destroy() { stop(); } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { start(); } diff --git a/ldap/src/test/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProviderTests.java b/ldap/src/test/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProviderTests.java index 0241f08b15..934b507d05 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProviderTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProviderTests.java @@ -66,13 +66,13 @@ public class ActiveDirectoryLdapAuthenticationProviderTests { "joe", "password"); @Before - public void setUp() throws Exception { + public void setUp() { provider = new ActiveDirectoryLdapAuthenticationProvider("mydomain.eu", "ldap://192.168.1.200/"); } @Test - public void bindPrincipalIsCreatedCorrectly() throws Exception { + public void bindPrincipalIsCreatedCorrectly() { assertThat(provider.createBindPrincipal("joe")).isEqualTo("joe@mydomain.eu"); assertThat(provider.createBindPrincipal("joe@mydomain.eu")).isEqualTo("joe@mydomain.eu"); } @@ -370,7 +370,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests { } @Test(expected = BadCredentialsException.class) - public void errorWithNoSubcodeIsHandledCleanly() throws Exception { + public void errorWithNoSubcodeIsHandledCleanly() { provider.contextFactory = createContextFactoryThrowing(new AuthenticationException( msg)); provider.setConvertSubErrorCodesToExceptions(true); @@ -378,8 +378,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests { } @Test(expected = org.springframework.ldap.CommunicationException.class) - public void nonAuthenticationExceptionIsConvertedToSpringLdapException() - throws Exception { + public void nonAuthenticationExceptionIsConvertedToSpringLdapException() { provider.contextFactory = createContextFactoryThrowing(new CommunicationException( msg)); provider.authenticate(joe); @@ -404,7 +403,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests { } @Test - public void contextEnvironmentPropertiesUsed() throws Exception { + public void contextEnvironmentPropertiesUsed() { Hashtable env = new Hashtable<>(); env.put("java.naming.ldap.factory.socket", "unknown.package.NonExistingSocketFactory"); @@ -431,7 +430,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests { ContextFactory createContextFactoryReturning(final DirContext ctx) { return new ContextFactory() { @Override - DirContext createContext(Hashtable env) throws NamingException { + DirContext createContext(Hashtable env) { return ctx; } }; diff --git a/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyAwareContextSourceTests.java b/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyAwareContextSourceTests.java index 5cd0b7701f..fbe36fc031 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyAwareContextSourceTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyAwareContextSourceTests.java @@ -36,7 +36,7 @@ public class PasswordPolicyAwareContextSourceTests { private final LdapContext ctx = mock(LdapContext.class); @Before - public void setUp() throws Exception { + public void setUp() { reset(ctx); ctxSource = new PasswordPolicyAwareContextSource( "ldap://blah:789/dc=springframework,dc=org") { @@ -55,8 +55,7 @@ public class PasswordPolicyAwareContextSourceTests { } @Test - public void contextIsReturnedWhenNoControlsAreSetAndReconnectIsSuccessful() - throws Exception { + public void contextIsReturnedWhenNoControlsAreSetAndReconnectIsSuccessful() { assertThat(ctxSource.getContext("user", "ignored")).isNotNull(); } diff --git a/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyControlFactoryTests.java b/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyControlFactoryTests.java index b042a842ae..c29f13b34f 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyControlFactoryTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/ppolicy/PasswordPolicyControlFactoryTests.java @@ -28,7 +28,7 @@ import javax.naming.ldap.Control; public class PasswordPolicyControlFactoryTests { @Test - public void returnsNullForUnrecognisedOID() throws Exception { + public void returnsNullForUnrecognisedOID() { PasswordPolicyControlFactory ctrlFactory = new PasswordPolicyControlFactory(); Control wrongCtrl = mock(Control.class); @@ -37,7 +37,7 @@ public class PasswordPolicyControlFactoryTests { } @Test - public void returnsControlForCorrectOID() throws Exception { + public void returnsControlForCorrectOID() { PasswordPolicyControlFactory ctrlFactory = new PasswordPolicyControlFactory(); Control control = mock(Control.class); diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/InetOrgPersonTests.java b/ldap/src/test/java/org/springframework/security/ldap/userdetails/InetOrgPersonTests.java index ad22b3d619..168f725460 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/userdetails/InetOrgPersonTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/userdetails/InetOrgPersonTests.java @@ -38,7 +38,7 @@ public class InetOrgPersonTests { } @Test - public void hashLookupViaEqualObjectRetrievesOriginal() throws Exception { + public void hashLookupViaEqualObjectRetrievesOriginal() { InetOrgPerson.Essence essence = new InetOrgPerson.Essence(createUserContext()); InetOrgPerson p = (InetOrgPerson) essence.createUserDetails(); essence = new InetOrgPerson.Essence(createUserContext()); diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapAuthorityTests.java b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapAuthorityTests.java index 237543a39d..c6727986c7 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapAuthorityTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapAuthorityTests.java @@ -44,7 +44,7 @@ public class LdapAuthorityTests { } @Test - public void testGetDn() throws Exception { + public void testGetDn() { assertThat(authority.getDn()).isEqualTo(DN); assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).isNotNull(); assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).hasSize(1); @@ -52,7 +52,7 @@ public class LdapAuthorityTests { } @Test - public void testGetAttributes() throws Exception { + public void testGetAttributes() { assertThat(authority.getAttributes()).isNotNull(); assertThat(authority.getAttributeValues("mail")).isNotNull(); assertThat(authority.getAttributeValues("mail")).hasSize(2); @@ -62,7 +62,7 @@ public class LdapAuthorityTests { } @Test - public void testGetAuthority() throws Exception { + public void testGetAuthority() { assertThat(authority.getAuthority()).isNotNull(); assertThat(authority.getAuthority()).isEqualTo("testRole"); } diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsMapperTests.java b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsMapperTests.java index 88d0c4f77d..1c8ca9e384 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsMapperTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsMapperTests.java @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class LdapUserDetailsMapperTests { @Test - public void testMultipleRoleAttributeValuesAreMappedToAuthorities() throws Exception { + public void testMultipleRoleAttributeValuesAreMappedToAuthorities() { LdapUserDetailsMapper mapper = new LdapUserDetailsMapper(); mapper.setConvertToUpperCase(false); mapper.setRolePrefix(""); @@ -58,7 +58,7 @@ public class LdapUserDetailsMapperTests { * SEC-303. Non-retrieved role attribute causes NullPointerException */ @Test - public void testNonRetrievedRoleAttributeIsIgnored() throws Exception { + public void testNonRetrievedRoleAttributeIsIgnored() { LdapUserDetailsMapper mapper = new LdapUserDetailsMapper(); mapper.setRoleAttributes(new String[] { "userRole", "nonRetrievedAttribute" }); @@ -78,7 +78,7 @@ public class LdapUserDetailsMapperTests { } @Test - public void testPasswordAttributeIsMappedCorrectly() throws Exception { + public void testPasswordAttributeIsMappedCorrectly() { LdapUserDetailsMapper mapper = new LdapUserDetailsMapper(); mapper.setPasswordAttributeName("myappsPassword"); diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsServiceTests.java b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsServiceTests.java index 38e2e4c29c..d8ff18881a 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsServiceTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsServiceTests.java @@ -65,7 +65,7 @@ public class LdapUserDetailsServiceTests { } @Test - public void nullPopulatorConstructorReturnsEmptyAuthoritiesList() throws Exception { + public void nullPopulatorConstructorReturnsEmptyAuthoritiesList() { DirContextAdapter userData = new DirContextAdapter(new DistinguishedName( "uid=joe")); diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/UserDetailsServiceLdapAuthoritiesPopulatorTests.java b/ldap/src/test/java/org/springframework/security/ldap/userdetails/UserDetailsServiceLdapAuthoritiesPopulatorTests.java index 7aa4a1f7c7..083f91c32d 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/userdetails/UserDetailsServiceLdapAuthoritiesPopulatorTests.java +++ b/ldap/src/test/java/org/springframework/security/ldap/userdetails/UserDetailsServiceLdapAuthoritiesPopulatorTests.java @@ -35,7 +35,7 @@ import org.springframework.security.ldap.authentication.UserDetailsServiceLdapAu public class UserDetailsServiceLdapAuthoritiesPopulatorTests { @Test - public void delegationToUserDetailsServiceReturnsCorrectRoles() throws Exception { + public void delegationToUserDetailsServiceReturnsCorrectRoles() { UserDetailsService uds = mock(UserDetailsService.class); UserDetails user = mock(UserDetails.class); when(uds.loadUserByUsername("joe")).thenReturn(user); diff --git a/messaging/src/main/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolver.java b/messaging/src/main/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolver.java index 5c8215b217..faebd3d2d9 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolver.java +++ b/messaging/src/main/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolver.java @@ -105,8 +105,7 @@ public final class AuthenticationPrincipalArgumentResolver * resolveArgument(org.springframework.core.MethodParameter, * org.springframework.messaging.Message) */ - public Object resolveArgument(MethodParameter parameter, Message message) - throws Exception { + public Object resolveArgument(MethodParameter parameter, Message message) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication == null) { @@ -164,4 +163,4 @@ public final class AuthenticationPrincipalArgumentResolver } return null; } -} \ No newline at end of file +} diff --git a/messaging/src/main/java/org/springframework/security/messaging/web/socket/server/CsrfTokenHandshakeInterceptor.java b/messaging/src/main/java/org/springframework/security/messaging/web/socket/server/CsrfTokenHandshakeInterceptor.java index 0e1f56762a..591b87dbb6 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/web/socket/server/CsrfTokenHandshakeInterceptor.java +++ b/messaging/src/main/java/org/springframework/security/messaging/web/socket/server/CsrfTokenHandshakeInterceptor.java @@ -38,7 +38,7 @@ public final class CsrfTokenHandshakeInterceptor implements HandshakeInterceptor public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, - Map attributes) throws Exception { + Map attributes) { HttpServletRequest httpRequest = ((ServletServerHttpRequest) request) .getServletRequest(); CsrfToken token = (CsrfToken) httpRequest.getAttribute(CsrfToken.class.getName()); diff --git a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java index 9e9fd07b8c..991186ea48 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java @@ -85,22 +85,22 @@ public class ChannelSecurityInterceptorTests { } @Test - public void getSecureObjectClass() throws Exception { + public void getSecureObjectClass() { assertThat(interceptor.getSecureObjectClass()).isEqualTo(Message.class); } @Test - public void obtainSecurityMetadataSource() throws Exception { + public void obtainSecurityMetadataSource() { assertThat(interceptor.obtainSecurityMetadataSource()).isEqualTo(source); } @Test - public void preSendNullAttributes() throws Exception { + public void preSendNullAttributes() { assertThat(interceptor.preSend(message, channel)).isSameAs(message); } @Test - public void preSendGrant() throws Exception { + public void preSendGrant() { when(source.getAttributes(message)).thenReturn(attrs); Message result = interceptor.preSend(message, channel); @@ -109,7 +109,7 @@ public class ChannelSecurityInterceptorTests { } @Test(expected = AccessDeniedException.class) - public void preSendDeny() throws Exception { + public void preSendDeny() { when(source.getAttributes(message)).thenReturn(attrs); doThrow(new AccessDeniedException("")).when(accessDecisionManager).decide( any(Authentication.class), eq(message), eq(attrs)); @@ -119,7 +119,7 @@ public class ChannelSecurityInterceptorTests { @SuppressWarnings("unchecked") @Test - public void preSendPostSendRunAs() throws Exception { + public void preSendPostSendRunAs() { when(source.getAttributes(message)).thenReturn(attrs); when( runAsManager.buildRunAs(any(Authentication.class), any(), @@ -137,13 +137,13 @@ public class ChannelSecurityInterceptorTests { } @Test - public void afterSendCompletionNotTokenMessageNoExceptionThrown() throws Exception { + public void afterSendCompletionNotTokenMessageNoExceptionThrown() { interceptor.afterSendCompletion(message, channel, true, null); } @SuppressWarnings("unchecked") @Test - public void preSendFinallySendRunAs() throws Exception { + public void preSendFinallySendRunAs() { when(source.getAttributes(message)).thenReturn(attrs); when( runAsManager.buildRunAs(any(Authentication.class), any(), @@ -161,17 +161,17 @@ public class ChannelSecurityInterceptorTests { } @Test - public void preReceive() throws Exception { + public void preReceive() { assertThat(interceptor.preReceive(channel)).isTrue(); } @Test - public void postReceive() throws Exception { + public void postReceive() { assertThat(interceptor.postReceive(message, channel)).isSameAs(message); } @Test - public void afterReceiveCompletionNullExceptionNoExceptionThrown() throws Exception { + public void afterReceiveCompletionNullExceptionNoExceptionThrown() { interceptor.afterReceiveCompletion(message, channel, null); } } diff --git a/messaging/src/test/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolverTests.java b/messaging/src/test/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolverTests.java index a9c8dea4df..55e31111b1 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolverTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/context/AuthenticationPrincipalArgumentResolverTests.java @@ -54,17 +54,17 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void supportsParameterNoAnnotation() throws Exception { + public void supportsParameterNoAnnotation() { assertThat(resolver.supportsParameter(showUserNoAnnotation())).isFalse(); } @Test - public void supportsParameterAnnotation() throws Exception { + public void supportsParameterAnnotation() { assertThat(resolver.supportsParameter(showUserAnnotationObject())).isTrue(); } @Test - public void supportsParameterCustomAnnotation() throws Exception { + public void supportsParameterCustomAnnotation() { assertThat(resolver.supportsParameter(showUserCustomAnnotation())).isTrue(); } diff --git a/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java b/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java index d5625e2441..56e784bc6a 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java @@ -75,7 +75,7 @@ public class SecurityContextChannelInterceptorTests { } @Test - public void preSendCustomHeader() throws Exception { + public void preSendCustomHeader() { String headerName = "header"; interceptor = new SecurityContextChannelInterceptor(headerName); messageBuilder.setHeader(headerName, authentication); @@ -87,7 +87,7 @@ public class SecurityContextChannelInterceptorTests { } @Test - public void preSendUserSet() throws Exception { + public void preSendUserSet() { messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, authentication); interceptor.preSend(messageBuilder.build(), channel); @@ -102,7 +102,7 @@ public class SecurityContextChannelInterceptorTests { } @Test - public void preSendUsesCustomAnonymous() throws Exception { + public void preSendUsesCustomAnonymous() { expectedAnonymous = new AnonymousAuthenticationToken("customKey", "customAnonymous", AuthorityUtils.createAuthorityList("ROLE_CUSTOM")); interceptor.setAnonymousAuthentication(expectedAnonymous); @@ -114,7 +114,7 @@ public class SecurityContextChannelInterceptorTests { // SEC-2845 @Test - public void preSendUserNotAuthentication() throws Exception { + public void preSendUserNotAuthentication() { messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, principal); interceptor.preSend(messageBuilder.build(), channel); @@ -124,7 +124,7 @@ public class SecurityContextChannelInterceptorTests { // SEC-2845 @Test - public void preSendUserNotSet() throws Exception { + public void preSendUserNotSet() { interceptor.preSend(messageBuilder.build(), channel); assertAnonymous(); @@ -132,14 +132,14 @@ public class SecurityContextChannelInterceptorTests { // SEC-2845 @Test - public void preSendUserNotSetCustomAnonymous() throws Exception { + public void preSendUserNotSetCustomAnonymous() { interceptor.preSend(messageBuilder.build(), channel); assertAnonymous(); } @Test - public void afterSendCompletion() throws Exception { + public void afterSendCompletion() { SecurityContextHolder.getContext().setAuthentication(authentication); interceptor.afterSendCompletion(messageBuilder.build(), channel, true, null); @@ -148,14 +148,14 @@ public class SecurityContextChannelInterceptorTests { } @Test - public void afterSendCompletionNullAuthentication() throws Exception { + public void afterSendCompletionNullAuthentication() { interceptor.afterSendCompletion(messageBuilder.build(), channel, true, null); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @Test - public void beforeHandleUserSet() throws Exception { + public void beforeHandleUserSet() { messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, authentication); interceptor.beforeHandle(messageBuilder.build(), channel, handler); @@ -166,7 +166,7 @@ public class SecurityContextChannelInterceptorTests { // SEC-2845 @Test - public void beforeHandleUserNotAuthentication() throws Exception { + public void beforeHandleUserNotAuthentication() { messageBuilder.setHeader(SimpMessageHeaderAccessor.USER_HEADER, principal); interceptor.beforeHandle(messageBuilder.build(), channel, handler); @@ -176,21 +176,21 @@ public class SecurityContextChannelInterceptorTests { // SEC-2845 @Test - public void beforeHandleUserNotSet() throws Exception { + public void beforeHandleUserNotSet() { interceptor.beforeHandle(messageBuilder.build(), channel, handler); assertAnonymous(); } @Test - public void afterMessageHandledUserNotSet() throws Exception { + public void afterMessageHandledUserNotSet() { interceptor.afterMessageHandled(messageBuilder.build(), channel, handler, null); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @Test - public void afterMessageHandled() throws Exception { + public void afterMessageHandled() { SecurityContextHolder.getContext().setAuthentication(authentication); interceptor.afterMessageHandled(messageBuilder.build(), channel, handler, null); @@ -200,7 +200,7 @@ public class SecurityContextChannelInterceptorTests { // SEC-2829 @Test - public void restoresOriginalContext() throws Exception { + public void restoresOriginalContext() { TestingAuthenticationToken original = new TestingAuthenticationToken("original", "original", "ROLE_USER"); SecurityContextHolder.getContext().setAuthentication(original); @@ -220,10 +220,9 @@ public class SecurityContextChannelInterceptorTests { /** * If a user sends a websocket when processing another websocket * - * @throws Exception */ @Test - public void restoresOriginalContextNestedThreeDeep() throws Exception { + public void restoresOriginalContextNestedThreeDeep() { AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key", "anonymous", AuthorityUtils.createAuthorityList("ROLE_USER")); diff --git a/messaging/src/test/java/org/springframework/security/messaging/util/matcher/SimpDestinationMessageMatcherTests.java b/messaging/src/test/java/org/springframework/security/messaging/util/matcher/SimpDestinationMessageMatcherTests.java index 4be60deee0..4ebe6cf797 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/util/matcher/SimpDestinationMessageMatcherTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/util/matcher/SimpDestinationMessageMatcherTests.java @@ -49,12 +49,12 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesDoesNotMatchNullDestination() throws Exception { + public void matchesDoesNotMatchNullDestination() { assertThat(matcher.matches(messageBuilder.build())).isFalse(); } @Test - public void matchesAllWithDestination() throws Exception { + public void matchesAllWithDestination() { messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/destination/1"); @@ -62,7 +62,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesSpecificWithDestination() throws Exception { + public void matchesSpecificWithDestination() { matcher = new SimpDestinationMessageMatcher("/destination/1"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, @@ -72,7 +72,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesFalseWithDestination() throws Exception { + public void matchesFalseWithDestination() { matcher = new SimpDestinationMessageMatcher("/nomatch"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, @@ -82,7 +82,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesFalseMessageTypeNotDisconnectType() throws Exception { + public void matchesFalseMessageTypeNotDisconnectType() { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); @@ -93,7 +93,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesTrueMessageType() throws Exception { + public void matchesTrueMessageType() { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); @@ -105,7 +105,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesTrueSubscribeType() throws Exception { + public void matchesTrueSubscribeType() { matcher = SimpDestinationMessageMatcher.createSubscribeMatcher("/match", pathMatcher); @@ -117,7 +117,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void matchesNullMessageType() throws Exception { + public void matchesNullMessageType() { matcher = new SimpDestinationMessageMatcher("/match"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/match"); @@ -128,7 +128,7 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void extractPathVariablesFromDestination() throws Exception { + public void extractPathVariablesFromDestination() { matcher = new SimpDestinationMessageMatcher("/topics/{topic}/**"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/topics/someTopic/sub1"); @@ -139,13 +139,13 @@ public class SimpDestinationMessageMatcherTests { } @Test - public void extractedVariablesAreEmptyInNullDestination() throws Exception { + public void extractedVariablesAreEmptyInNullDestination() { matcher = new SimpDestinationMessageMatcher("/topics/{topic}/**"); assertThat(matcher.extractPathVariables(messageBuilder.build())).isEmpty(); } @Test - public void typeConstructorParameterIsTransmitted() throws Exception { + public void typeConstructorParameterIsTransmitted() { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationCodeGrantFilter.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationCodeGrantFilter.java index 0968ed332c..3eda6df7c6 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationCodeGrantFilter.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationCodeGrantFilter.java @@ -156,7 +156,7 @@ public class OAuth2AuthorizationCodeGrantFilter extends OncePerRequestFilter { } private void processAuthorizationResponse(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws IOException { OAuth2AuthorizationRequest authorizationRequest = this.authorizationRequestRepository.removeAuthorizationRequest(request, response); diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilter.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilter.java index fcd30e3c2a..0953200255 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilter.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilter.java @@ -190,7 +190,7 @@ public class OAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFilt } private void sendRedirectForAuthorization(HttpServletRequest request, HttpServletResponse response, - OAuth2AuthorizationRequest authorizationRequest) throws IOException, ServletException { + OAuth2AuthorizationRequest authorizationRequest) throws IOException { if (AuthorizationGrantType.AUTHORIZATION_CODE.equals(authorizationRequest.getGrantType())) { this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest, request, response); @@ -199,7 +199,7 @@ public class OAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFilt } private void unsuccessfulRedirectForAuthorization(HttpServletRequest request, HttpServletResponse response, - Exception failed) throws IOException, ServletException { + Exception failed) throws IOException { if (logger.isErrorEnabled()) { logger.error("Authorization Request failed: " + failed.toString(), failed); diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilter.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilter.java index 4cb47f575c..6d58ffba21 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilter.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilter.java @@ -150,7 +150,7 @@ public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProce @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) - throws AuthenticationException, IOException, ServletException { + throws AuthenticationException { MultiValueMap params = OAuth2AuthorizationResponseUtils.toMultiMap(request.getParameterMap()); if (!OAuth2AuthorizationResponseUtils.isAuthorizationResponse(params)) { diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/method/annotation/OAuth2AuthorizedClientArgumentResolver.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/method/annotation/OAuth2AuthorizedClientArgumentResolver.java index b88f2ecad6..533e020f96 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/method/annotation/OAuth2AuthorizedClientArgumentResolver.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/method/annotation/OAuth2AuthorizedClientArgumentResolver.java @@ -126,7 +126,7 @@ public final class OAuth2AuthorizedClientArgumentResolver implements HandlerMeth public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - @Nullable WebDataBinderFactory binderFactory) throws Exception { + @Nullable WebDataBinderFactory binderFactory) { String clientRegistrationId = this.resolveClientRegistrationId(parameter); if (StringUtils.isEmpty(clientRegistrationId)) { diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java index bd3f441359..a777d897b0 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java @@ -173,12 +173,12 @@ public final class ServletOAuth2AuthorizedClientExchangeFilterFunction } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Hooks.onLastOperator(REQUEST_CONTEXT_OPERATOR_KEY, Operators.lift((s, sub) -> createRequestContextSubscriber(sub))); } @Override - public void destroy() throws Exception { + public void destroy() { Hooks.resetOnLastOperator(REQUEST_CONTEXT_OPERATOR_KEY); } diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProviderTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProviderTests.java index 31d841a6f1..e4431ee471 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProviderTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProviderTests.java @@ -77,7 +77,7 @@ public class OAuth2LoginAuthenticationProviderTests { @Before @SuppressWarnings("unchecked") - public void setUp() throws Exception { + public void setUp() { this.clientRegistration = clientRegistration().build(); this.authorizationRequest = request().scope("scope1", "scope2").build(); this.authorizationResponse = success().build(); diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/NimbusAuthorizationCodeTokenResponseClientTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/NimbusAuthorizationCodeTokenResponseClientTests.java index ce651b431b..e26cb0b18d 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/NimbusAuthorizationCodeTokenResponseClientTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/NimbusAuthorizationCodeTokenResponseClientTests.java @@ -57,7 +57,7 @@ public class NimbusAuthorizationCodeTokenResponseClientTests { public ExpectedException exception = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { this.clientRegistrationBuilder = clientRegistration() .clientAuthenticationMethod(ClientAuthenticationMethod.BASIC); this.authorizationRequest = request().build(); @@ -107,7 +107,7 @@ public class NimbusAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenRedirectUriMalformedThenThrowIllegalArgumentException() throws Exception { + public void getTokenResponseWhenRedirectUriMalformedThenThrowIllegalArgumentException() { this.exception.expect(IllegalArgumentException.class); String redirectUri = "http:\\example.com"; @@ -121,7 +121,7 @@ public class NimbusAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenTokenUriMalformedThenThrowIllegalArgumentException() throws Exception { + public void getTokenResponseWhenTokenUriMalformedThenThrowIllegalArgumentException() { this.exception.expect(IllegalArgumentException.class); String tokenUri = "http:\\provider.com\\oauth2\\token"; @@ -166,7 +166,7 @@ public class NimbusAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenTokenUriInvalidThenThrowOAuth2AuthorizationException() throws Exception { + public void getTokenResponseWhenTokenUriInvalidThenThrowOAuth2AuthorizationException() { this.exception.expect(OAuth2AuthorizationException.class); String tokenUri = "https://invalid-provider.com/oauth2/token"; diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/WebClientReactiveAuthorizationCodeTokenResponseClientTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/WebClientReactiveAuthorizationCodeTokenResponseClientTests.java index c05d1572d9..d4104bae16 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/WebClientReactiveAuthorizationCodeTokenResponseClientTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/WebClientReactiveAuthorizationCodeTokenResponseClientTests.java @@ -170,7 +170,7 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests { // } // @Test - public void getTokenResponseWhenErrorResponseThenThrowOAuth2AuthorizationException() throws Exception { + public void getTokenResponseWhenErrorResponseThenThrowOAuth2AuthorizationException() { String accessTokenErrorResponse = "{\n" + " \"error\": \"unauthorized_client\"\n" + "}\n"; @@ -184,7 +184,7 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests { // gh-5594 @Test - public void getTokenResponseWhenServerErrorResponseThenThrowOAuth2AuthorizationException() throws Exception { + public void getTokenResponseWhenServerErrorResponseThenThrowOAuth2AuthorizationException() { String accessTokenErrorResponse = "{}"; this.server.enqueue(jsonResponse(accessTokenErrorResponse).setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR.value())); @@ -194,7 +194,7 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenSuccessResponseAndNotBearerTokenTypeThenThrowOAuth2AuthorizationException() throws Exception { + public void getTokenResponseWhenSuccessResponseAndNotBearerTokenTypeThenThrowOAuth2AuthorizationException() { String accessTokenSuccessResponse = "{\n" + " \"access_token\": \"access-token-1234\",\n" + " \"token_type\": \"not-bearer\",\n" + @@ -209,7 +209,7 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenSuccessResponseIncludesScopeThenReturnAccessTokenResponseUsingResponseScope() throws Exception { + public void getTokenResponseWhenSuccessResponseIncludesScopeThenReturnAccessTokenResponseUsingResponseScope() { String accessTokenSuccessResponse = "{\n" + " \"access_token\": \"access-token-1234\",\n" + " \"token_type\": \"bearer\",\n" + @@ -226,7 +226,7 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests { } @Test - public void getTokenResponseWhenSuccessResponseDoesNotIncludeScopeThenReturnAccessTokenResponseUsingRequestedScope() throws Exception { + public void getTokenResponseWhenSuccessResponseDoesNotIncludeScopeThenReturnAccessTokenResponseUsingRequestedScope() { String accessTokenSuccessResponse = "{\n" + " \"access_token\": \"access-token-1234\",\n" + " \"token_type\": \"bearer\",\n" + diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java index 903e26e02c..86f40a9410 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java @@ -241,10 +241,9 @@ public class ClientRegistrationsTest { /** * We currently only support authorization_code, so verify we have a meaningful error until we add support. - * @throws Exception */ @Test - public void issuerWhenGrantTypesSupportedInvalidThenException() throws Exception { + public void issuerWhenGrantTypesSupportedInvalidThenException() { this.response.put("grant_types_supported", Arrays.asList("implicit")); assertThatThrownBy(() -> registration("")) @@ -253,7 +252,7 @@ public class ClientRegistrationsTest { } @Test - public void issuerWhenOAuth2GrantTypesSupportedInvalidThenException() throws Exception { + public void issuerWhenOAuth2GrantTypesSupportedInvalidThenException() { this.response.put("grant_types_supported", Arrays.asList("implicit")); assertThatThrownBy(() -> registrationOAuth2("", null)) @@ -317,10 +316,9 @@ public class ClientRegistrationsTest { /** * We currently only support client_secret_basic, so verify we have a meaningful error until we add support. - * @throws Exception */ @Test - public void issuerWhenTokenEndpointAuthMethodsInvalidThenException() throws Exception { + public void issuerWhenTokenEndpointAuthMethodsInvalidThenException() { this.response.put("token_endpoint_auth_methods_supported", Arrays.asList("tls_client_auth")); assertThatThrownBy(() -> registration("")) @@ -329,7 +327,7 @@ public class ClientRegistrationsTest { } @Test - public void issuerWhenOAuth2TokenEndpointAuthMethodsInvalidThenException() throws Exception { + public void issuerWhenOAuth2TokenEndpointAuthMethodsInvalidThenException() { this.response.put("token_endpoint_auth_methods_supported", Arrays.asList("tls_client_auth")); assertThatThrownBy(() -> registrationOAuth2("", null)) @@ -395,7 +393,7 @@ public class ClientRegistrationsTest { final Dispatcher dispatcher = new Dispatcher() { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { switch(request.getPath()) { case "/.well-known/oauth-authorization-server/issuer1": case "/.well-known/oauth-authorization-server/": @@ -433,7 +431,7 @@ public class ClientRegistrationsTest { final Dispatcher dispatcher = new Dispatcher() { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { switch(request.getPath()) { case "/issuer1/.well-known/openid-configuration": case "/.well-known/openid-configuration/": diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserServiceTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserServiceTests.java index b856c80252..63dd4c1376 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserServiceTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserServiceTests.java @@ -104,7 +104,7 @@ public class DefaultReactiveOAuth2UserServiceTests { } @Test - public void loadUserWhenUserInfoSuccessResponseThenReturnUser() throws Exception { + public void loadUserWhenUserInfoSuccessResponseThenReturnUser() { String userInfoResponse = "{\n" + " \"id\": \"user1\",\n" + " \"first-name\": \"first\",\n" + @@ -179,7 +179,7 @@ public class DefaultReactiveOAuth2UserServiceTests { } @Test - public void loadUserWhenUserInfoSuccessResponseInvalidThenThrowOAuth2AuthenticationException() throws Exception { + public void loadUserWhenUserInfoSuccessResponseInvalidThenThrowOAuth2AuthenticationException() { String userInfoResponse = "{\n" + " \"id\": \"user1\",\n" + " \"first-name\": \"first\",\n" + @@ -196,7 +196,7 @@ public class DefaultReactiveOAuth2UserServiceTests { } @Test - public void loadUserWhenUserInfoErrorResponseThenThrowOAuth2AuthenticationException() throws Exception { + public void loadUserWhenUserInfoErrorResponseThenThrowOAuth2AuthenticationException() { this.server.enqueue(new MockResponse().setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).setResponseCode(500).setBody("{}")); assertThatThrownBy(() -> this.userService.loadUser(oauth2UserRequest()).block()) @@ -205,7 +205,7 @@ public class DefaultReactiveOAuth2UserServiceTests { } @Test - public void loadUserWhenUserInfoUriInvalidThenThrowAuthenticationServiceException() throws Exception { + public void loadUserWhenUserInfoUriInvalidThenThrowAuthenticationServiceException() { this.clientRegistration.userInfoUri("https://invalid-provider.com/user"); assertThatThrownBy(() -> this.userService.loadUser(oauth2UserRequest()).block()) .isInstanceOf(AuthenticationServiceException.class); diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunctionTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunctionTests.java index 4c866c8abb..44c9ebb040 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunctionTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunctionTests.java @@ -575,7 +575,7 @@ public class ServletOAuth2AuthorizedClientExchangeFilterFunctionTests { } @Test - public void filterWhenRequestAttributesNotSetAndHooksNotInitThenDefaultsNotAvailable() throws Exception { + public void filterWhenRequestAttributesNotSetAndHooksNotInitThenDefaultsNotAvailable() { // this.function.afterPropertiesSet(); // Hooks.onLastOperator() NOT initialized this.function.setDefaultOAuth2AuthorizedClient(true); diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2AccessTokenResponseHttpMessageConverter.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2AccessTokenResponseHttpMessageConverter.java index eb731d2ca0..9246331ea9 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2AccessTokenResponseHttpMessageConverter.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2AccessTokenResponseHttpMessageConverter.java @@ -79,7 +79,7 @@ public class OAuth2AccessTokenResponseHttpMessageConverter extends AbstractHttpM @Override protected OAuth2AccessTokenResponse readInternal(Class clazz, HttpInputMessage inputMessage) - throws IOException, HttpMessageNotReadableException { + throws HttpMessageNotReadableException { try { @SuppressWarnings("unchecked") @@ -94,7 +94,7 @@ public class OAuth2AccessTokenResponseHttpMessageConverter extends AbstractHttpM @Override protected void writeInternal(OAuth2AccessTokenResponse tokenResponse, HttpOutputMessage outputMessage) - throws IOException, HttpMessageNotWritableException { + throws HttpMessageNotWritableException { try { Map tokenResponseParameters = this.tokenResponseParametersConverter.convert(tokenResponse); diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2ErrorHttpMessageConverter.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2ErrorHttpMessageConverter.java index b5f192b0d7..15fc1bec6d 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2ErrorHttpMessageConverter.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2ErrorHttpMessageConverter.java @@ -67,7 +67,7 @@ public class OAuth2ErrorHttpMessageConverter extends AbstractHttpMessageConverte @Override protected OAuth2Error readInternal(Class clazz, HttpInputMessage inputMessage) - throws IOException, HttpMessageNotReadableException { + throws HttpMessageNotReadableException { try { @SuppressWarnings("unchecked") @@ -82,7 +82,7 @@ public class OAuth2ErrorHttpMessageConverter extends AbstractHttpMessageConverte @Override protected void writeInternal(OAuth2Error oauth2Error, HttpOutputMessage outputMessage) - throws IOException, HttpMessageNotWritableException { + throws HttpMessageNotWritableException { try { Map errorParameters = this.errorParametersConverter.convert(oauth2Error); diff --git a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java index ae086b8eca..3290a0518d 100644 --- a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java +++ b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java @@ -97,7 +97,7 @@ public class OAuth2BodyExtractorsTests { } @Test - public void oauth2AccessTokenResponseWhenValidThenCreated() throws Exception { + public void oauth2AccessTokenResponseWhenValidThenCreated() { BodyExtractor, ReactiveHttpInputMessage> extractor = OAuth2BodyExtractors .oauth2AccessTokenResponse(); @@ -124,7 +124,7 @@ public class OAuth2BodyExtractorsTests { @Test // gh-6087 - public void oauth2AccessTokenResponseWhenMultipleAttributeTypesThenCreated() throws Exception { + public void oauth2AccessTokenResponseWhenMultipleAttributeTypesThenCreated() { BodyExtractor, ReactiveHttpInputMessage> extractor = OAuth2BodyExtractors .oauth2AccessTokenResponse(); diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/MappedJwtClaimSetConverterTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/MappedJwtClaimSetConverterTests.java index 3b28e9d528..322890449d 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/MappedJwtClaimSetConverterTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/MappedJwtClaimSetConverterTests.java @@ -89,7 +89,7 @@ public class MappedJwtClaimSetConverterTests { } @Test - public void convertWhenUsingDefaultsThenCoercesAllAttributesInJwtSpec() throws Exception { + public void convertWhenUsingDefaultsThenCoercesAllAttributesInJwtSpec() { MappedJwtClaimSetConverter converter = MappedJwtClaimSetConverter.withDefaults(Collections.emptyMap()); @@ -114,7 +114,7 @@ public class MappedJwtClaimSetConverterTests { } @Test - public void convertWhenUsingCustomConverterThenAllOtherDefaultsAreStillUsed() throws Exception { + public void convertWhenUsingCustomConverterThenAllOtherDefaultsAreStillUsed() { Converter claimConverter = mock(Converter.class); MappedJwtClaimSetConverter converter = MappedJwtClaimSetConverter .withDefaults(Collections.singletonMap(JwtClaimNames.SUB, claimConverter)); diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java index d41ca11fef..2597dd2638 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java @@ -97,7 +97,7 @@ public class NimbusJwtDecoderJwkSupportTests { // gh-5168 @Test - public void decodeWhenExpClaimNullThenDoesNotThrowException() throws Exception { + public void decodeWhenExpClaimNullThenDoesNotThrowException() { NimbusJwtDecoderJwkSupport jwtDecoder = new NimbusJwtDecoderJwkSupport(JWK_SET_URL); jwtDecoder.setRestOperations(mockJwkSetResponse(JWK_SET)); jwtDecoder.setClaimSetConverter(map -> { diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderTests.java index e194267569..aa92f80f28 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderTests.java @@ -442,7 +442,7 @@ public class NimbusJwtDecoderTests { private static class MockJwtProcessor extends DefaultJWTProcessor { @Override public JWTClaimsSet process(SignedJWT signedJWT, SecurityContext context) - throws BadJOSEException, JOSEException { + throws BadJOSEException { try { return signedJWT.getJWTClaimsSet(); diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationEntryPoint.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationEntryPoint.java index c083201a68..fd247ac32f 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationEntryPoint.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationEntryPoint.java @@ -61,8 +61,7 @@ public final class BearerTokenAuthenticationEntryPoint implements Authentication @Override public void commence( HttpServletRequest request, HttpServletResponse response, - AuthenticationException authException) - throws IOException, ServletException { + AuthenticationException authException) { HttpStatus status = HttpStatus.UNAUTHORIZED; diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/access/BearerTokenAccessDeniedHandler.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/access/BearerTokenAccessDeniedHandler.java index c2b489218f..445b1ca211 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/access/BearerTokenAccessDeniedHandler.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/access/BearerTokenAccessDeniedHandler.java @@ -59,8 +59,7 @@ public final class BearerTokenAccessDeniedHandler implements AccessDeniedHandler @Override public void handle( HttpServletRequest request, HttpServletResponse response, - AccessDeniedException accessDeniedException) - throws IOException, ServletException { + AccessDeniedException accessDeniedException) { Map parameters = new LinkedHashMap<>(); diff --git a/openid/src/main/java/org/springframework/security/openid/OpenID4JavaConsumer.java b/openid/src/main/java/org/springframework/security/openid/OpenID4JavaConsumer.java index 6f6bb81e6c..2323f99985 100644 --- a/openid/src/main/java/org/springframework/security/openid/OpenID4JavaConsumer.java +++ b/openid/src/main/java/org/springframework/security/openid/OpenID4JavaConsumer.java @@ -70,7 +70,7 @@ public class OpenID4JavaConsumer implements OpenIDConsumer { } public OpenID4JavaConsumer(ConsumerManager consumerManager, - AxFetchListFactory attributesToFetchFactory) throws ConsumerException { + AxFetchListFactory attributesToFetchFactory) { this.consumerManager = consumerManager; this.attributesToFetchFactory = attributesToFetchFactory; } diff --git a/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProvider.java b/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProvider.java index 2ea78f364b..6b9f723aac 100644 --- a/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProvider.java +++ b/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProvider.java @@ -58,7 +58,7 @@ public class OpenIDAuthenticationProvider // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.userDetailsService, "The userDetailsService must be set"); } diff --git a/openid/src/test/java/org/springframework/security/openid/MockOpenIDConsumer.java b/openid/src/test/java/org/springframework/security/openid/MockOpenIDConsumer.java index 7043e5bca7..e22b73984b 100644 --- a/openid/src/test/java/org/springframework/security/openid/MockOpenIDConsumer.java +++ b/openid/src/test/java/org/springframework/security/openid/MockOpenIDConsumer.java @@ -51,12 +51,11 @@ public class MockOpenIDConsumer implements OpenIDConsumer { // ======================================================================================================== public String beginConsumption(HttpServletRequest req, String claimedIdentity, - String returnToUrl, String realm) throws OpenIDConsumerException { + String returnToUrl, String realm) { return redirectUrl; } - public OpenIDAuthenticationToken endConsumption(HttpServletRequest req) - throws OpenIDConsumerException { + public OpenIDAuthenticationToken endConsumption(HttpServletRequest req) { return token; } diff --git a/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationFilterTests.java b/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationFilterTests.java index 415beae628..818698313a 100644 --- a/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationFilterTests.java +++ b/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationFilterTests.java @@ -42,7 +42,7 @@ public class OpenIDAuthenticationFilterTests { private static final String DEFAULT_TARGET_URL = FILTER_PROCESS_URL; @Before - public void setUp() throws Exception { + public void setUp() { filter = new OpenIDAuthenticationFilter(); filter.setConsumer(new MockOpenIDConsumer(REDIRECT_URL)); SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); @@ -65,8 +65,7 @@ public class OpenIDAuthenticationFilterTests { filter.setConsumer(new MockOpenIDConsumer() { public String beginConsumption(HttpServletRequest req, - String claimedIdentity, String returnToUrl, String realm) - throws OpenIDConsumerException { + String claimedIdentity, String returnToUrl, String realm) { assertThat(claimedIdentity).isEqualTo(CLAIMED_IDENTITY_URL); assertThat(returnToUrl).isEqualTo(DEFAULT_TARGET_URL); assertThat(realm).isEqualTo("http://localhost:8080/"); diff --git a/remoting/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java b/remoting/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java index 6753e2fb03..0d225d423b 100644 --- a/remoting/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java +++ b/remoting/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java @@ -57,10 +57,8 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor extends * @param con the HTTP connection to prepare * @param contentLength the length of the content to send * - * @throws IOException if thrown by HttpURLConnection methods */ - protected void doPrepareConnection(HttpURLConnection con, int contentLength) - throws IOException { + protected void doPrepareConnection(HttpURLConnection con, int contentLength) { } /** diff --git a/remoting/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java b/remoting/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java index cff51e1d3c..3d8e028013 100644 --- a/remoting/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java +++ b/remoting/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java @@ -43,7 +43,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests { // ~ Methods // ======================================================================================================== @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @@ -109,7 +109,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests { super(u); } - public void connect() throws IOException { + public void connect() { throw new UnsupportedOperationException("mock not implemented"); } diff --git a/remoting/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java b/remoting/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java index ed999b4e5b..c5877fd021 100644 --- a/remoting/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java +++ b/remoting/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java @@ -42,7 +42,7 @@ public class ContextPropagatingRemoteInvocationTests { // ~ Methods // ======================================================================================================== @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } diff --git a/samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java b/samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java index e398fa7fe9..e5dcd999ca 100644 --- a/samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java +++ b/samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java @@ -39,7 +39,7 @@ public class HelloWebfluxMethodApplicationITests { @Test - public void messageWhenNotAuthenticated() throws Exception { + public void messageWhenNotAuthenticated() { this.rest .get() .uri("/message") @@ -48,7 +48,7 @@ public class HelloWebfluxMethodApplicationITests { } @Test - public void messageWhenUserThenForbidden() throws Exception { + public void messageWhenUserThenForbidden() { this.rest .get() .uri("/message") @@ -58,7 +58,7 @@ public class HelloWebfluxMethodApplicationITests { } @Test - public void messageWhenAdminThenOk() throws Exception { + public void messageWhenAdminThenOk() { this.rest .get() .uri("/message") diff --git a/samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java b/samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java index bb7349c7dc..8fe6d52139 100644 --- a/samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java +++ b/samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java @@ -36,7 +36,7 @@ import static org.springframework.security.config.Customizer.withDefaults; public class SecurityConfig { @Bean - SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { + SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) { return http // Demonstrate that method security works // Best practice to use both for defense in depth diff --git a/samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java b/samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java index aef7a9b380..fdf850a114 100644 --- a/samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java +++ b/samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java @@ -50,7 +50,7 @@ public class HelloWebfluxMethodApplicationTests { } @Test - public void messageWhenNotAuthenticated() throws Exception { + public void messageWhenNotAuthenticated() { this.rest .get() .uri("/message") @@ -61,7 +61,7 @@ public class HelloWebfluxMethodApplicationTests { // --- Basic Authentication --- @Test - public void messageWhenUserThenForbidden() throws Exception { + public void messageWhenUserThenForbidden() { this.rest .get() .uri("/message") @@ -71,7 +71,7 @@ public class HelloWebfluxMethodApplicationTests { } @Test - public void messageWhenAdminThenOk() throws Exception { + public void messageWhenAdminThenOk() { this.rest .get() .uri("/message") @@ -85,7 +85,7 @@ public class HelloWebfluxMethodApplicationTests { @Test @WithMockUser - public void messageWhenWithMockUserThenForbidden() throws Exception { + public void messageWhenWithMockUserThenForbidden() { this.rest .get() .uri("/message") @@ -95,7 +95,7 @@ public class HelloWebfluxMethodApplicationTests { @Test @WithMockUser(roles = "ADMIN") - public void messageWhenWithMockAdminThenOk() throws Exception { + public void messageWhenWithMockAdminThenOk() { this.rest .get() .uri("/message") @@ -107,7 +107,7 @@ public class HelloWebfluxMethodApplicationTests { // --- mutateWith mockUser --- @Test - public void messageWhenMutateWithMockUserThenForbidden() throws Exception { + public void messageWhenMutateWithMockUserThenForbidden() { this.rest .mutateWith(mockUser()) .get() @@ -117,7 +117,7 @@ public class HelloWebfluxMethodApplicationTests { } @Test - public void messageWhenMutateWithMockAdminThenOk() throws Exception { + public void messageWhenMutateWithMockAdminThenOk() { this.rest .mutateWith(mockUser().roles("ADMIN")) .get() diff --git a/samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java b/samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java index 1b9124ae14..a749cbb592 100644 --- a/samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java +++ b/samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java @@ -37,7 +37,7 @@ public class HelloWebfluxApplicationITests { WebTestClient rest; @Test - public void basicWhenNoCredentialsThenUnauthorized() throws Exception { + public void basicWhenNoCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -46,7 +46,7 @@ public class HelloWebfluxApplicationITests { } @Test - public void basicWhenValidCredentialsThenOk() throws Exception { + public void basicWhenValidCredentialsThenOk() { this.rest .get() .uri("/") @@ -57,7 +57,7 @@ public class HelloWebfluxApplicationITests { } @Test - public void basicWhenInvalidCredentialsThenUnauthorized() throws Exception { + public void basicWhenInvalidCredentialsThenUnauthorized() { this.rest .get() .uri("/") diff --git a/samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java b/samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java index c6dfdfa2ff..7d6c2a7bf6 100644 --- a/samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java +++ b/samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java @@ -51,7 +51,7 @@ public class HelloWebfluxApplicationTests { } @Test - public void basicWhenNoCredentialsThenUnauthorized() throws Exception { + public void basicWhenNoCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -60,7 +60,7 @@ public class HelloWebfluxApplicationTests { } @Test - public void basicWhenValidCredentialsThenOk() throws Exception { + public void basicWhenValidCredentialsThenOk() { this.rest .get() .uri("/") @@ -71,7 +71,7 @@ public class HelloWebfluxApplicationTests { } @Test - public void basicWhenInvalidCredentialsThenUnauthorized() throws Exception { + public void basicWhenInvalidCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -82,7 +82,7 @@ public class HelloWebfluxApplicationTests { } @Test - public void mockSupportWhenMutateWithMockUserThenOk() throws Exception { + public void mockSupportWhenMutateWithMockUserThenOk() { this.rest .mutateWith(mockUser()) .get() @@ -94,7 +94,7 @@ public class HelloWebfluxApplicationTests { @Test @WithMockUser - public void mockSupportWhenWithMockUserThenOk() throws Exception { + public void mockSupportWhenWithMockUserThenOk() { this.rest .get() .uri("/") diff --git a/samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java b/samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java index 669234034e..80e805ff4f 100644 --- a/samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java +++ b/samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java @@ -43,7 +43,7 @@ public class HelloWebfluxFnApplicationITests { } @Test - public void basicWhenNoCredentialsThenUnauthorized() throws Exception { + public void basicWhenNoCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -52,7 +52,7 @@ public class HelloWebfluxFnApplicationITests { } @Test - public void basicWhenValidCredentialsThenOk() throws Exception { + public void basicWhenValidCredentialsThenOk() { this.rest .get() .uri("/") @@ -63,7 +63,7 @@ public class HelloWebfluxFnApplicationITests { } @Test - public void basicWhenInvalidCredentialsThenUnauthorized() throws Exception { + public void basicWhenInvalidCredentialsThenUnauthorized() { this.rest .get() .uri("/") diff --git a/samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java b/samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java index bdeb39dd86..3bdc2f7e03 100644 --- a/samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java +++ b/samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java @@ -52,7 +52,7 @@ public class HelloWebfluxFnApplicationTests { } @Test - public void basicWhenNoCredentialsThenUnauthorized() throws Exception { + public void basicWhenNoCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -61,7 +61,7 @@ public class HelloWebfluxFnApplicationTests { } @Test - public void basicWhenValidCredentialsThenOk() throws Exception { + public void basicWhenValidCredentialsThenOk() { this.rest .get() .uri("/") @@ -72,7 +72,7 @@ public class HelloWebfluxFnApplicationTests { } @Test - public void basicWhenInvalidCredentialsThenUnauthorized() throws Exception { + public void basicWhenInvalidCredentialsThenUnauthorized() { this.rest .get() .uri("/") @@ -83,7 +83,7 @@ public class HelloWebfluxFnApplicationTests { } @Test - public void mockSupportWhenMutateWithMockUserThenOk() throws Exception { + public void mockSupportWhenMutateWithMockUserThenOk() { this.rest .mutateWith(mockUser()) .get() @@ -95,7 +95,7 @@ public class HelloWebfluxFnApplicationTests { @Test @WithMockUser - public void mockSupportWhenWithMockUserThenOk() throws Exception { + public void mockSupportWhenWithMockUserThenOk() { this.rest .get() .uri("/") diff --git a/samples/boot/oauth2authorizationserver/src/main/java/sample/AuthorizationServerConfiguration.java b/samples/boot/oauth2authorizationserver/src/main/java/sample/AuthorizationServerConfiguration.java index 62d4f61504..8a47b9b7a0 100644 --- a/samples/boot/oauth2authorizationserver/src/main/java/sample/AuthorizationServerConfiguration.java +++ b/samples/boot/oauth2authorizationserver/src/main/java/sample/AuthorizationServerConfiguration.java @@ -116,7 +116,7 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu } @Override - public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { + public void configure(AuthorizationServerEndpointsConfigurer endpoints) { // @formatter:off endpoints .authenticationManager(this.authenticationManager) diff --git a/samples/boot/oauth2login/src/integration-test/java/org/springframework/security/samples/OAuth2LoginApplicationTests.java b/samples/boot/oauth2login/src/integration-test/java/org/springframework/security/samples/OAuth2LoginApplicationTests.java index 3e2760c4b1..067bed4431 100644 --- a/samples/boot/oauth2login/src/integration-test/java/org/springframework/security/samples/OAuth2LoginApplicationTests.java +++ b/samples/boot/oauth2login/src/integration-test/java/org/springframework/security/samples/OAuth2LoginApplicationTests.java @@ -291,7 +291,7 @@ public class OAuth2LoginApplicationTests { assertThat(errorElement.asText()).contains("invalid_redirect_uri_parameter"); } - private void assertLoginPage(HtmlPage page) throws Exception { + private void assertLoginPage(HtmlPage page) { assertThat(page.getTitleText()).isEqualTo("Please sign in"); int expectedClients = 4; @@ -322,7 +322,7 @@ public class OAuth2LoginApplicationTests { } } - private void assertIndexPage(HtmlPage page) throws Exception { + private void assertIndexPage(HtmlPage page) { assertThat(page.getTitleText()).isEqualTo("Spring Security - OAuth 2.0 Login"); DomNodeList divElements = page.getBody().getElementsByTagName("div"); diff --git a/samples/boot/oauth2resourceserver-jwe/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java b/samples/boot/oauth2resourceserver-jwe/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java index 7486cdd8ce..5e9df1d836 100644 --- a/samples/boot/oauth2resourceserver-jwe/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java +++ b/samples/boot/oauth2resourceserver-jwe/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java @@ -94,7 +94,7 @@ public class MockWebServerPropertySource extends PropertySource i private void intializeMockWebServer(MockWebServer mockWebServer) { Dispatcher dispatcher = new Dispatcher() { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { if ("/.well-known/jwks.json".equals(request.getPath())) { return JWKS_RESPONSE; } diff --git a/samples/boot/oauth2resourceserver-webflux/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java b/samples/boot/oauth2resourceserver-webflux/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java index 96c4c3875f..54dc2ca143 100644 --- a/samples/boot/oauth2resourceserver-webflux/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java +++ b/samples/boot/oauth2resourceserver-webflux/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java @@ -93,7 +93,7 @@ public class MockWebServerPropertySource extends PropertySource i private void intializeMockWebServer(MockWebServer mockWebServer) { Dispatcher dispatcher = new Dispatcher() { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { if ("/.well-known/jwks.json".equals(request.getPath())) { return JWKS_RESPONSE; } diff --git a/samples/boot/oauth2resourceserver-webflux/src/main/java/sample/SecurityConfig.java b/samples/boot/oauth2resourceserver-webflux/src/main/java/sample/SecurityConfig.java index 5f8f5f45db..fad9309c02 100644 --- a/samples/boot/oauth2resourceserver-webflux/src/main/java/sample/SecurityConfig.java +++ b/samples/boot/oauth2resourceserver-webflux/src/main/java/sample/SecurityConfig.java @@ -32,7 +32,7 @@ import static org.springframework.security.config.Customizer.withDefaults; public class SecurityConfig { @Bean - SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { + SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http .authorizeExchange(exchanges -> exchanges diff --git a/samples/boot/oauth2resourceserver/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java b/samples/boot/oauth2resourceserver/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java index 2a721e69f7..b90ad29b91 100644 --- a/samples/boot/oauth2resourceserver/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java +++ b/samples/boot/oauth2resourceserver/src/main/java/org/springframework/boot/env/MockWebServerPropertySource.java @@ -93,7 +93,7 @@ public class MockWebServerPropertySource extends PropertySource i private void intializeMockWebServer(MockWebServer mockWebServer) { Dispatcher dispatcher = new Dispatcher() { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { if ("/.well-known/jwks.json".equals(request.getPath())) { return JWKS_RESPONSE; } diff --git a/samples/boot/oauth2webclient-webflux/src/main/java/sample/config/SecurityConfig.java b/samples/boot/oauth2webclient-webflux/src/main/java/sample/config/SecurityConfig.java index d2b73b4824..bea4effe96 100644 --- a/samples/boot/oauth2webclient-webflux/src/main/java/sample/config/SecurityConfig.java +++ b/samples/boot/oauth2webclient-webflux/src/main/java/sample/config/SecurityConfig.java @@ -32,7 +32,7 @@ import static org.springframework.security.config.Customizer.withDefaults; public class SecurityConfig { @Bean - SecurityWebFilterChain configure(ServerHttpSecurity http) throws Exception { + SecurityWebFilterChain configure(ServerHttpSecurity http) { http .authorizeExchange(exchanges -> exchanges diff --git a/samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java b/samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java index 20d26327f2..41cda60a5c 100644 --- a/samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java +++ b/samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java @@ -47,7 +47,7 @@ public class WebfluxFormApplicationTests { } @Test - public void loginWhenInvalidUsernameThenError() throws Exception { + public void loginWhenInvalidUsernameThenError() { LoginPage login = IndexPage.to(this.driver, this.port, LoginPage.class); login.assertAt(); @@ -60,7 +60,7 @@ public class WebfluxFormApplicationTests { } @Test - public void loginAndLogout() throws Exception { + public void loginAndLogout() { LoginPage login = IndexPage.to(this.driver, this.port, LoginPage.class); login.assertAt(); diff --git a/samples/javaconfig/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java b/samples/javaconfig/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java index 0cd9cc6313..1c7cf918bf 100644 --- a/samples/javaconfig/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java +++ b/samples/javaconfig/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java @@ -49,46 +49,46 @@ public class AspectJInterceptorTests { private SecuredService securedService; @Test - public void publicMethod() throws Exception { + public void publicMethod() { service.publicMethod(); } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void securedMethodNotAuthenticated() throws Exception { + public void securedMethodNotAuthenticated() { service.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void securedMethodWrongRole() throws Exception { + public void securedMethodWrongRole() { SecurityContextHolder.getContext().setAuthentication(admin); service.secureMethod(); } @Test - public void securedMethodEverythingOk() throws Exception { + public void securedMethodEverythingOk() { SecurityContextHolder.getContext().setAuthentication(user); service.secureMethod(); } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void securedClassNotAuthenticated() throws Exception { + public void securedClassNotAuthenticated() { securedService.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void securedClassWrongRole() throws Exception { + public void securedClassWrongRole() { SecurityContextHolder.getContext().setAuthentication(admin); securedService.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void securedClassWrongRoleOnNewedInstance() throws Exception { + public void securedClassWrongRoleOnNewedInstance() { SecurityContextHolder.getContext().setAuthentication(admin); new SecuredService().secureMethod(); } @Test - public void securedClassEverythingOk() throws Exception { + public void securedClassEverythingOk() { SecurityContextHolder.getContext().setAuthentication(user); securedService.secureMethod(); new SecuredService().secureMethod(); diff --git a/samples/javaconfig/helloworld/src/main/java/org/springframework/security/samples/config/SecurityConfig.java b/samples/javaconfig/helloworld/src/main/java/org/springframework/security/samples/config/SecurityConfig.java index 954c06d7d3..c3bdfe2417 100644 --- a/samples/javaconfig/helloworld/src/main/java/org/springframework/security/samples/config/SecurityConfig.java +++ b/samples/javaconfig/helloworld/src/main/java/org/springframework/security/samples/config/SecurityConfig.java @@ -27,7 +27,7 @@ public class SecurityConfig { // @formatter:off @Bean - public UserDetailsService userDetailsService() throws Exception { + public UserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build(); return new InMemoryUserDetailsManager(user); } diff --git a/samples/javaconfig/inmemory/src/main/java/org/springframework/security/samples/config/SecurityConfig.java b/samples/javaconfig/inmemory/src/main/java/org/springframework/security/samples/config/SecurityConfig.java index 7d9cfd1950..a657c60795 100644 --- a/samples/javaconfig/inmemory/src/main/java/org/springframework/security/samples/config/SecurityConfig.java +++ b/samples/javaconfig/inmemory/src/main/java/org/springframework/security/samples/config/SecurityConfig.java @@ -27,11 +27,11 @@ public class SecurityConfig { // @formatter:off @Bean - public UserDetailsService userDetailsService() throws Exception { + public UserDetailsService userDetailsService() { User.UserBuilder builder = User.withDefaultPasswordEncoder(); UserDetails user = builder.username("user").password("password").roles("USER").build(); UserDetails admin = builder.username("admin").password("password").roles("USER", "ADMIN").build(); return new InMemoryUserDetailsManager(user, admin); } // @formatter:on -} \ No newline at end of file +} diff --git a/samples/xml/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java b/samples/xml/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java index 51d4fc5e8c..a195b18224 100644 --- a/samples/xml/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java +++ b/samples/xml/aspectj/src/test/java/sample/aspectj/AspectJInterceptorTests.java @@ -43,46 +43,46 @@ public class AspectJInterceptorTests { private SecuredService securedService; @Test - public void testPublicMethod() throws Exception { + public void testPublicMethod() { service.publicMethod(); } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void testSecuredMethodNotAuthenticated() throws Exception { + public void testSecuredMethodNotAuthenticated() { service.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void testSecuredMethodWrongRole() throws Exception { + public void testSecuredMethodWrongRole() { SecurityContextHolder.getContext().setAuthentication(admin); service.secureMethod(); } @Test - public void testSecuredMethodEverythingOk() throws Exception { + public void testSecuredMethodEverythingOk() { SecurityContextHolder.getContext().setAuthentication(user); service.secureMethod(); } @Test(expected = AuthenticationCredentialsNotFoundException.class) - public void testSecuredClassNotAuthenticated() throws Exception { + public void testSecuredClassNotAuthenticated() { securedService.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void testSecuredClassWrongRole() throws Exception { + public void testSecuredClassWrongRole() { SecurityContextHolder.getContext().setAuthentication(admin); securedService.secureMethod(); } @Test(expected = AccessDeniedException.class) - public void testSecuredClassWrongRoleOnNewedInstance() throws Exception { + public void testSecuredClassWrongRoleOnNewedInstance() { SecurityContextHolder.getContext().setAuthentication(admin); new SecuredService().secureMethod(); } @Test - public void testSecuredClassEverythingOk() throws Exception { + public void testSecuredClassEverythingOk() { SecurityContextHolder.getContext().setAuthentication(user); securedService.secureMethod(); new SecuredService().secureMethod(); diff --git a/samples/xml/cas/cassample/src/main/java/org/springframework/security/samples/cas/web/ProxyTicketSampleServlet.java b/samples/xml/cas/cassample/src/main/java/org/springframework/security/samples/cas/web/ProxyTicketSampleServlet.java index 6115d2b953..29f6241644 100644 --- a/samples/xml/cas/cassample/src/main/java/org/springframework/security/samples/cas/web/ProxyTicketSampleServlet.java +++ b/samples/xml/cas/cassample/src/main/java/org/springframework/security/samples/cas/web/ProxyTicketSampleServlet.java @@ -45,7 +45,7 @@ public final class ProxyTicketSampleServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws IOException { // NOTE: The CasAuthenticationToken can also be obtained using // SecurityContextHolder.getContext().getAuthentication() final CasAuthenticationToken token = (CasAuthenticationToken) request diff --git a/samples/xml/contacts/src/main/java/sample/contact/ContactManagerBackend.java b/samples/xml/contacts/src/main/java/sample/contact/ContactManagerBackend.java index 9c6c24a01f..ea7eabba7b 100644 --- a/samples/xml/contacts/src/main/java/sample/contact/ContactManagerBackend.java +++ b/samples/xml/contacts/src/main/java/sample/contact/ContactManagerBackend.java @@ -59,7 +59,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport implements // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(contactDao, "contactDao required"); Assert.notNull(mutableAclService, "mutableAclService required"); } diff --git a/samples/xml/contacts/src/main/java/sample/contact/DataSourcePopulator.java b/samples/xml/contacts/src/main/java/sample/contact/DataSourcePopulator.java index 290b694d17..c58b1fd76c 100644 --- a/samples/xml/contacts/src/main/java/sample/contact/DataSourcePopulator.java +++ b/samples/xml/contacts/src/main/java/sample/contact/DataSourcePopulator.java @@ -63,7 +63,7 @@ public class DataSourcePopulator implements InitializingBean { // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(mutableAclService, "mutableAclService required"); Assert.notNull(template, "dataSource required"); Assert.notNull(tt, "platformTransactionManager required"); diff --git a/samples/xml/dms/src/main/java/sample/dms/DataSourcePopulator.java b/samples/xml/dms/src/main/java/sample/dms/DataSourcePopulator.java index 08c5294512..9e2250c288 100755 --- a/samples/xml/dms/src/main/java/sample/dms/DataSourcePopulator.java +++ b/samples/xml/dms/src/main/java/sample/dms/DataSourcePopulator.java @@ -45,7 +45,7 @@ public class DataSourcePopulator implements InitializingBean { this.documentDao = documentDao; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { // ACL tables template.execute("CREATE TABLE ACL_SID(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,PRINCIPAL BOOLEAN NOT NULL,SID VARCHAR_IGNORECASE(100) NOT NULL,CONSTRAINT UNIQUE_UK_1 UNIQUE(SID,PRINCIPAL));"); template.execute("CREATE TABLE ACL_CLASS(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,CLASS VARCHAR_IGNORECASE(100) NOT NULL,CLASS_ID_TYPE VARCHAR_IGNORECASE(100),CONSTRAINT UNIQUE_UK_2 UNIQUE(CLASS));"); diff --git a/samples/xml/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java b/samples/xml/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java index 8fd1600ab6..1d828d4032 100644 --- a/samples/xml/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java +++ b/samples/xml/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java @@ -120,7 +120,7 @@ public class GaeAuthenticationFilter extends GenericFilterBean { } @Override - public void afterPropertiesSet() throws ServletException { + public void afterPropertiesSet() { Assert.notNull(authenticationManager, "AuthenticationManager must be set"); } diff --git a/samples/xml/gae/src/main/java/samples/gae/security/GoogleAccountsAuthenticationEntryPoint.java b/samples/xml/gae/src/main/java/samples/gae/security/GoogleAccountsAuthenticationEntryPoint.java index 51bb8dff68..3802f8cb58 100644 --- a/samples/xml/gae/src/main/java/samples/gae/security/GoogleAccountsAuthenticationEntryPoint.java +++ b/samples/xml/gae/src/main/java/samples/gae/security/GoogleAccountsAuthenticationEntryPoint.java @@ -30,7 +30,7 @@ import com.google.appengine.api.users.UserServiceFactory; public class GoogleAccountsAuthenticationEntryPoint implements AuthenticationEntryPoint { public void commence(HttpServletRequest request, HttpServletResponse response, - AuthenticationException authException) throws IOException, ServletException { + AuthenticationException authException) throws IOException { UserService userService = UserServiceFactory.getUserService(); response.sendRedirect(userService.createLoginURL(request.getRequestURI())); diff --git a/samples/xml/gae/src/test/java/samples/gae/security/AppRoleTests.java b/samples/xml/gae/src/test/java/samples/gae/security/AppRoleTests.java index fd1a287992..be7eb06751 100644 --- a/samples/xml/gae/src/test/java/samples/gae/security/AppRoleTests.java +++ b/samples/xml/gae/src/test/java/samples/gae/security/AppRoleTests.java @@ -34,7 +34,7 @@ public class AppRoleTests { } @Test - public void bitsAreCorrect() throws Exception { + public void bitsAreCorrect() { // If this fails, someone has modified the Enum and the Datastore is probably // corrupt! assertThat(ADMIN.getBit()).isZero(); diff --git a/samples/xml/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java b/samples/xml/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java index 8c16a15c8a..28e6eb964d 100644 --- a/samples/xml/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java +++ b/samples/xml/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java @@ -35,12 +35,12 @@ public class GaeDataStoreUserRegistryTests { new LocalDatastoreServiceTestConfig()); @Before - public void setUp() throws Exception { + public void setUp() { helper.setUp(); } @After - public void tearDown() throws Exception { + public void tearDown() { helper.tearDown(); } diff --git a/samples/xml/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java b/samples/xml/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java index d4d039414d..fe6fc7ba83 100644 --- a/samples/xml/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java +++ b/samples/xml/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java @@ -45,12 +45,12 @@ public class UsernameEqualsPasswordLoginModule implements LoginModule { // ======================================================================================================== @Override - public boolean abort() throws LoginException { + public boolean abort() { return true; } @Override - public boolean commit() throws LoginException { + public boolean commit() { return true; } @@ -87,7 +87,7 @@ public class UsernameEqualsPasswordLoginModule implements LoginModule { } @Override - public boolean logout() throws LoginException { + public boolean logout() { return true; } diff --git a/samples/xml/servletapi/src/main/java/org/springframework/security/samples/servletapi/mvc/ServletApiController.java b/samples/xml/servletapi/src/main/java/org/springframework/security/samples/servletapi/mvc/ServletApiController.java index bebd9f52e0..95170c1e9a 100644 --- a/samples/xml/servletapi/src/main/java/org/springframework/security/samples/servletapi/mvc/ServletApiController.java +++ b/samples/xml/servletapi/src/main/java/org/springframework/security/samples/servletapi/mvc/ServletApiController.java @@ -102,12 +102,10 @@ public class ServletApiController { * @param loginForm * @param result * @return - * @throws ServletException */ @RequestMapping(value = "/login", method = RequestMethod.POST) public String login(HttpServletRequest request, HttpServletResponse response, - @ModelAttribute LoginForm loginForm, BindingResult result) - throws ServletException { + @ModelAttribute LoginForm loginForm, BindingResult result) { try { request.login(loginForm.getUsername(), loginForm.getPassword()); } diff --git a/samples/xml/tutorial/src/main/java/bigbank/SeedData.java b/samples/xml/tutorial/src/main/java/bigbank/SeedData.java index 04a0585824..21b7791c0d 100644 --- a/samples/xml/tutorial/src/main/java/bigbank/SeedData.java +++ b/samples/xml/tutorial/src/main/java/bigbank/SeedData.java @@ -21,7 +21,7 @@ import org.springframework.util.Assert; public class SeedData implements InitializingBean { private BankDao bankDao; - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(bankDao, "bankDao cannot be null"); bankDao.createOrUpdateAccount(new Account("rod")); bankDao.createOrUpdateAccount(new Account("dianne")); diff --git a/samples/xml/tutorial/src/main/java/bigbank/web/ListAccounts.java b/samples/xml/tutorial/src/main/java/bigbank/web/ListAccounts.java index cab8d23403..f17aad051b 100644 --- a/samples/xml/tutorial/src/main/java/bigbank/web/ListAccounts.java +++ b/samples/xml/tutorial/src/main/java/bigbank/web/ListAccounts.java @@ -34,7 +34,7 @@ public class ListAccounts implements Controller { } public ModelAndView handleRequest(HttpServletRequest request, - HttpServletResponse response) throws Exception { + HttpServletResponse response) { // Security check (this is unnecessary if Spring Security is performing the // authorization) // if (request.getUserPrincipal() == null) { diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java index dbca2ae1eb..e740ffb6ec 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java @@ -149,7 +149,7 @@ public class AuthenticationTag extends TagSupport { /** * Set HTML escaping for this tag, as boolean value. */ - public void setHtmlEscape(String htmlEscape) throws JspException { + public void setHtmlEscape(String htmlEscape) { this.htmlEscape = Boolean.parseBoolean(htmlEscape); } diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java index 65eaf1af5b..d768b992a6 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java @@ -156,7 +156,7 @@ public class AuthenticationTagTests { return lastMessage; } - protected void writeMessage(String msg) throws JspException { + protected void writeMessage(String msg) { lastMessage = msg; } } diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java index caa408d9c5..25c8e926e3 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java @@ -62,7 +62,7 @@ public class AuthorizeTagTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { SecurityContextHolder.getContext().setAuthentication(currentUser); StaticWebApplicationContext ctx = new StaticWebApplicationContext(); @@ -82,7 +82,7 @@ public class AuthorizeTagTests { } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } diff --git a/test/src/main/java/org/springframework/security/test/context/support/ReactorContextTestExecutionListener.java b/test/src/main/java/org/springframework/security/test/context/support/ReactorContextTestExecutionListener.java index 8c8cec6cc2..0ad8200938 100644 --- a/test/src/main/java/org/springframework/security/test/context/support/ReactorContextTestExecutionListener.java +++ b/test/src/main/java/org/springframework/security/test/context/support/ReactorContextTestExecutionListener.java @@ -58,13 +58,13 @@ public class ReactorContextTestExecutionListener private static class DelegateTestExecutionListener extends AbstractTestExecutionListener { @Override - public void beforeTestMethod(TestContext testContext) throws Exception { + public void beforeTestMethod(TestContext testContext) { SecurityContext securityContext = TestSecurityContextHolder.getContext(); Hooks.onLastOperator(CONTEXT_OPERATOR_KEY, Operators.lift((s, sub) -> new SecuritySubContext<>(sub, securityContext))); } @Override - public void afterTestMethod(TestContext testContext) throws Exception { + public void afterTestMethod(TestContext testContext) { Hooks.resetOnLastOperator(CONTEXT_OPERATOR_KEY); } diff --git a/test/src/main/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListener.java b/test/src/main/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListener.java index c03d02682d..72259a549b 100644 --- a/test/src/main/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListener.java +++ b/test/src/main/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListener.java @@ -58,7 +58,7 @@ public class WithSecurityContextTestExecutionListener * still not found, then no {@link SecurityContext} is populated. */ @Override - public void beforeTestMethod(TestContext testContext) throws Exception { + public void beforeTestMethod(TestContext testContext) { TestSecurityContext testSecurityContext = createTestSecurityContext( testContext.getTestMethod(), testContext); if (testSecurityContext == null) { @@ -166,7 +166,7 @@ public class WithSecurityContextTestExecutionListener * {@link SecurityContextHolder} after each test method. */ @Override - public void afterTestMethod(TestContext testContext) throws Exception { + public void afterTestMethod(TestContext testContext) { TestSecurityContextHolder.clearContext(); } diff --git a/test/src/main/java/org/springframework/security/test/web/servlet/response/SecurityMockMvcResultMatchers.java b/test/src/main/java/org/springframework/security/test/web/servlet/response/SecurityMockMvcResultMatchers.java index c3c976216d..a4f93652ac 100644 --- a/test/src/main/java/org/springframework/security/test/web/servlet/response/SecurityMockMvcResultMatchers.java +++ b/test/src/main/java/org/springframework/security/test/web/servlet/response/SecurityMockMvcResultMatchers.java @@ -92,7 +92,7 @@ public final class SecurityMockMvcResultMatchers { private Consumer assertAuthentication; @Override - public void match(MvcResult result) throws Exception { + public void match(MvcResult result) { SecurityContext context = load(result); Authentication auth = context.getAuthentication(); @@ -252,7 +252,7 @@ public final class SecurityMockMvcResultMatchers { private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); @Override - public void match(MvcResult result) throws Exception { + public void match(MvcResult result) { SecurityContext context = load(result); Authentication authentication = context.getAuthentication(); diff --git a/test/src/test/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListenerTests.java b/test/src/test/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListenerTests.java index de7004b5fc..fe7804f2c2 100644 --- a/test/src/test/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListenerTests.java +++ b/test/src/test/java/org/springframework/security/test/context/support/WithSecurityContextTestExecutionListenerTests.java @@ -106,14 +106,14 @@ public class WithSecurityContextTestExecutionListenerTests { } @Test - public void beforeTestExecutionWhenTestContextNullThenSecurityContextNotSet() throws Exception { + public void beforeTestExecutionWhenTestContextNullThenSecurityContextNotSet() { this.listener.beforeTestExecution(this.testContext); assertThat(TestSecurityContextHolder.getContext().getAuthentication()).isNull(); } @Test - public void beforeTestExecutionWhenTestContextNotNullThenSecurityContextSet() throws Exception { + public void beforeTestExecutionWhenTestContextNotNullThenSecurityContextSet() { SecurityContextImpl securityContext = new SecurityContextImpl(); securityContext.setAuthentication(new TestingAuthenticationToken("user", "passsword", "ROLE_USER")); when(this.testContext.removeAttribute(WithSecurityContextTestExecutionListener.SECURITY_CONTEXT_ATTR_NAME)).thenReturn(securityContext); diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLoginTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLoginTests.java index f1dd688191..cb533bed11 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLoginTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLoginTests.java @@ -31,12 +31,12 @@ public class SecurityMockMvcRequestBuildersFormLoginTests { private MockServletContext servletContext; @Before - public void setup() throws Exception { + public void setup() { this.servletContext = new MockServletContext(); } @Test - public void defaults() throws Exception { + public void defaults() { MockHttpServletRequest request = formLogin().buildRequest(this.servletContext); CsrfToken token = (CsrfToken) request .getAttribute(CsrfRequestPostProcessor.TestCsrfTokenRepository.TOKEN_ATTR_NAME); @@ -51,7 +51,7 @@ public class SecurityMockMvcRequestBuildersFormLoginTests { } @Test - public void custom() throws Exception { + public void custom() { MockHttpServletRequest request = formLogin("/login").user("username", "admin") .password("password", "secret").buildRequest(this.servletContext); @@ -68,7 +68,7 @@ public class SecurityMockMvcRequestBuildersFormLoginTests { // gh-3920 @Test - public void usesAcceptMediaForContentNegotiation() throws Exception { + public void usesAcceptMediaForContentNegotiation() { MockHttpServletRequest request = formLogin("/login").user("username", "admin") .password("password", "secret").buildRequest(this.servletContext); diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLogoutTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLogoutTests.java index 6904930ad9..522f685c2f 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLogoutTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestBuildersFormLogoutTests.java @@ -34,7 +34,7 @@ public class SecurityMockMvcRequestBuildersFormLogoutTests { } @Test - public void defaults() throws Exception { + public void defaults() { MockHttpServletRequest request = logout().buildRequest(servletContext); CsrfToken token = (CsrfToken) request.getAttribute(CsrfRequestPostProcessor.TestCsrfTokenRepository.TOKEN_ATTR_NAME); @@ -46,7 +46,7 @@ public class SecurityMockMvcRequestBuildersFormLogoutTests { } @Test - public void custom() throws Exception { + public void custom() { MockHttpServletRequest request = logout("/admin/logout").buildRequest( servletContext); diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests.java index 48bca39b30..b65a219236 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests.java @@ -44,7 +44,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests { // SEC-3836 @Test - public void findCookieCsrfTokenRepository() throws Exception { + public void findCookieCsrfTokenRepository() { MockHttpServletRequest request = post("/").buildRequest(wac.getServletContext()); CsrfTokenRepository csrfTokenRepository = WebTestUtils.getCsrfTokenRepository(request); assertThat(csrfTokenRepository).isNotNull(); @@ -61,9 +61,9 @@ public class SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests { } @Override - public void configure(WebSecurity web) throws Exception { + public void configure(WebSecurity web) { // Enable the DebugFilter web.debug(true); } } -} \ No newline at end of file +} diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfTests.java index 6f85c3b11b..26caba94e7 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsCsrfTests.java @@ -172,7 +172,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests { static class CsrfParamResultMatcher implements ResultMatcher { @Override - public void match(MvcResult result) throws Exception { + public void match(MvcResult result) { MockHttpServletRequest request = result.getRequest(); assertThat(request.getParameter("_csrf")).isNotNull(); assertThat(request.getHeader("X-CSRF-TOKEN")).isNull(); @@ -186,7 +186,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests { static class CsrfHeaderResultMatcher implements ResultMatcher { @Override - public void match(MvcResult result) throws Exception { + public void match(MvcResult result) { MockHttpServletRequest request = result.getRequest(); assertThat(request.getParameter("_csrf")).isNull(); assertThat(request.getHeader("X-CSRF-TOKEN")).isNotNull(); @@ -224,7 +224,7 @@ public class SecurityMockMvcRequestPostProcessorsCsrfTests { @EnableWebSecurity static class Config extends WebSecurityConfigurerAdapter { @Override - protected void configure(HttpSecurity http) throws Exception { + protected void configure(HttpSecurity http) { } @RestController diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsDigestTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsDigestTests.java index 852f939fde..39bae21942 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsDigestTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/request/SecurityMockMvcRequestPostProcessorsDigestTests.java @@ -116,8 +116,7 @@ public class SecurityMockMvcRequestPostProcessorsDigestTests { private String extractUser() throws IOException, ServletException { filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain() { @Override - public void doFilter(ServletRequest request, ServletResponse response) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); username = authentication == null ? null : authentication.getName(); diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/setup/SecurityMockMvcConfigurerTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/setup/SecurityMockMvcConfigurerTests.java index eb4c41567f..d75220f0e1 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/setup/SecurityMockMvcConfigurerTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/setup/SecurityMockMvcConfigurerTests.java @@ -89,14 +89,14 @@ public class SecurityMockMvcConfigurerTests { } @Test(expected = IllegalStateException.class) - public void beforeMockMvcCreatedNoFilter() throws Exception { + public void beforeMockMvcCreatedNoFilter() { SecurityMockMvcConfigurer configurer = new SecurityMockMvcConfigurer(); configurer.afterConfigurerAdded(this.builder); configurer.beforeMockMvcCreated(this.builder, this.context); } - private void assertFilterAdded(Filter filter) throws IOException, ServletException { + private void assertFilterAdded(Filter filter) { ArgumentCaptor filterArg = ArgumentCaptor.forClass( SecurityMockMvcConfigurer.DelegateFilter.class); verify(this.builder).addFilters(filterArg.capture()); diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/CsrfShowcaseTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/CsrfShowcaseTests.java index e18e483c86..bf5f71edfe 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/CsrfShowcaseTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/CsrfShowcaseTests.java @@ -72,7 +72,7 @@ public class CsrfShowcaseTests { static class Config extends WebSecurityConfigurerAdapter { @Override - protected void configure(HttpSecurity http) throws Exception { + protected void configure(HttpSecurity http) { } // @formatter:off diff --git a/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/DefaultCsrfShowcaseTests.java b/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/DefaultCsrfShowcaseTests.java index 7eecf0b3e8..4554ca660d 100644 --- a/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/DefaultCsrfShowcaseTests.java +++ b/test/src/test/java/org/springframework/security/test/web/servlet/showcase/csrf/DefaultCsrfShowcaseTests.java @@ -67,7 +67,7 @@ public class DefaultCsrfShowcaseTests { static class Config extends WebSecurityConfigurerAdapter { @Override - protected void configure(HttpSecurity http) throws Exception { + protected void configure(HttpSecurity http) { } // @formatter:off diff --git a/test/src/test/java/org/springframework/security/test/web/support/WebTestUtilsTests.java b/test/src/test/java/org/springframework/security/test/web/support/WebTestUtilsTests.java index 9ec789d740..c7aead4ed9 100644 --- a/test/src/test/java/org/springframework/security/test/web/support/WebTestUtilsTests.java +++ b/test/src/test/java/org/springframework/security/test/web/support/WebTestUtilsTests.java @@ -207,7 +207,7 @@ public class WebTestUtilsTests { // @formatter:off @Override - public void configure(HttpSecurity http) throws Exception { + public void configure(HttpSecurity http) { http .antMatcher("/willnotmatchthis"); } diff --git a/web/src/main/java/org/springframework/security/web/FilterInvocation.java b/web/src/main/java/org/springframework/security/web/FilterInvocation.java index 7a52973f4d..871b349cf1 100644 --- a/web/src/main/java/org/springframework/security/web/FilterInvocation.java +++ b/web/src/main/java/org/springframework/security/web/FilterInvocation.java @@ -231,7 +231,7 @@ class DummyRequest extends HttpServletRequestWrapper { } final class UnsupportedOperationExceptionInvocationHandler implements InvocationHandler { - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + public Object invoke(Object proxy, Method method, Object[] args) { throw new UnsupportedOperationException(method + " is not supported"); } } diff --git a/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java index 1380a72639..b1fc58b371 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java @@ -58,7 +58,7 @@ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint { // ======================================================================================================== public void commence(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { + throws IOException { String queryString = request.getQueryString(); String redirectUrl = request.getRequestURI() + ((queryString == null) ? "" : ("?" + queryString)); diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java index 9756516ba4..07c5f66b88 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java @@ -60,7 +60,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notEmpty(channelProcessors, "A list of ChannelProcessors is required"); } diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java index db84cf9d9a..21e17f6aa8 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java @@ -48,5 +48,5 @@ public interface ChannelEntryPoint { * */ void commence(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException; + throws IOException; } diff --git a/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java b/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java index 4a1d9eff21..9130ef3748 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java @@ -50,7 +50,7 @@ public class InsecureChannelProcessor implements InitializingBean, ChannelProces // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasLength(insecureKeyword, "insecureKeyword required"); Assert.notNull(entryPoint, "entryPoint required"); } diff --git a/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java b/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java index 0ac08f2a7f..ea6d1b577f 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java @@ -50,7 +50,7 @@ public class SecureChannelProcessor implements InitializingBean, ChannelProcesso // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasLength(secureKeyword, "secureKeyword required"); Assert.notNull(entryPoint, "entryPoint required"); } diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java b/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java index ebdf33600a..0dd86eeda1 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java @@ -63,9 +63,8 @@ public class FilterSecurityInterceptor extends AbstractSecurityInterceptor imple * * @param arg0 ignored * - * @throws ServletException never thrown */ - public void init(FilterConfig arg0) throws ServletException { + public void init(FilterConfig arg0) { } /** diff --git a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java index 5f7cf4b839..776e6a3472 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java @@ -280,8 +280,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt * @throws AuthenticationException if authentication fails. */ public abstract Authentication attemptAuthentication(HttpServletRequest request, - HttpServletResponse response) throws AuthenticationException, IOException, - ServletException; + HttpServletResponse response) throws AuthenticationException, IOException; /** * Default behaviour for successful authentication. diff --git a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java index 80aeeebe3a..883cab608a 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java @@ -79,7 +79,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler { * The redirect will not be performed if the response has already been committed. */ protected void handle(HttpServletRequest request, HttpServletResponse response, - Authentication authentication) throws IOException, ServletException { + Authentication authentication) throws IOException { String targetUrl = determineTargetUrl(request, response, authentication); if (response.isCommitted()) { diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFilter.java index 0f539842f0..30dda2e377 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFilter.java @@ -167,7 +167,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { } protected Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) - throws AuthenticationException, IOException, ServletException { + throws AuthenticationException, ServletException { Authentication authentication = this.authenticationConverter.convert(request); if (authentication == null) { return null; diff --git a/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java index fd6ce951aa..b69560e66e 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java @@ -102,7 +102,7 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo this.defaultEntryPoint = defaultEntryPoint; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notEmpty(entryPoints, "entryPoints must be specified"); Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified"); } diff --git a/web/src/main/java/org/springframework/security/web/authentication/Http403ForbiddenEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/Http403ForbiddenEntryPoint.java index 00f002dde5..79ae124f21 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/Http403ForbiddenEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/Http403ForbiddenEntryPoint.java @@ -52,10 +52,10 @@ public class Http403ForbiddenEntryPoint implements AuthenticationEntryPoint { * Always returns a 403 error code to the client. */ public void commence(HttpServletRequest request, HttpServletResponse response, - AuthenticationException arg2) throws IOException, ServletException { + AuthenticationException arg2) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Pre-authenticated entry point called. Rejecting access"); } response.sendError(HttpServletResponse.SC_FORBIDDEN, "Access Denied"); } -} \ No newline at end of file +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/HttpStatusEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/HttpStatusEntryPoint.java index b744ff20f0..e013b1540c 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/HttpStatusEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/HttpStatusEntryPoint.java @@ -48,7 +48,7 @@ public final class HttpStatusEntryPoint implements AuthenticationEntryPoint { } public void commence(HttpServletRequest request, HttpServletResponse response, - AuthenticationException authException) throws IOException, ServletException { + AuthenticationException authException) { response.setStatus(httpStatus.value()); } } diff --git a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java index 5bcd829e25..0dff495c20 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java @@ -99,7 +99,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin // ~ Methods // ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.isTrue( StringUtils.hasText(loginFormUrl) && UrlUtils.isValidRedirectUrl(loginFormUrl), @@ -211,8 +211,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin * Builds a URL to redirect the supplied request to HTTPS. Used to redirect the * current request to HTTPS, before doing a forward to the login page. */ - protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) - throws IOException, ServletException { + protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) { int serverPort = portResolver.getServerPort(request); Integer httpsPort = portMapper.lookupHttpsPort(serverPort); diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandler.java index d107e78e24..6d89ff2bb8 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandler.java @@ -63,7 +63,7 @@ public class HttpStatusReturningLogoutSuccessHandler implements LogoutSuccessHan * . Sets the status on the {@link HttpServletResponse}. */ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, - Authentication authentication) throws IOException, ServletException { + Authentication authentication) throws IOException { response.setStatus(this.httpStatusToReturn.value()); response.getWriter().flush(); } diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java index c80ed0d6ef..b04851e0c6 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java @@ -50,7 +50,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource /** * Check that all required properties have been set. */ - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(j2eeMappableRoles, "No mappable roles available"); Assert.notNull(j2eeUserRoles2GrantedAuthoritiesMapper, "Roles to granted authorities mapper not set"); diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java index 4c368412dc..f7764aa270 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java @@ -130,8 +130,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware, * We do not need to resolve external entities, so just return an empty String. */ private static final class MyEntityResolver implements EntityResolver { - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { + public InputSource resolveEntity(String publicId, String systemId) { return new InputSource(new StringReader("")); } } diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java index cf0bfb4a72..a95a555398 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java @@ -94,7 +94,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices, } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.hasLength(key, "key cannot be empty or null"); Assert.notNull(userDetailsService, "A UserDetailsService is required"); } diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java index abb422b0fc..ca696a88fb 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java @@ -56,7 +56,7 @@ public class BasicAuthenticationEntryPoint implements AuthenticationEntryPoint, } public void commence(HttpServletRequest request, HttpServletResponse response, - AuthenticationException authException) throws IOException, ServletException { + AuthenticationException authException) throws IOException { response.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\""); response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase()); } diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java index dfc9bb3703..622c36e830 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java @@ -244,12 +244,11 @@ public class BasicAuthenticationFilter extends OncePerRequestFilter { } protected void onSuccessfulAuthentication(HttpServletRequest request, - HttpServletResponse response, Authentication authResult) throws IOException { + HttpServletResponse response, Authentication authResult) { } protected void onUnsuccessfulAuthentication(HttpServletRequest request, - HttpServletResponse response, AuthenticationException failed) - throws IOException { + HttpServletResponse response, AuthenticationException failed) { } protected AuthenticationEntryPoint getAuthenticationEntryPoint() { diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java index 76de0ddfc1..dcde9161b4 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java @@ -72,7 +72,7 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint, this.order = order; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { if ((realmName == null) || "".equals(realmName)) { throw new IllegalArgumentException("realmName must be specified"); } @@ -83,7 +83,7 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint, } public void commence(HttpServletRequest request, HttpServletResponse response, - AuthenticationException authException) throws IOException, ServletException { + AuthenticationException authException) throws IOException { HttpServletResponse httpResponse = response; // compute a nonce (do not use remote IP address due to proxy farms) diff --git a/web/src/main/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolver.java b/web/src/main/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolver.java index 063c76b044..ea6f0cc9c0 100644 --- a/web/src/main/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolver.java +++ b/web/src/main/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolver.java @@ -107,7 +107,7 @@ public final class AuthenticationPrincipalArgumentResolver */ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - WebDataBinderFactory binderFactory) throws Exception { + WebDataBinderFactory binderFactory) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication == null) { @@ -153,4 +153,4 @@ public final class AuthenticationPrincipalArgumentResolver } return null; } -} \ No newline at end of file +} diff --git a/web/src/main/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.java b/web/src/main/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.java index 7b0e66c96d..805442f928 100644 --- a/web/src/main/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.java +++ b/web/src/main/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.java @@ -106,7 +106,7 @@ public final class CurrentSecurityContextArgumentResolver */ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - WebDataBinderFactory binderFactory) throws Exception { + WebDataBinderFactory binderFactory) { SecurityContext securityContext = SecurityContextHolder.getContext(); if (securityContext == null) { return null; diff --git a/web/src/main/java/org/springframework/security/web/context/AbstractSecurityWebApplicationInitializer.java b/web/src/main/java/org/springframework/security/web/context/AbstractSecurityWebApplicationInitializer.java index f7bf77b885..a235553e20 100644 --- a/web/src/main/java/org/springframework/security/web/context/AbstractSecurityWebApplicationInitializer.java +++ b/web/src/main/java/org/springframework/security/web/context/AbstractSecurityWebApplicationInitializer.java @@ -109,7 +109,7 @@ public abstract class AbstractSecurityWebApplicationInitializer * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet. * ServletContext) */ - public final void onStartup(ServletContext servletContext) throws ServletException { + public final void onStartup(ServletContext servletContext) { beforeSpringSecurityFilterChain(servletContext); if (this.configurationClasses != null) { AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext(); diff --git a/web/src/main/java/org/springframework/security/web/context/request/async/SecurityContextCallableProcessingInterceptor.java b/web/src/main/java/org/springframework/security/web/context/request/async/SecurityContextCallableProcessingInterceptor.java index 82e7eda850..d8e082f370 100644 --- a/web/src/main/java/org/springframework/security/web/context/request/async/SecurityContextCallableProcessingInterceptor.java +++ b/web/src/main/java/org/springframework/security/web/context/request/async/SecurityContextCallableProcessingInterceptor.java @@ -65,22 +65,20 @@ public final class SecurityContextCallableProcessingInterceptor extends } @Override - public void beforeConcurrentHandling(NativeWebRequest request, Callable task) - throws Exception { + public void beforeConcurrentHandling(NativeWebRequest request, Callable task) { if (securityContext == null) { setSecurityContext(SecurityContextHolder.getContext()); } } @Override - public void preProcess(NativeWebRequest request, Callable task) - throws Exception { + public void preProcess(NativeWebRequest request, Callable task) { SecurityContextHolder.setContext(securityContext); } @Override public void postProcess(NativeWebRequest request, Callable task, - Object concurrentResult) throws Exception { + Object concurrentResult) { SecurityContextHolder.clearContext(); } diff --git a/web/src/main/java/org/springframework/security/web/debug/DebugFilter.java b/web/src/main/java/org/springframework/security/web/debug/DebugFilter.java index e0a53d3090..b55320cb51 100644 --- a/web/src/main/java/org/springframework/security/web/debug/DebugFilter.java +++ b/web/src/main/java/org/springframework/security/web/debug/DebugFilter.java @@ -143,7 +143,7 @@ public final class DebugFilter implements Filter { return null; } - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) { } public void destroy() { diff --git a/web/src/main/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.java b/web/src/main/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.java index 7a711e0f88..60ec3c1168 100644 --- a/web/src/main/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.java +++ b/web/src/main/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.java @@ -112,7 +112,7 @@ public final class AuthenticationPrincipalArgumentResolver */ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - WebDataBinderFactory binderFactory) throws Exception { + WebDataBinderFactory binderFactory) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication == null) { @@ -180,4 +180,4 @@ public final class AuthenticationPrincipalArgumentResolver } return null; } -} \ No newline at end of file +} diff --git a/web/src/main/java/org/springframework/security/web/method/annotation/CsrfTokenArgumentResolver.java b/web/src/main/java/org/springframework/security/web/method/annotation/CsrfTokenArgumentResolver.java index 19d113edc9..2b8681c386 100644 --- a/web/src/main/java/org/springframework/security/web/method/annotation/CsrfTokenArgumentResolver.java +++ b/web/src/main/java/org/springframework/security/web/method/annotation/CsrfTokenArgumentResolver.java @@ -68,9 +68,9 @@ public final class CsrfTokenArgumentResolver implements HandlerMethodArgumentRes */ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - WebDataBinderFactory binderFactory) throws Exception { + WebDataBinderFactory binderFactory) { CsrfToken token = (CsrfToken) webRequest.getAttribute(CsrfToken.class.getName(), NativeWebRequest.SCOPE_REQUEST); return token; } -} \ No newline at end of file +} diff --git a/web/src/main/java/org/springframework/security/web/session/ConcurrentSessionFilter.java b/web/src/main/java/org/springframework/security/web/session/ConcurrentSessionFilter.java index 6228203c41..741260472c 100644 --- a/web/src/main/java/org/springframework/security/web/session/ConcurrentSessionFilter.java +++ b/web/src/main/java/org/springframework/security/web/session/ConcurrentSessionFilter.java @@ -192,7 +192,7 @@ public class ConcurrentSessionFilter extends GenericFilterBean { implements SessionInformationExpiredStrategy { @Override public void onExpiredSessionDetected(SessionInformationExpiredEvent event) - throws IOException, ServletException { + throws IOException { HttpServletResponse response = event.getResponse(); response.getWriter().print( "This session has been expired (possibly due to multiple concurrent " diff --git a/web/src/main/java/org/springframework/security/web/session/InvalidSessionStrategy.java b/web/src/main/java/org/springframework/security/web/session/InvalidSessionStrategy.java index f21cb8378b..283a5b30b2 100644 --- a/web/src/main/java/org/springframework/security/web/session/InvalidSessionStrategy.java +++ b/web/src/main/java/org/springframework/security/web/session/InvalidSessionStrategy.java @@ -29,6 +29,6 @@ import java.io.IOException; public interface InvalidSessionStrategy { void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException; + throws IOException; } diff --git a/web/src/main/java/org/springframework/security/web/session/SessionInformationExpiredStrategy.java b/web/src/main/java/org/springframework/security/web/session/SessionInformationExpiredStrategy.java index db2594b79c..105e75cc69 100644 --- a/web/src/main/java/org/springframework/security/web/session/SessionInformationExpiredStrategy.java +++ b/web/src/main/java/org/springframework/security/web/session/SessionInformationExpiredStrategy.java @@ -30,5 +30,5 @@ import javax.servlet.ServletException; public interface SessionInformationExpiredStrategy { void onExpiredSessionDetected(SessionInformationExpiredEvent event) - throws IOException, ServletException; + throws IOException; } diff --git a/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java b/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java index 9451b4b811..c16afe6a21 100644 --- a/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java +++ b/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java @@ -78,7 +78,7 @@ public class FilterChainProxyTests { } @Test - public void toStringCallSucceeds() throws Exception { + public void toStringCallSucceeds() { fcp.afterPropertiesSet(); fcp.toString(); } diff --git a/web/src/test/java/org/springframework/security/web/FilterInvocationTests.java b/web/src/test/java/org/springframework/security/web/FilterInvocationTests.java index d2c57a5d84..e08e1c4d7d 100644 --- a/web/src/test/java/org/springframework/security/web/FilterInvocationTests.java +++ b/web/src/test/java/org/springframework/security/web/FilterInvocationTests.java @@ -130,7 +130,7 @@ public class FilterInvocationTests { } @Test - public void dummyRequestIsSupportedByUrlUtils() throws Exception { + public void dummyRequestIsSupportedByUrlUtils() { DummyRequest request = new DummyRequest(); request.setContextPath(""); request.setRequestURI("/something"); diff --git a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java index e6709763a8..dbcca569a7 100644 --- a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java +++ b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java @@ -34,7 +34,7 @@ public class PortMapperImplTests { // ~ Methods // ======================================================================================================== @Test - public void testDefaultMappingsAreKnown() throws Exception { + public void testDefaultMappingsAreKnown() { PortMapperImpl portMapper = new PortMapperImpl(); assertThat(portMapper.lookupHttpPort(443)).isEqualTo( Integer.valueOf(80)); @@ -47,7 +47,7 @@ public class PortMapperImplTests { } @Test - public void testDetectsEmptyMap() throws Exception { + public void testDetectsEmptyMap() { PortMapperImpl portMapper = new PortMapperImpl(); try { @@ -60,7 +60,7 @@ public class PortMapperImplTests { } @Test - public void testDetectsNullMap() throws Exception { + public void testDetectsNullMap() { PortMapperImpl portMapper = new PortMapperImpl(); try { diff --git a/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java b/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java index 7627d090cb..d4b265588a 100644 --- a/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java +++ b/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java @@ -32,7 +32,7 @@ public class PortResolverImplTests { // ~ Methods // ======================================================================================================== @Test - public void testDetectsBuggyIeHttpRequest() throws Exception { + public void testDetectsBuggyIeHttpRequest() { PortResolverImpl pr = new PortResolverImpl(); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -42,7 +42,7 @@ public class PortResolverImplTests { } @Test - public void testDetectsBuggyIeHttpsRequest() throws Exception { + public void testDetectsBuggyIeHttpsRequest() { PortResolverImpl pr = new PortResolverImpl(); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -52,7 +52,7 @@ public class PortResolverImplTests { } @Test - public void testDetectsEmptyPortMapper() throws Exception { + public void testDetectsEmptyPortMapper() { PortResolverImpl pr = new PortResolverImpl(); try { @@ -65,7 +65,7 @@ public class PortResolverImplTests { } @Test - public void testGettersSetters() throws Exception { + public void testGettersSetters() { PortResolverImpl pr = new PortResolverImpl(); assertThat(pr.getPortMapper() != null).isTrue(); pr.setPortMapper(new PortMapperImpl()); @@ -73,7 +73,7 @@ public class PortResolverImplTests { } @Test - public void testNormalOperation() throws Exception { + public void testNormalOperation() { PortResolverImpl pr = new PortResolverImpl(); MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java index 2db7899e1c..8e69ca83bf 100644 --- a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java @@ -62,8 +62,7 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { } @Test - public void permitsAccessIfNoMatchingAttributesAndPublicInvocationsAllowed() - throws Exception { + public void permitsAccessIfNoMatchingAttributesAndPublicInvocationsAllowed() { DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator( interceptor); when(ods.getAttributes(anyObject())).thenReturn(null); @@ -72,8 +71,7 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { } @Test - public void deniesAccessIfNoMatchingAttributesAndPublicInvocationsNotAllowed() - throws Exception { + public void deniesAccessIfNoMatchingAttributesAndPublicInvocationsNotAllowed() { DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator( interceptor); when(ods.getAttributes(anyObject())).thenReturn(null); @@ -83,14 +81,14 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { } @Test - public void deniesAccessIfAuthenticationIsNull() throws Exception { + public void deniesAccessIfAuthenticationIsNull() { DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator( interceptor); assertThat(wipe.isAllowed("/foo/index.jsp", null)).isFalse(); } @Test - public void allowsAccessIfAccessDecisionManagerDoes() throws Exception { + public void allowsAccessIfAccessDecisionManagerDoes() { Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX"); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator( @@ -100,7 +98,7 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { @SuppressWarnings("unchecked") @Test - public void deniesAccessIfAccessDecisionManagerDoes() throws Exception { + public void deniesAccessIfAccessDecisionManagerDoes() { Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX"); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator( diff --git a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java index bf9c9cbe1a..c26c3b98b4 100644 --- a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java @@ -61,7 +61,7 @@ public class ExceptionTranslationFilterTests { @After @Before - public void clearContext() throws Exception { + public void clearContext() { SecurityContextHolder.clearContext(); } @@ -257,12 +257,12 @@ public class ExceptionTranslationFilterTests { } @Test(expected = IllegalArgumentException.class) - public void startupDetectsMissingAuthenticationEntryPoint() throws Exception { + public void startupDetectsMissingAuthenticationEntryPoint() { new ExceptionTranslationFilter(null); } @Test(expected = IllegalArgumentException.class) - public void startupDetectsMissingRequestCache() throws Exception { + public void startupDetectsMissingRequestCache() { new ExceptionTranslationFilter(mockEntryPoint, null); } @@ -305,7 +305,7 @@ public class ExceptionTranslationFilterTests { } @Test - public void doFilterWhenResponseCommittedThenRethrowsException() throws Exception { + public void doFilterWhenResponseCommittedThenRethrowsException() { this.mockEntryPoint = mock(AuthenticationEntryPoint.class); FilterChain chain = (request, response) -> { HttpServletResponse httpResponse = (HttpServletResponse) response; diff --git a/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java b/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java index 13726a03bf..2ce10b4c92 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java @@ -62,8 +62,7 @@ public class ChannelDecisionManagerImplTests { } @Test - public void testCannotSetIncorrectObjectTypesIntoChannelProcessorsList() - throws Exception { + public void testCannotSetIncorrectObjectTypesIntoChannelProcessorsList() { ChannelDecisionManagerImpl cdm = new ChannelDecisionManagerImpl(); List list = new Vector(); list.add("THIS IS NOT A CHANNELPROCESSOR"); @@ -210,7 +209,7 @@ public class ChannelDecisionManagerImplTests { } public void decide(FilterInvocation invocation, - Collection config) throws IOException, ServletException { + Collection config) throws IOException { Iterator iter = config.iterator(); if (this.failIfCalled) { diff --git a/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java index 06647a7de3..b640f6cdc2 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java @@ -43,7 +43,7 @@ public class ChannelProcessingFilterTests { // ======================================================================================================== @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingChannelDecisionManager() throws Exception { + public void testDetectsMissingChannelDecisionManager() { ChannelProcessingFilter filter = new ChannelProcessingFilter(); MockFilterInvocationDefinitionMap fids = new MockFilterInvocationDefinitionMap( @@ -54,15 +54,14 @@ public class ChannelProcessingFilterTests { } @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingFilterInvocationSecurityMetadataSource() - throws Exception { + public void testDetectsMissingFilterInvocationSecurityMetadataSource() { ChannelProcessingFilter filter = new ChannelProcessingFilter(); filter.setChannelDecisionManager(new MockChannelDecisionManager(false, "MOCK")); filter.afterPropertiesSet(); } @Test - public void testDetectsSupportedConfigAttribute() throws Exception { + public void testDetectsSupportedConfigAttribute() { ChannelProcessingFilter filter = new ChannelProcessingFilter(); filter.setChannelDecisionManager(new MockChannelDecisionManager(false, "SUPPORTS_MOCK_ONLY")); @@ -76,7 +75,7 @@ public class ChannelProcessingFilterTests { } @Test(expected = IllegalArgumentException.class) - public void testDetectsUnsupportedConfigAttribute() throws Exception { + public void testDetectsUnsupportedConfigAttribute() { ChannelProcessingFilter filter = new ChannelProcessingFilter(); filter.setChannelDecisionManager(new MockChannelDecisionManager(false, "SUPPORTS_MOCK_ONLY")); @@ -148,7 +147,7 @@ public class ChannelProcessingFilterTests { } @Test - public void testGetterSetters() throws Exception { + public void testGetterSetters() { ChannelProcessingFilter filter = new ChannelProcessingFilter(); filter.setChannelDecisionManager(new MockChannelDecisionManager(false, "MOCK")); assertThat(filter.getChannelDecisionManager() != null).isTrue(); @@ -175,7 +174,7 @@ public class ChannelProcessingFilterTests { } public void decide(FilterInvocation invocation, Collection config) - throws IOException, ServletException { + throws IOException { if (commitAResponse) { invocation.getHttpResponse().sendRedirect("/redirected"); } diff --git a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java index a4d2140d7e..f9d8bb0769 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java @@ -42,7 +42,7 @@ public class RetryWithHttpEntryPointTests { // ~ Methods // ======================================================================================================== @Test - public void testDetectsMissingPortMapper() throws Exception { + public void testDetectsMissingPortMapper() { RetryWithHttpEntryPoint ep = new RetryWithHttpEntryPoint(); try { @@ -54,7 +54,7 @@ public class RetryWithHttpEntryPointTests { } @Test - public void testDetectsMissingPortResolver() throws Exception { + public void testDetectsMissingPortResolver() { RetryWithHttpEntryPoint ep = new RetryWithHttpEntryPoint(); try { diff --git a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java index 430ddb2925..921cbeef70 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java @@ -38,7 +38,7 @@ public class RetryWithHttpsEntryPointTests { // ~ Methods // ======================================================================================================== @Test - public void testDetectsMissingPortMapper() throws Exception { + public void testDetectsMissingPortMapper() { RetryWithHttpsEntryPoint ep = new RetryWithHttpsEntryPoint(); try { @@ -50,7 +50,7 @@ public class RetryWithHttpsEntryPointTests { } @Test - public void testDetectsMissingPortResolver() throws Exception { + public void testDetectsMissingPortResolver() { RetryWithHttpsEntryPoint ep = new RetryWithHttpsEntryPoint(); try { diff --git a/web/src/test/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandlerTests.java b/web/src/test/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandlerTests.java index 5cec682087..609864e7c3 100644 --- a/web/src/test/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandlerTests.java @@ -63,7 +63,7 @@ public class DefaultWebSecurityExpressionHandlerTests { } @Test - public void expressionPropertiesAreResolvedAgainstAppContextBeans() throws Exception { + public void expressionPropertiesAreResolvedAgainstAppContextBeans() { StaticApplicationContext appContext = new StaticApplicationContext(); RootBeanDefinition bean = new RootBeanDefinition(SecurityConfig.class); bean.getConstructorArgumentValues().addGenericArgumentValue("ROLE_A"); diff --git a/web/src/test/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSourceTests.java b/web/src/test/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSourceTests.java index c627765c28..3f63e8d721 100644 --- a/web/src/test/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSourceTests.java +++ b/web/src/test/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSourceTests.java @@ -51,7 +51,7 @@ public class ExpressionBasedFilterInvocationSecurityMetadataSourceTests { } @Test(expected = IllegalArgumentException.class) - public void invalidExpressionIsRejected() throws Exception { + public void invalidExpressionIsRejected() { LinkedHashMap> requestMap = new LinkedHashMap<>(); requestMap.put(AnyRequestMatcher.INSTANCE, SecurityConfig.createList("hasRole('X'")); diff --git a/web/src/test/java/org/springframework/security/web/access/expression/WebExpressionVoterTests.java b/web/src/test/java/org/springframework/security/web/access/expression/WebExpressionVoterTests.java index 01488e192b..a36abcd489 100644 --- a/web/src/test/java/org/springframework/security/web/access/expression/WebExpressionVoterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/expression/WebExpressionVoterTests.java @@ -46,7 +46,7 @@ public class WebExpressionVoterTests { private Authentication user = new TestingAuthenticationToken("user", "pass", "X"); @Test - public void supportsWebConfigAttributeAndFilterInvocation() throws Exception { + public void supportsWebConfigAttributeAndFilterInvocation() { WebExpressionVoter voter = new WebExpressionVoter(); assertThat(voter.supports(new WebExpressionConfigAttribute(mock(Expression.class), mock(EvaluationContextPostProcessor.class)))).isTrue(); diff --git a/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java b/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java index 69a3842e89..0e1816cea2 100644 --- a/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java +++ b/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java @@ -36,7 +36,7 @@ import org.springframework.security.web.access.expression.WebSecurityExpressionR public class WebSecurityExpressionRootTests { @Test - public void ipAddressMatchesForEqualIpAddresses() throws Exception { + public void ipAddressMatchesForEqualIpAddresses() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRequestURI("/test"); // IPv4 @@ -53,7 +53,7 @@ public class WebSecurityExpressionRootTests { } @Test - public void addressesInIpRangeMatch() throws Exception { + public void addressesInIpRangeMatch() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRequestURI("/test"); WebSecurityExpressionRoot root = new WebSecurityExpressionRoot( diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java index 57bf27362f..26fc69fe5e 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java @@ -133,7 +133,7 @@ public class DefaultFilterInvocationSecurityMetadataSourceTests { // SEC-1236 @Test - public void mixingPatternsWithAndWithoutHttpMethodsIsSupported() throws Exception { + public void mixingPatternsWithAndWithoutHttpMethodsIsSupported() { LinkedHashMap> requestMap = new LinkedHashMap<>(); Collection userAttrs = SecurityConfig.createList("A"); diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java index 6cea52c9a4..9d73f56aa1 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java @@ -60,7 +60,7 @@ public class FilterSecurityInterceptorTests { // ======================================================================================================== @Before - public final void setUp() throws Exception { + public final void setUp() { interceptor = new FilterSecurityInterceptor(); am = mock(AuthenticationManager.class); ods = mock(FilterInvocationSecurityMetadataSource.class); @@ -76,7 +76,7 @@ public class FilterSecurityInterceptorTests { } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java index f4a426b528..29fe0c3d27 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java @@ -66,10 +66,9 @@ public class RequestKeyTests { } /** - * @throws Exception */ @Test - public void keysWithNullUrlFailsAssertion() throws Exception { + public void keysWithNullUrlFailsAssertion() { assertThatThrownBy(() -> new RequestKey(null, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("url cannot be null"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java index 24e2836247..6809ac96a8 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java @@ -85,7 +85,7 @@ public class AbstractAuthenticationProcessingFilterTests { } @Before - public void setUp() throws Exception { + public void setUp() { successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setDefaultTargetUrl("/logged_in.jsp"); failureHandler = new SimpleUrlAuthenticationFailureHandler(); @@ -94,12 +94,12 @@ public class AbstractAuthenticationProcessingFilterTests { } @After - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @Test - public void testDefaultProcessesFilterUrlMatchesWithPathParameter() throws Exception { + public void testDefaultProcessesFilterUrlMatchesWithPathParameter() { MockHttpServletRequest request = createMockAuthenticationRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); MockAuthenticationFilter filter = new MockAuthenticationFilter(); @@ -143,7 +143,7 @@ public class AbstractAuthenticationProcessingFilterTests { } @Test - public void testGettersSetters() throws Exception { + public void testGettersSetters() { AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter(); filter.setAuthenticationManager(mock(AuthenticationManager.class)); filter.setFilterProcessesUrl("/p"); @@ -216,7 +216,7 @@ public class AbstractAuthenticationProcessingFilterTests { } @Test - public void testStartupDetectsInvalidAuthenticationManager() throws Exception { + public void testStartupDetectsInvalidAuthenticationManager() { AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter(); filter.setAuthenticationFailureHandler(failureHandler); successHandler.setDefaultTargetUrl("/"); @@ -234,7 +234,7 @@ public class AbstractAuthenticationProcessingFilterTests { } @Test - public void testStartupDetectsInvalidFilterProcessesUrl() throws Exception { + public void testStartupDetectsInvalidFilterProcessesUrl() { AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter(); filter.setAuthenticationFailureHandler(failureHandler); filter.setAuthenticationManager(mock(AuthenticationManager.class)); @@ -469,8 +469,7 @@ public class AbstractAuthenticationProcessingFilterTests { this.expectToProceed = expectToProceed; } - public void doFilter(ServletRequest request, ServletResponse response) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response) { if (expectToProceed) { } diff --git a/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java index a7205014e0..037006847a 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java @@ -59,17 +59,17 @@ public class AnonymousAuthenticationFilterTests { @Before @After - public void clearContext() throws Exception { + public void clearContext() { SecurityContextHolder.clearContext(); } @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingKey() throws Exception { + public void testDetectsMissingKey() { new AnonymousAuthenticationFilter(null); } @Test(expected = IllegalArgumentException.class) - public void testDetectsUserAttribute() throws Exception { + public void testDetectsUserAttribute() { new AnonymousAuthenticationFilter("qwerty", null, null); } @@ -124,8 +124,7 @@ public class AnonymousAuthenticationFilterTests { this.expectToProceed = expectToProceed; } - public void doFilter(ServletRequest request, ServletResponse response) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response) { if (!expectToProceed) { fail("Did not expect filter chain to proceed"); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java index 85e3608bed..c33910f4fc 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java @@ -72,7 +72,7 @@ public class AuthenticationFilterTests { } @After - public void clearContext() throws Exception { + public void clearContext() { SecurityContextHolder.clearContext(); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java index b78faee771..9981ff4572 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java @@ -37,19 +37,19 @@ public class LoginUrlAuthenticationEntryPointTests { // ======================================================================================================== @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingLoginFormUrl() throws Exception { + public void testDetectsMissingLoginFormUrl() { new LoginUrlAuthenticationEntryPoint(null); } @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingPortMapper() throws Exception { + public void testDetectsMissingPortMapper() { LoginUrlAuthenticationEntryPoint ep = new LoginUrlAuthenticationEntryPoint( "/login"); ep.setPortMapper(null); } @Test(expected = IllegalArgumentException.class) - public void testDetectsMissingPortResolver() throws Exception { + public void testDetectsMissingPortResolver() { LoginUrlAuthenticationEntryPoint ep = new LoginUrlAuthenticationEntryPoint( "/login"); ep.setPortResolver(null); diff --git a/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java index c673ce8ca6..cfc732741e 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java @@ -40,7 +40,7 @@ public class UsernamePasswordAuthenticationFilterTests { // ======================================================================================================== @Test - public void testNormalOperation() throws Exception { + public void testNormalOperation() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, @@ -60,7 +60,7 @@ public class UsernamePasswordAuthenticationFilterTests { } @Test - public void testNullPasswordHandledGracefully() throws Exception { + public void testNullPasswordHandledGracefully() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, @@ -73,7 +73,7 @@ public class UsernamePasswordAuthenticationFilterTests { } @Test - public void testNullUsernameHandledGracefully() throws Exception { + public void testNullUsernameHandledGracefully() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, @@ -86,7 +86,7 @@ public class UsernamePasswordAuthenticationFilterTests { } @Test - public void testUsingDifferentParameterNamesWorksAsExpected() throws ServletException { + public void testUsingDifferentParameterNamesWorksAsExpected() { UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAuthenticationManager(createAuthenticationManager()); filter.setUsernameParameter("x"); @@ -103,7 +103,7 @@ public class UsernamePasswordAuthenticationFilterTests { } @Test - public void testSpacesAreTrimmedCorrectlyFromUsername() throws Exception { + public void testSpacesAreTrimmedCorrectlyFromUsername() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); request.addParameter( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, @@ -144,7 +144,7 @@ public class UsernamePasswordAuthenticationFilterTests { * SEC-571 */ @Test - public void noSessionIsCreatedIfAllowSessionCreationIsFalse() throws Exception { + public void noSessionIsCreatedIfAllowSessionCreationIsFalse() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod("POST"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandlerTests.java b/web/src/test/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandlerTests.java index d4cfc9e20f..f0ee41cc4f 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/logout/HttpStatusReturningLogoutSuccessHandlerTests.java @@ -64,7 +64,7 @@ public class HttpStatusReturningLogoutSuccessHandlerTests { } @Test - public void testThatSettNullHttpStatusThrowsException() throws Exception { + public void testThatSettNullHttpStatusThrowsException() { try { new HttpStatusReturningLogoutSuccessHandler(null); diff --git a/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java b/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java index 6f090e33ee..bc3edb1e30 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java @@ -31,7 +31,7 @@ import org.springframework.security.web.firewall.DefaultHttpFirewall; public class LogoutHandlerTests { LogoutFilter filter; @Before - public void setUp() throws Exception { + public void setUp() { filter = new LogoutFilter("/success", new SecurityContextLogoutHandler()); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java index ceb01891bf..e741cef7b9 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java @@ -116,7 +116,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { // SEC-2045 @Test - public void testAfterPropertiesSetInvokesSuper() throws Exception { + public void testAfterPropertiesSetInvokesSuper() { ConcretePreAuthenticatedProcessingFilter filter = new ConcretePreAuthenticatedProcessingFilter(); AuthenticationManager am = mock(AuthenticationManager.class); filter.setAuthenticationManager(am); @@ -384,8 +384,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { grantAccess); } - private static ConcretePreAuthenticatedProcessingFilter getFilter(boolean grantAccess) - throws Exception { + private static ConcretePreAuthenticatedProcessingFilter getFilter(boolean grantAccess) { ConcretePreAuthenticatedProcessingFilter filter = new ConcretePreAuthenticatedProcessingFilter(); AuthenticationManager am = mock(AuthenticationManager.class); diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java index 959b5ad4e6..1ed6001680 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java @@ -52,7 +52,7 @@ public class PreAuthenticatedAuthenticationProviderTests { } @Test - public final void nullPrincipalReturnsNullAuthentication() throws Exception { + public final void nullPrincipalReturnsNullAuthentication() { PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider(); Authentication request = new PreAuthenticatedAuthenticationToken(null, "dummyPwd"); @@ -115,8 +115,7 @@ public class PreAuthenticatedAuthenticationProviderTests { assertThat(333).isEqualTo(provider.getOrder()); } - private PreAuthenticatedAuthenticationProvider getProvider(UserDetails aUserDetails) - throws Exception { + private PreAuthenticatedAuthenticationProvider getProvider(UserDetails aUserDetails) { PreAuthenticatedAuthenticationProvider result = new PreAuthenticatedAuthenticationProvider(); result.setPreAuthenticatedUserDetailsService( getPreAuthenticatedUserDetailsService(aUserDetails)); diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java index 64205edc6a..9e4b50bb00 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java @@ -37,7 +37,7 @@ public class SubjectDnX509PrincipalExtractorTests { } @Test(expected = IllegalArgumentException.class) - public void invalidRegexFails() throws Exception { + public void invalidRegexFails() { extractor.setSubjectDnRegex("CN=(.*?,"); // missing closing bracket on group } diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java index 102e451ff2..11adf5f758 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java @@ -86,7 +86,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void cookieShouldBeCorrectlyEncodedAndDecoded() throws Exception { + public void cookieShouldBeCorrectlyEncodedAndDecoded() { String[] cookie = new String[] { "name:with:colon", "cookie", "tokens", "blah" }; MockRememberMeServices services = new MockRememberMeServices(uds); @@ -99,7 +99,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void cookieWithOpenIDidentifierAsNameIsEncodedAndDecoded() throws Exception { + public void cookieWithOpenIDidentifierAsNameIsEncodedAndDecoded() { String[] cookie = new String[] { "https://id.openid.zz", "cookie", "tokens", "blah" }; MockRememberMeServices services = new MockRememberMeServices(uds); @@ -153,7 +153,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void autoLoginShouldFailIfCookieIsNotBase64() throws Exception { + public void autoLoginShouldFailIfCookieIsNotBase64() { MockRememberMeServices services = new MockRememberMeServices(uds); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -167,7 +167,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void autoLoginShouldFailIfCookieIsEmpty() throws Exception { + public void autoLoginShouldFailIfCookieIsEmpty() { MockRememberMeServices services = new MockRememberMeServices(uds); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -246,7 +246,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void logoutShouldCancelCookie() throws Exception { + public void logoutShouldCancelCookie() { MockRememberMeServices services = new MockRememberMeServices(uds); services.setCookieDomain("spring.io"); @@ -347,7 +347,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void setCookieSetsSecureFlagIfConfigured() throws Exception { + public void setCookieSetsSecureFlagIfConfigured() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); request.setContextPath("contextpath"); @@ -366,7 +366,7 @@ public class AbstractRememberMeServicesTests { } @Test - public void setCookieSetsIsHttpOnlyFlagByDefault() throws Exception { + public void setCookieSetsIsHttpOnlyFlagByDefault() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); request.setContextPath("contextpath"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java index 033c1aa615..4e2ce1a683 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java @@ -68,7 +68,7 @@ public class JdbcTokenRepositoryImplTests { } @AfterClass - public static void clearDataSource() throws Exception { + public static void clearDataSource() { dataSource.destroy(); dataSource = null; } diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java index 567dcbf2f1..b44f878fc8 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java @@ -124,7 +124,7 @@ public class PersistentTokenBasedRememberMeServicesTests { } @Test - public void logoutClearsUsersTokenAndCookie() throws Exception { + public void logoutClearsUsersTokenAndCookie() { Cookie cookie = new Cookie("mycookiename", "somevalue"); MockHttpServletRequest request = new MockHttpServletRequest(); request.setCookies(cookie); diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java index 2df01cbca5..845efa8cbb 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java @@ -98,7 +98,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginReturnsNullIfNoCookiePresented() throws Exception { + public void autoLoginReturnsNullIfNoCookiePresented() { MockHttpServletResponse response = new MockHttpServletResponse(); Authentication result = services @@ -109,7 +109,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginIgnoresUnrelatedCookie() throws Exception { + public void autoLoginIgnoresUnrelatedCookie() { Cookie cookie = new Cookie("unrelated_cookie", "foobar"); MockHttpServletRequest request = new MockHttpServletRequest(); request.setCookies(cookie); @@ -122,7 +122,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginReturnsNullForExpiredCookieAndClearsCookie() throws Exception { + public void autoLoginReturnsNullForExpiredCookieAndClearsCookie() { Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, generateCorrectCookieContentForToken( System.currentTimeMillis() - 1000000, "someone", "password", @@ -140,8 +140,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginReturnsNullAndClearsCookieIfMissingThreeTokensInCookieValue() - throws Exception { + public void autoLoginReturnsNullAndClearsCookieIfMissingThreeTokensInCookieValue() { Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, new String( Base64.encodeBase64("x".getBytes()))); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -157,7 +156,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginClearsNonBase64EncodedCookie() throws Exception { + public void autoLoginClearsNonBase64EncodedCookie() { Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, "NOT_BASE_64_ENCODED"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -173,8 +172,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginClearsCookieIfSignatureBlocksDoesNotMatchExpectedValue() - throws Exception { + public void autoLoginClearsCookieIfSignatureBlocksDoesNotMatchExpectedValue() { udsWillReturnUser(); Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, generateCorrectCookieContentForToken( @@ -194,8 +192,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginClearsCookieIfTokenDoesNotContainANumberInCookieValue() - throws Exception { + public void autoLoginClearsCookieIfTokenDoesNotContainANumberInCookieValue() { Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, new String( Base64.encodeBase64("username:NOT_A_NUMBER:signature".getBytes()))); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -211,7 +208,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginClearsCookieIfUserNotFound() throws Exception { + public void autoLoginClearsCookieIfUserNotFound() { udsWillThrowNotFound(); Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, generateCorrectCookieContentForToken( @@ -231,7 +228,7 @@ public class TokenBasedRememberMeServicesTests { } @Test - public void autoLoginWithValidTokenAndUserSucceeds() throws Exception { + public void autoLoginWithValidTokenAndUserSucceeds() { udsWillReturnUser(); Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, generateCorrectCookieContentForToken( @@ -330,7 +327,7 @@ public class TokenBasedRememberMeServicesTests { // SEC-933 @Test - public void obtainPasswordReturnsNullForTokenWithNullCredentials() throws Exception { + public void obtainPasswordReturnsNullForTokenWithNullCredentials() { TestingAuthenticationToken token = new TestingAuthenticationToken("username", null); assertThat(services.retrievePassword(token)).isNull(); @@ -338,8 +335,7 @@ public class TokenBasedRememberMeServicesTests { // SEC-949 @Test - public void negativeValidityPeriodIsSetOnCookieButExpiryTimeRemainsAtTwoWeeks() - throws Exception { + public void negativeValidityPeriodIsSetOnCookieButExpiryTimeRemainsAtTwoWeeks() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(DEFAULT_PARAMETER, "true"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlAuthenticationStrategyTests.java b/web/src/test/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlAuthenticationStrategyTests.java index b007449061..b993fcbe40 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlAuthenticationStrategyTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlAuthenticationStrategyTests.java @@ -57,7 +57,7 @@ public class ConcurrentSessionControlAuthenticationStrategyTests { private ConcurrentSessionControlAuthenticationStrategy strategy; @Before - public void setup() throws Exception { + public void setup() { authentication = new TestingAuthenticationToken("user", "password", "ROLE_USER"); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); diff --git a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java index 05f8060931..af2e24a76d 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java @@ -171,7 +171,7 @@ public class SwitchUserFilterTests { } @Test(expected = UsernameNotFoundException.class) - public void attemptSwitchToUnknownUserFails() throws Exception { + public void attemptSwitchToUnknownUserFails() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(SwitchUserFilter.SPRING_SECURITY_SWITCH_USERNAME_KEY, @@ -183,27 +183,27 @@ public class SwitchUserFilterTests { } @Test(expected = DisabledException.class) - public void attemptSwitchToUserThatIsDisabledFails() throws Exception { + public void attemptSwitchToUserThatIsDisabledFails() { switchToUser("mcgarrett"); } @Test(expected = AccountExpiredException.class) - public void attemptSwitchToUserWithAccountExpiredFails() throws Exception { + public void attemptSwitchToUserWithAccountExpiredFails() { switchToUser("wofat"); } @Test(expected = CredentialsExpiredException.class) - public void attemptSwitchToUserWithExpiredCredentialsFails() throws Exception { + public void attemptSwitchToUserWithExpiredCredentialsFails() { switchToUser("steve"); } @Test(expected = UsernameNotFoundException.class) - public void switchUserWithNullUsernameThrowsException() throws Exception { + public void switchUserWithNullUsernameThrowsException() { switchToUser(null); } @Test - public void attemptSwitchUserIsSuccessfulWithValidUser() throws Exception { + public void attemptSwitchUserIsSuccessfulWithValidUser() { assertThat(switchToUser("jacklord")).isNotNull(); } @@ -245,7 +245,7 @@ public class SwitchUserFilterTests { } @Test(expected = IllegalArgumentException.class) - public void configMissingUserDetailsServiceFails() throws Exception { + public void configMissingUserDetailsServiceFails() { SwitchUserFilter filter = new SwitchUserFilter(); filter.setSwitchUserUrl("/login/impersonate"); filter.setExitUserUrl("/logout/impersonate"); @@ -254,7 +254,7 @@ public class SwitchUserFilterTests { } @Test(expected = IllegalArgumentException.class) - public void testBadConfigMissingTargetUrl() throws Exception { + public void testBadConfigMissingTargetUrl() { SwitchUserFilter filter = new SwitchUserFilter(); filter.setUserDetailsService(new MockUserDetailsService()); filter.setSwitchUserUrl("/login/impersonate"); @@ -454,7 +454,7 @@ public class SwitchUserFilterTests { // SEC-1763 @Test - public void nestedSwitchesAreNotAllowed() throws Exception { + public void nestedSwitchesAreNotAllowed() { // original user UsernamePasswordAuthenticationToken source = new UsernamePasswordAuthenticationToken( "orig", "hawaii50", ROLES_12); @@ -477,7 +477,7 @@ public class SwitchUserFilterTests { // gh-3697 @Test - public void switchAuthorityRoleCannotBeNull() throws Exception { + public void switchAuthorityRoleCannotBeNull() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("switchAuthorityRole cannot be null"); switchToUserWithAuthorityRole("dano", null); @@ -485,7 +485,7 @@ public class SwitchUserFilterTests { // gh-3697 @Test - public void switchAuthorityRoleCanBeChanged() throws Exception { + public void switchAuthorityRoleCanBeChanged() { String switchAuthorityRole = "PREVIOUS_ADMINISTRATOR"; // original user diff --git a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthorityTests.java b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthorityTests.java index c3921b3712..90ed059cff 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthorityTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthorityTests.java @@ -28,20 +28,18 @@ import org.springframework.security.web.authentication.switchuser.SwitchUserGran public class SwitchUserGrantedAuthorityTests { /** - * @throws Exception */ @Test - public void authorityWithNullRoleFailsAssertion() throws Exception { + public void authorityWithNullRoleFailsAssertion() { assertThatThrownBy(() -> new SwitchUserGrantedAuthority(null, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("role cannot be null"); } /** - * @throws Exception */ @Test - public void authorityWithNullSourceFailsAssertion() throws Exception { + public void authorityWithNullSourceFailsAssertion() { assertThatThrownBy(() -> new SwitchUserGrantedAuthority("role", null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("source cannot be null"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java index e9428943a8..e24499036b 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java @@ -50,7 +50,7 @@ public class BasicAuthenticationConverterTests { } @Test - public void testNormalOperation() throws Exception { + public void testNormalOperation() { String token = "rod:koala"; MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); @@ -74,7 +74,7 @@ public class BasicAuthenticationConverterTests { } @Test - public void testWhenUnsupportedAuthorizationHeaderThenIgnored() throws Exception { + public void testWhenUnsupportedAuthorizationHeaderThenIgnored() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Bearer someOtherToken"); UsernamePasswordAuthenticationToken authentication = converter.convert(request); @@ -84,7 +84,7 @@ public class BasicAuthenticationConverterTests { } @Test(expected = BadCredentialsException.class) - public void testWhenInvalidBasicAuthorizationTokenThenError() throws Exception { + public void testWhenInvalidBasicAuthorizationTokenThenError() { String token = "NOT_A_VALID_TOKEN_AS_MISSING_COLON"; MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); @@ -92,7 +92,7 @@ public class BasicAuthenticationConverterTests { } @Test(expected = BadCredentialsException.class) - public void testWhenInvalidBase64ThenError() throws Exception { + public void testWhenInvalidBase64ThenError() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Basic NOT_VALID_BASE64"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java index 2d5d974d75..d958a42873 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.fail; public class BasicAuthenticationEntryPointTests { @Test - public void testDetectsMissingRealmName() throws Exception { + public void testDetectsMissingRealmName() { BasicAuthenticationEntryPoint ep = new BasicAuthenticationEntryPoint(); try { diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java index 67ec66236d..3b604a3cd1 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java @@ -56,7 +56,7 @@ public class BasicAuthenticationFilterTests { // ======================================================================================================== @Before - public void setUp() throws Exception { + public void setUp() { SecurityContextHolder.clearContext(); UsernamePasswordAuthenticationToken rodRequest = new UsernamePasswordAuthenticationToken( "rod", "koala"); @@ -74,7 +74,7 @@ public class BasicAuthenticationFilterTests { } @After - public void clearContext() throws Exception { + public void clearContext() { SecurityContextHolder.clearContext(); } @@ -208,12 +208,12 @@ public class BasicAuthenticationFilterTests { } @Test(expected = IllegalArgumentException.class) - public void testStartupDetectsMissingAuthenticationEntryPoint() throws Exception { + public void testStartupDetectsMissingAuthenticationEntryPoint() { new BasicAuthenticationFilter(manager, null); } @Test(expected = IllegalArgumentException.class) - public void testStartupDetectsMissingAuthenticationManager() throws Exception { + public void testStartupDetectsMissingAuthenticationManager() { BasicAuthenticationFilter filter = new BasicAuthenticationFilter(null); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java index e1d27eaf77..d41c335644 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java @@ -372,14 +372,14 @@ public class DigestAuthenticationFilterTests { } @Test(expected = IllegalArgumentException.class) - public void startupDetectsMissingAuthenticationEntryPoint() throws Exception { + public void startupDetectsMissingAuthenticationEntryPoint() { DigestAuthenticationFilter filter = new DigestAuthenticationFilter(); filter.setUserDetailsService(mock(UserDetailsService.class)); filter.afterPropertiesSet(); } @Test(expected = IllegalArgumentException.class) - public void startupDetectsMissingUserDetailsService() throws Exception { + public void startupDetectsMissingUserDetailsService() { DigestAuthenticationFilter filter = new DigestAuthenticationFilter(); filter.setAuthenticationEntryPoint(new DigestAuthenticationEntryPoint()); filter.afterPropertiesSet(); diff --git a/web/src/test/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolverTests.java index 6b8fdd0a7f..1ec610ad40 100644 --- a/web/src/test/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/bind/support/AuthenticationPrincipalArgumentResolverTests.java @@ -55,17 +55,17 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void supportsParameterNoAnnotation() throws Exception { + public void supportsParameterNoAnnotation() { assertThat(resolver.supportsParameter(showUserNoAnnotation())).isFalse(); } @Test - public void supportsParameterAnnotation() throws Exception { + public void supportsParameterAnnotation() { assertThat(resolver.supportsParameter(showUserAnnotationObject())).isTrue(); } @Test - public void supportsParameterCustomAnnotation() throws Exception { + public void supportsParameterCustomAnnotation() { assertThat(resolver.supportsParameter(showUserCustomAnnotation())).isTrue(); } diff --git a/web/src/test/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolverTests.java index 4886e5221d..3c7bf65d8e 100644 --- a/web/src/test/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolverTests.java @@ -59,12 +59,12 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void supportsParameterNoAnnotation() throws Exception { + public void supportsParameterNoAnnotation() { assertThat(resolver.supportsParameter(showSecurityContextNoAnnotation())).isFalse(); } @Test - public void supportsParameterAnnotation() throws Exception { + public void supportsParameterAnnotation() { assertThat(resolver.supportsParameter(showSecurityContextAnnotation())).isTrue(); } @@ -103,7 +103,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithNullAuthentication() throws Exception { + public void resolveArgumentWithNullAuthentication() { SecurityContext context = SecurityContextHolder.getContext(); Authentication authentication = context.getAuthentication(); context.setAuthentication(null); @@ -159,7 +159,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentSecurityContextErrorOnInvalidTypeTrue() throws Exception { + public void resolveArgumentSecurityContextErrorOnInvalidTypeTrue() { String principal = "invalid_type_true"; setAuthenticationPrincipal(principal); assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> resolver.resolveArgument(showSecurityContextErrorOnInvalidTypeTrue(), null, @@ -187,7 +187,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenMisMatch() throws Exception { + public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenMisMatch() { assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> resolver.resolveArgument(showCurrentSecurityWithErrorOnInvalidTypeMisMatch(), null, null, null)); } diff --git a/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java b/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java index 229b491ea0..11d951c47c 100644 --- a/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java @@ -134,7 +134,7 @@ public class ConcurrentSessionFilterTests { } @Test(expected = IllegalArgumentException.class) - public void detectsMissingSessionRegistry() throws Exception { + public void detectsMissingSessionRegistry() { new ConcurrentSessionFilter(null); } diff --git a/web/src/test/java/org/springframework/security/web/context/HttpSessionSecurityContextRepositoryTests.java b/web/src/test/java/org/springframework/security/web/context/HttpSessionSecurityContextRepositoryTests.java index 8d7893c09c..2975f61bb1 100644 --- a/web/src/test/java/org/springframework/security/web/context/HttpSessionSecurityContextRepositoryTests.java +++ b/web/src/test/java/org/springframework/security/web/context/HttpSessionSecurityContextRepositoryTests.java @@ -102,7 +102,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void sessionIsntCreatedIfContextDoesntChange() throws Exception { + public void sessionIsntCreatedIfContextDoesntChange() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -115,7 +115,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void sessionIsntCreatedIfAllowSessionCreationIsFalse() throws Exception { + public void sessionIsntCreatedIfAllowSessionCreationIsFalse() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); repo.setAllowSessionCreation(false); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -130,8 +130,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void existingContextIsSuccessFullyLoadedFromSessionAndSavedBack() - throws Exception { + public void existingContextIsSuccessFullyLoadedFromSessionAndSavedBack() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); repo.setSpringSecurityContextKey("imTheContext"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -152,8 +151,7 @@ public class HttpSessionSecurityContextRepositoryTests { // SEC-1528 @Test - public void saveContextCallsSetAttributeIfContextIsModifiedDirectlyDuringRequest() - throws Exception { + public void saveContextCallsSetAttributeIfContextIsModifiedDirectlyDuringRequest() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); // Set up an existing authenticated context, mocking that it is in the session @@ -177,7 +175,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void nonSecurityContextInSessionIsIgnored() throws Exception { + public void nonSecurityContextInSessionIsIgnored() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); SecurityContextHolder.getContext().setAuthentication(testToken); @@ -192,7 +190,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void sessionIsCreatedAndContextStoredWhenContextChanges() throws Exception { + public void sessionIsCreatedAndContextStoredWhenContextChanges() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -404,8 +402,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void noSessionIsCreatedIfSessionWasInvalidatedDuringTheRequest() - throws Exception { + public void noSessionIsCreatedIfSessionWasInvalidatedDuringTheRequest() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); request.getSession(); @@ -422,7 +419,7 @@ public class HttpSessionSecurityContextRepositoryTests { // SEC-1315 @Test - public void noSessionIsCreatedIfAnonymousTokenIsUsed() throws Exception { + public void noSessionIsCreatedIfAnonymousTokenIsUsed() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -439,8 +436,7 @@ public class HttpSessionSecurityContextRepositoryTests { // SEC-1587 @Test - public void contextIsRemovedFromSessionIfCurrentContextIsAnonymous() - throws Exception { + public void contextIsRemovedFromSessionIfCurrentContextIsAnonymous() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); SecurityContext ctxInSession = SecurityContextHolder.createEmptyContext(); @@ -458,7 +454,7 @@ public class HttpSessionSecurityContextRepositoryTests { } @Test - public void contextIsRemovedFromSessionIfCurrentContextIsEmpty() throws Exception { + public void contextIsRemovedFromSessionIfCurrentContextIsEmpty() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); repo.setSpringSecurityContextKey("imTheContext"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -476,8 +472,7 @@ public class HttpSessionSecurityContextRepositoryTests { // SEC-1735 @Test - public void contextIsNotRemovedFromSessionIfContextBeforeExecutionDefault() - throws Exception { + public void contextIsNotRemovedFromSessionIfContextBeforeExecutionDefault() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, @@ -497,7 +492,7 @@ public class HttpSessionSecurityContextRepositoryTests { // SEC-3070 @Test - public void logoutInvalidateSessionFalseFails() throws Exception { + public void logoutInvalidateSessionFalseFails() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); SecurityContext ctxInSession = SecurityContextHolder.createEmptyContext(); @@ -517,8 +512,7 @@ public class HttpSessionSecurityContextRepositoryTests { @Test @SuppressWarnings("deprecation") - public void sessionDisableUrlRewritingPreventsSessionIdBeingWrittenToUrl() - throws Exception { + public void sessionDisableUrlRewritingPreventsSessionIdBeingWrittenToUrl() { HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository(); MockHttpServletRequest request = new MockHttpServletRequest(); final String sessionId = ";jsessionid=id"; diff --git a/web/src/test/java/org/springframework/security/web/context/request/async/WebAsyncManagerIntegrationFilterTests.java b/web/src/test/java/org/springframework/security/web/context/request/async/WebAsyncManagerIntegrationFilterTests.java index 540cf7fed7..42d7cc701c 100644 --- a/web/src/test/java/org/springframework/security/web/context/request/async/WebAsyncManagerIntegrationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/context/request/async/WebAsyncManagerIntegrationFilterTests.java @@ -92,7 +92,7 @@ public class WebAsyncManagerIntegrationFilterTests { .registerCallableInterceptors(new CallableProcessingInterceptorAdapter() { @Override public void postProcess(NativeWebRequest request, - Callable task, Object concurrentResult) throws Exception { + Callable task, Object concurrentResult) { assertThat(SecurityContextHolder.getContext()).isNotSameAs( securityContext); } @@ -113,7 +113,7 @@ public class WebAsyncManagerIntegrationFilterTests { .registerCallableInterceptors(new CallableProcessingInterceptorAdapter() { @Override public void postProcess(NativeWebRequest request, - Callable task, Object concurrentResult) throws Exception { + Callable task, Object concurrentResult) { assertThat(SecurityContextHolder.getContext()).isNotSameAs( securityContext); } @@ -142,7 +142,7 @@ public class WebAsyncManagerIntegrationFilterTests { private class VerifyingCallable implements Callable { - public SecurityContext call() throws Exception { + public SecurityContext call() { return SecurityContextHolder.getContext(); } diff --git a/web/src/test/java/org/springframework/security/web/firewall/DefaultHttpFirewallTests.java b/web/src/test/java/org/springframework/security/web/firewall/DefaultHttpFirewallTests.java index b40d1fe83f..400b7478f0 100644 --- a/web/src/test/java/org/springframework/security/web/firewall/DefaultHttpFirewallTests.java +++ b/web/src/test/java/org/springframework/security/web/firewall/DefaultHttpFirewallTests.java @@ -29,7 +29,7 @@ public class DefaultHttpFirewallTests { "./path", ".//path", "." }; @Test - public void unnormalizedPathsAreRejected() throws Exception { + public void unnormalizedPathsAreRejected() { DefaultHttpFirewall fw = new DefaultHttpFirewall(); MockHttpServletRequest request; diff --git a/web/src/test/java/org/springframework/security/web/firewall/FirewalledResponseTests.java b/web/src/test/java/org/springframework/security/web/firewall/FirewalledResponseTests.java index ccc1c2ebba..ee6ff8edf2 100644 --- a/web/src/test/java/org/springframework/security/web/firewall/FirewalledResponseTests.java +++ b/web/src/test/java/org/springframework/security/web/firewall/FirewalledResponseTests.java @@ -67,14 +67,14 @@ public class FirewalledResponseTests { } @Test - public void addHeaderWhenValidThenDelegateInvoked() throws Exception { + public void addHeaderWhenValidThenDelegateInvoked() { fwResponse.addHeader("foo", "bar"); verify(response).addHeader("foo", "bar"); } @Test - public void addHeaderWhenNullValueThenDelegateInvoked() throws Exception { + public void addHeaderWhenNullValueThenDelegateInvoked() { fwResponse.addHeader("foo", null); verify(response).addHeader("foo", null); diff --git a/web/src/test/java/org/springframework/security/web/firewall/StrictHttpFirewallTests.java b/web/src/test/java/org/springframework/security/web/firewall/StrictHttpFirewallTests.java index 01d97d6493..8695ea7fa6 100644 --- a/web/src/test/java/org/springframework/security/web/firewall/StrictHttpFirewallTests.java +++ b/web/src/test/java/org/springframework/security/web/firewall/StrictHttpFirewallTests.java @@ -90,7 +90,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRequestURINotNormalizedThenThrowsRequestRejectedException() throws Exception { + public void getFirewalledRequestWhenRequestURINotNormalizedThenThrowsRequestRejectedException() { for (String path : this.unnormalizedPaths) { this.request = new MockHttpServletRequest("GET", ""); this.request.setRequestURI(path); @@ -103,7 +103,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenContextPathNotNormalizedThenThrowsRequestRejectedException() throws Exception { + public void getFirewalledRequestWhenContextPathNotNormalizedThenThrowsRequestRejectedException() { for (String path : this.unnormalizedPaths) { this.request = new MockHttpServletRequest("GET", ""); this.request.setContextPath(path); @@ -116,7 +116,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenServletPathNotNormalizedThenThrowsRequestRejectedException() throws Exception { + public void getFirewalledRequestWhenServletPathNotNormalizedThenThrowsRequestRejectedException() { for (String path : this.unnormalizedPaths) { this.request = new MockHttpServletRequest("GET", ""); this.request.setServletPath(path); @@ -129,7 +129,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenPathInfoNotNormalizedThenThrowsRequestRejectedException() throws Exception { + public void getFirewalledRequestWhenPathInfoNotNormalizedThenThrowsRequestRejectedException() { for (String path : this.unnormalizedPaths) { this.request = new MockHttpServletRequest("GET", ""); this.request.setPathInfo(path); @@ -431,7 +431,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenAllowUrlLowerCaseEncodedDoubleSlashThenNoException() throws Exception { + public void getFirewalledRequestWhenAllowUrlLowerCaseEncodedDoubleSlashThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); this.firewall.setAllowUrlEncodedDoubleSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); @@ -443,7 +443,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenAllowUrlUpperCaseEncodedDoubleSlashThenNoException() throws Exception { + public void getFirewalledRequestWhenAllowUrlUpperCaseEncodedDoubleSlashThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); this.firewall.setAllowUrlEncodedDoubleSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); @@ -455,8 +455,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenAllowUrlLowerCaseAndUpperCaseEncodedDoubleSlashThenNoException() - throws Exception { + public void getFirewalledRequestWhenAllowUrlLowerCaseAndUpperCaseEncodedDoubleSlashThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); this.firewall.setAllowUrlEncodedDoubleSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); @@ -468,8 +467,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenAllowUrlUpperCaseAndLowerCaseEncodedDoubleSlashThenNoException() - throws Exception { + public void getFirewalledRequestWhenAllowUrlUpperCaseAndLowerCaseEncodedDoubleSlashThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); this.firewall.setAllowUrlEncodedDoubleSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); @@ -481,7 +479,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRemoveFromUpperCaseEncodedUrlBlacklistThenNoException() throws Exception { + public void getFirewalledRequestWhenRemoveFromUpperCaseEncodedUrlBlacklistThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); request.setRequestURI("/context-root/a/b%2F%2Fc"); @@ -490,7 +488,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRemoveFromLowerCaseEncodedUrlBlacklistThenNoException() throws Exception { + public void getFirewalledRequestWhenRemoveFromLowerCaseEncodedUrlBlacklistThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); request.setRequestURI("/context-root/a/b%2f%2fc"); @@ -499,8 +497,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRemoveFromLowerCaseAndUpperCaseEncodedUrlBlacklistThenNoException() - throws Exception { + public void getFirewalledRequestWhenRemoveFromLowerCaseAndUpperCaseEncodedUrlBlacklistThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); request.setRequestURI("/context-root/a/b%2f%2Fc"); @@ -509,8 +506,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRemoveFromUpperCaseAndLowerCaseEncodedUrlBlacklistThenNoException() - throws Exception { + public void getFirewalledRequestWhenRemoveFromUpperCaseAndLowerCaseEncodedUrlBlacklistThenNoException() { this.firewall.setAllowUrlEncodedSlash(true); MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); request.setRequestURI("/context-root/a/b%2F%2fc"); @@ -519,7 +515,7 @@ public class StrictHttpFirewallTests { } @Test - public void getFirewalledRequestWhenRemoveFromDecodedUrlBlacklistThenNoException() throws Exception { + public void getFirewalledRequestWhenRemoveFromDecodedUrlBlacklistThenNoException() { MockHttpServletRequest request = new MockHttpServletRequest("GET", ""); request.setPathInfo("/a/b//c"); this.firewall.getDecodedUrlBlacklist().removeAll(Arrays.asList("//")); diff --git a/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java b/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java index 77a2255a27..b7f478f518 100644 --- a/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java @@ -54,13 +54,13 @@ public class HeaderWriterFilterTests { private HeaderWriter writer2; @Test(expected = IllegalArgumentException.class) - public void noHeadersConfigured() throws Exception { + public void noHeadersConfigured() { List headerWriters = new ArrayList<>(); new HeaderWriterFilter(headerWriters); } @Test(expected = IllegalArgumentException.class) - public void constructorNullWriters() throws Exception { + public void constructorNullWriters() { new HeaderWriterFilter(null); } diff --git a/web/src/test/java/org/springframework/security/web/header/writers/HpkpHeaderWriterTests.java b/web/src/test/java/org/springframework/security/web/header/writers/HpkpHeaderWriterTests.java index 8db0fd42da..a3b55b6f32 100644 --- a/web/src/test/java/org/springframework/security/web/header/writers/HpkpHeaderWriterTests.java +++ b/web/src/test/java/org/springframework/security/web/header/writers/HpkpHeaderWriterTests.java @@ -158,7 +158,7 @@ public class HpkpHeaderWriterTests { } @Test - public void writeHeadersTerminateConnectionWithURIAsString() throws URISyntaxException { + public void writeHeadersTerminateConnectionWithURIAsString() { writer.setReportOnly(false); writer.setReportUri("https://example.com/pkp-report"); diff --git a/web/src/test/java/org/springframework/security/web/jaasapi/JaasApiIntegrationFilterTests.java b/web/src/test/java/org/springframework/security/web/jaasapi/JaasApiIntegrationFilterTests.java index d6ff8fe75c..e56a4a1fc4 100644 --- a/web/src/test/java/org/springframework/security/web/jaasapi/JaasApiIntegrationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/jaasapi/JaasApiIntegrationFilterTests.java @@ -171,7 +171,7 @@ public class JaasApiIntegrationFilterTests { } @Test - public void obtainSubject() throws Exception { + public void obtainSubject() { SecurityContextHolder.getContext().setAuthentication(token); assertThat(filter.obtainSubject(request)).isEqualTo(authenticatedSubject); } diff --git a/web/src/test/java/org/springframework/security/web/jackson2/SavedCookieMixinTests.java b/web/src/test/java/org/springframework/security/web/jackson2/SavedCookieMixinTests.java index 8fbd91d468..d9abcb6484 100644 --- a/web/src/test/java/org/springframework/security/web/jackson2/SavedCookieMixinTests.java +++ b/web/src/test/java/org/springframework/security/web/jackson2/SavedCookieMixinTests.java @@ -83,7 +83,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests { @Test @SuppressWarnings("unchecked") - public void deserializeSavedCookieWithList() throws IOException, JSONException { + public void deserializeSavedCookieWithList() throws IOException { List savedCookies = (List) mapper.readValue(COOKIES_JSON, Object.class); assertThat(savedCookies).isNotNull().hasSize(1); assertThat(savedCookies.get(0).getName()).isEqualTo("SESSION"); diff --git a/web/src/test/java/org/springframework/security/web/jackson2/WebAuthenticationDetailsMixinTests.java b/web/src/test/java/org/springframework/security/web/jackson2/WebAuthenticationDetailsMixinTests.java index c443601c50..405efd642c 100644 --- a/web/src/test/java/org/springframework/security/web/jackson2/WebAuthenticationDetailsMixinTests.java +++ b/web/src/test/java/org/springframework/security/web/jackson2/WebAuthenticationDetailsMixinTests.java @@ -71,7 +71,7 @@ public class WebAuthenticationDetailsMixinTests extends AbstractMixinTests { @Test public void webAuthenticationDetailsDeserializeTest() - throws IOException, JSONException { + throws IOException { WebAuthenticationDetails details = mapper.readValue(AUTHENTICATION_DETAILS_JSON, WebAuthenticationDetails.class); assertThat(details).isNotNull(); diff --git a/web/src/test/java/org/springframework/security/web/method/ResolvableMethod.java b/web/src/test/java/org/springframework/security/web/method/ResolvableMethod.java index 8ced92651e..f4cd55ef45 100644 --- a/web/src/test/java/org/springframework/security/web/method/ResolvableMethod.java +++ b/web/src/test/java/org/springframework/security/web/method/ResolvableMethod.java @@ -624,7 +624,7 @@ public class ResolvableMethod { } @Override - public Object invoke(org.aopalliance.intercept.MethodInvocation inv) throws Throwable { + public Object invoke(org.aopalliance.intercept.MethodInvocation inv) { return intercept(inv.getThis(), inv.getMethod(), inv.getArguments(), null); } } diff --git a/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java index 7255c83c1a..d7be109aec 100644 --- a/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java @@ -54,17 +54,17 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void supportsParameterNoAnnotation() throws Exception { + public void supportsParameterNoAnnotation() { assertThat(resolver.supportsParameter(showUserNoAnnotation())).isFalse(); } @Test - public void supportsParameterAnnotation() throws Exception { + public void supportsParameterAnnotation() { assertThat(resolver.supportsParameter(showUserAnnotationObject())).isTrue(); } @Test - public void supportsParameterCustomAnnotation() throws Exception { + public void supportsParameterCustomAnnotation() { assertThat(resolver.supportsParameter(showUserCustomAnnotation())).isTrue(); } diff --git a/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/AuthenticationPrincipalArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/AuthenticationPrincipalArgumentResolverTests.java index f12295e0b9..6a6ced10ad 100644 --- a/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/AuthenticationPrincipalArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/AuthenticationPrincipalArgumentResolverTests.java @@ -69,17 +69,17 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void supportsParameterAuthenticationPrincipal() throws Exception { + public void supportsParameterAuthenticationPrincipal() { assertThat(resolver.supportsParameter(this.authenticationPrincipal.arg(String.class))).isTrue(); } @Test - public void supportsParameterCurrentUser() throws Exception { + public void supportsParameterCurrentUser() { assertThat(resolver.supportsParameter(this.meta.arg(String.class))).isTrue(); } @Test - public void resolveArgumentWhenIsAuthenticationThenObtainsPrincipal() throws Exception { + public void resolveArgumentWhenIsAuthenticationThenObtainsPrincipal() { MethodParameter parameter = this.authenticationPrincipal.arg(String.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -90,7 +90,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenIsNotAuthenticationThenMonoEmpty() throws Exception { + public void resolveArgumentWhenIsNotAuthenticationThenMonoEmpty() { MethodParameter parameter = this.authenticationPrincipal.arg(String.class); when(exchange.getPrincipal()).thenReturn(Mono.just(() -> "")); @@ -101,7 +101,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenIsEmptyThenMonoEmpty() throws Exception { + public void resolveArgumentWhenIsEmptyThenMonoEmpty() { MethodParameter parameter = this.authenticationPrincipal.arg(String.class); when(exchange.getPrincipal()).thenReturn(Mono.empty()); @@ -112,7 +112,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenMonoIsAuthenticationThenObtainsPrincipal() throws Exception { + public void resolveArgumentWhenMonoIsAuthenticationThenObtainsPrincipal() { MethodParameter parameter = this.authenticationPrincipal.arg(Mono.class, String.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -123,7 +123,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenMonoIsAuthenticationAndNoGenericThenObtainsPrincipal() throws Exception { + public void resolveArgumentWhenMonoIsAuthenticationAndNoGenericThenObtainsPrincipal() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("authenticationPrincipalNoGeneric").build().arg(Mono.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -134,7 +134,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenSpelThenObtainsPrincipal() throws Exception { + public void resolveArgumentWhenSpelThenObtainsPrincipal() { MyUser user = new MyUser(3L); MethodParameter parameter = this.spel.arg(Long.class); when(authentication.getPrincipal()).thenReturn(user); @@ -159,7 +159,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenMetaThenObtainsPrincipal() throws Exception { + public void resolveArgumentWhenMetaThenObtainsPrincipal() { MethodParameter parameter = this.meta.arg(String.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -170,7 +170,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenErrorOnInvalidTypeImplicit() throws Exception { + public void resolveArgumentWhenErrorOnInvalidTypeImplicit() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenImplicit").build().arg(Integer.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -181,7 +181,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenErrorOnInvalidTypeExplicitFalse() throws Exception { + public void resolveArgumentWhenErrorOnInvalidTypeExplicitFalse() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenExplicitFalse").build().arg(Integer.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); @@ -192,7 +192,7 @@ public class AuthenticationPrincipalArgumentResolverTests { } @Test - public void resolveArgumentWhenErrorOnInvalidTypeExplicitTrue() throws Exception { + public void resolveArgumentWhenErrorOnInvalidTypeExplicitTrue() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenExplicitTrue").build().arg(Integer.class); when(authentication.getPrincipal()).thenReturn("user"); when(exchange.getPrincipal()).thenReturn(Mono.just(authentication)); diff --git a/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolverTests.java index 8f3e6b7fc4..d23277bb37 100644 --- a/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolverTests.java @@ -76,17 +76,17 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void supportsParameterCurrentSecurityContext() throws Exception { + public void supportsParameterCurrentSecurityContext() { assertThat(resolver.supportsParameter(this.securityContextMethod.arg(Mono.class, SecurityContext.class))).isTrue(); } @Test - public void supportsParameterWithAuthentication() throws Exception { + public void supportsParameterWithAuthentication() { assertThat(resolver.supportsParameter(this.securityContextWithAuthentication.arg(Mono.class, Authentication.class))).isTrue(); } @Test - public void resolveArgumentWithNullSecurityContext() throws Exception { + public void resolveArgumentWithNullSecurityContext() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContext").build().arg(Mono.class, SecurityContext.class); Context context = ReactiveSecurityContextHolder.withSecurityContext(Mono.empty()); Mono argument = resolver.resolveArgument(parameter, bindingContext, exchange); @@ -96,7 +96,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithSecurityContext() throws Exception { + public void resolveArgumentWithSecurityContext() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContext").build().arg(Mono.class, SecurityContext.class); Authentication auth = buildAuthenticationWithPrincipal("hello"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -107,7 +107,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithCustomSecurityContext() throws Exception { + public void resolveArgumentWithCustomSecurityContext() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("customSecurityContext").build().arg(Mono.class, SecurityContext.class); Authentication auth = buildAuthenticationWithPrincipal("hello"); Context context = ReactiveSecurityContextHolder.withSecurityContext(Mono.just(new CustomSecurityContext(auth))); @@ -118,7 +118,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithNullAuthentication1() throws Exception { + public void resolveArgumentWithNullAuthentication1() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContext").build().arg(Mono.class, SecurityContext.class); Authentication auth = null; Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -129,7 +129,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithNullAuthentication2() throws Exception { + public void resolveArgumentWithNullAuthentication2() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithAuthentication").build().arg(Mono.class, Authentication.class); Authentication auth = null; Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -140,7 +140,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithAuthentication1() throws Exception { + public void resolveArgumentWithAuthentication1() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithAuthentication").build().arg(Mono.class, Authentication.class); Authentication auth = buildAuthenticationWithPrincipal("authentication1"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -151,7 +151,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithNullAuthenticationOptional1() throws Exception { + public void resolveArgumentWithNullAuthenticationOptional1() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithDepthPropOptional").build().arg(Mono.class, Object.class); Authentication auth = null; Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -162,7 +162,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithAuthenticationOptional1() throws Exception { + public void resolveArgumentWithAuthenticationOptional1() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithDepthPropOptional").build().arg(Mono.class, Object.class); Authentication auth = buildAuthenticationWithPrincipal("auth_optional"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -173,7 +173,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithNullDepthProp1() throws Exception { + public void resolveArgumentWithNullDepthProp1() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithDepthProp").build().arg(Mono.class, Object.class); Authentication auth = null; Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -183,7 +183,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWithStringDepthProp() throws Exception { + public void resolveArgumentWithStringDepthProp() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("securityContextWithDepthStringProp").build().arg(Mono.class, String.class); Authentication auth = buildAuthenticationWithPrincipal("auth_string"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -194,7 +194,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentWhenErrorOnInvalidTypeImplicit() throws Exception { + public void resolveArgumentWhenErrorOnInvalidTypeImplicit() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenImplicit").build().arg(Mono.class, String.class); Authentication auth = buildAuthenticationWithPrincipal("invalid_type_implicit"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -205,7 +205,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentErrorOnInvalidTypeWhenExplicitFalse() throws Exception { + public void resolveArgumentErrorOnInvalidTypeWhenExplicitFalse() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenExplicitFalse").build().arg(Mono.class, String.class); Authentication auth = buildAuthenticationWithPrincipal("error_on_invalid_type_explicit_false"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -216,7 +216,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void resolveArgumentErrorOnInvalidTypeWhenExplicitTrue() throws Exception { + public void resolveArgumentErrorOnInvalidTypeWhenExplicitTrue() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("errorOnInvalidTypeWhenExplicitTrue").build().arg(Mono.class, String.class); Authentication auth = buildAuthenticationWithPrincipal("error_on_invalid_type_explicit_true"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -226,7 +226,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void metaAnnotationWhenDefaultSecurityContextThenInjectSecurityContext() throws Exception { + public void metaAnnotationWhenDefaultSecurityContextThenInjectSecurityContext() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("currentCustomSecurityContext").build().arg(Mono.class, SecurityContext.class); Authentication auth = buildAuthenticationWithPrincipal("current_custom_security_context"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -237,7 +237,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void metaAnnotationWhenCurrentAuthenticationThenInjectAuthentication() throws Exception { + public void metaAnnotationWhenCurrentAuthenticationThenInjectAuthentication() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("currentAuthentication").build().arg(Mono.class, Authentication.class); Authentication auth = buildAuthenticationWithPrincipal("current_authentication"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -248,7 +248,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenInjectSecurityContext() throws Exception { + public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenInjectSecurityContext() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("currentSecurityWithErrorOnInvalidType").build().arg(Mono.class, SecurityContext.class); Authentication auth = buildAuthenticationWithPrincipal("current_security_with_error_on_invalid_type"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); @@ -259,7 +259,7 @@ public class CurrentSecurityContextArgumentResolverTests { } @Test - public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenMisMatch() throws Exception { + public void metaAnnotationWhenCurrentSecurityWithErrorOnInvalidTypeThenMisMatch() { MethodParameter parameter = ResolvableMethod.on(getClass()).named("currentSecurityWithErrorOnInvalidTypeMisMatch").build().arg(Mono.class, String.class); Authentication auth = buildAuthenticationWithPrincipal("current_security_with_error_on_invalid_type_mismatch"); Context context = ReactiveSecurityContextHolder.withAuthentication(auth); diff --git a/web/src/test/java/org/springframework/security/web/savedrequest/DefaultSavedRequestTests.java b/web/src/test/java/org/springframework/security/web/savedrequest/DefaultSavedRequestTests.java index 7abc1fcd4d..dd381f196a 100644 --- a/web/src/test/java/org/springframework/security/web/savedrequest/DefaultSavedRequestTests.java +++ b/web/src/test/java/org/springframework/security/web/savedrequest/DefaultSavedRequestTests.java @@ -29,7 +29,7 @@ public class DefaultSavedRequestTests { // SEC-308, SEC-315 @Test - public void headersAreCaseInsensitive() throws Exception { + public void headersAreCaseInsensitive() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("USER-aGenT", "Mozilla"); DefaultSavedRequest saved = new DefaultSavedRequest(request, @@ -39,7 +39,7 @@ public class DefaultSavedRequestTests { // SEC-1412 @Test - public void discardsIfNoneMatchHeader() throws Exception { + public void discardsIfNoneMatchHeader() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("If-None-Match", "somehashvalue"); DefaultSavedRequest saved = new DefaultSavedRequest(request, @@ -49,7 +49,7 @@ public class DefaultSavedRequestTests { // SEC-3082 @Test - public void parametersAreCaseSensitive() throws Exception { + public void parametersAreCaseSensitive() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("AnotHerTest", "Hi dad"); request.addParameter("thisisatest", "Hi mom"); diff --git a/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java b/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java index e967dc02be..048b3d8adb 100644 --- a/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java +++ b/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java @@ -59,7 +59,7 @@ public class HttpSessionRequestCacheTests { } @Test - public void requestMatcherDefinesCorrectSubsetOfCachedRequests() throws Exception { + public void requestMatcherDefinesCorrectSubsetOfCachedRequests() { HttpSessionRequestCache cache = new HttpSessionRequestCache(); cache.setRequestMatcher(request -> request.getMethod().equals("GET")); @@ -75,7 +75,7 @@ public class HttpSessionRequestCacheTests { // SEC-2246 @Test - public void getRequestCustomNoClassCastException() throws Exception { + public void getRequestCustomNoClassCastException() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/destination"); MockHttpServletResponse response = new MockHttpServletResponse(); diff --git a/web/src/test/java/org/springframework/security/web/savedrequest/SavedCookieTests.java b/web/src/test/java/org/springframework/security/web/savedrequest/SavedCookieTests.java index be75fa9f27..88d3f7a702 100644 --- a/web/src/test/java/org/springframework/security/web/savedrequest/SavedCookieTests.java +++ b/web/src/test/java/org/springframework/security/web/savedrequest/SavedCookieTests.java @@ -31,7 +31,7 @@ public class SavedCookieTests { SavedCookie savedCookie; @Before - public void setUp() throws Exception { + public void setUp() { cookie = new Cookie("name", "value"); cookie.setComment("comment"); cookie.setDomain("domain"); @@ -43,42 +43,42 @@ public class SavedCookieTests { } @Test - public void testGetName() throws Exception { + public void testGetName() { assertThat(savedCookie.getName()).isEqualTo(cookie.getName()); } @Test - public void testGetValue() throws Exception { + public void testGetValue() { assertThat(savedCookie.getValue()).isEqualTo(cookie.getValue()); } @Test - public void testGetComment() throws Exception { + public void testGetComment() { assertThat(savedCookie.getComment()).isEqualTo(cookie.getComment()); } @Test - public void testGetDomain() throws Exception { + public void testGetDomain() { assertThat(savedCookie.getDomain()).isEqualTo(cookie.getDomain()); } @Test - public void testGetMaxAge() throws Exception { + public void testGetMaxAge() { assertThat(savedCookie.getMaxAge()).isEqualTo(cookie.getMaxAge()); } @Test - public void testGetPath() throws Exception { + public void testGetPath() { assertThat(savedCookie.getPath()).isEqualTo(cookie.getPath()); } @Test - public void testGetVersion() throws Exception { + public void testGetVersion() { assertThat(savedCookie.getVersion()).isEqualTo(cookie.getVersion()); } @Test - public void testGetCookie() throws Exception { + public void testGetCookie() { Cookie other = savedCookie.getCookie(); assertThat(other.getComment()).isEqualTo(cookie.getComment()); assertThat(other.getDomain()).isEqualTo(cookie.getDomain()); @@ -91,7 +91,7 @@ public class SavedCookieTests { } @Test - public void testSerializable() throws Exception { + public void testSerializable() { assertThat(savedCookie instanceof Serializable).isTrue(); } } diff --git a/web/src/test/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapperTests.java b/web/src/test/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapperTests.java index 0ad0211042..81c45f1dd8 100644 --- a/web/src/test/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapperTests.java +++ b/web/src/test/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapperTests.java @@ -42,7 +42,7 @@ public class SavedRequestAwareWrapperTests { // SEC-2569 @Test - public void savedRequestCookiesAreIgnored() throws Exception { + public void savedRequestCookiesAreIgnored() { MockHttpServletRequest newRequest = new MockHttpServletRequest(); newRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromnew") }); MockHttpServletRequest savedRequest = new MockHttpServletRequest(); @@ -54,7 +54,7 @@ public class SavedRequestAwareWrapperTests { @Test @SuppressWarnings("unchecked") - public void savedRequesthHeaderIsReturnedIfSavedRequestIsSet() throws Exception { + public void savedRequesthHeaderIsReturnedIfSavedRequestIsSet() { MockHttpServletRequest savedRequest = new MockHttpServletRequest(); savedRequest.addHeader("header", "savedheader"); SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, @@ -155,7 +155,7 @@ public class SavedRequestAwareWrapperTests { } @Test(expected = IllegalArgumentException.class) - public void invalidDateHeaderIsRejected() throws Exception { + public void invalidDateHeaderIsRejected() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("header", "notadate"); SavedRequestAwareWrapper wrapper = createWrapper(request, @@ -164,7 +164,7 @@ public class SavedRequestAwareWrapperTests { } @Test - public void correctHttpMethodIsReturned() throws Exception { + public void correctHttpMethodIsReturned() { MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/notused"); SavedRequestAwareWrapper wrapper = createWrapper(request, new MockHttpServletRequest("GET", "/notused")); @@ -172,7 +172,7 @@ public class SavedRequestAwareWrapperTests { } @Test - public void correctIntHeaderIsReturned() throws Exception { + public void correctIntHeaderIsReturned() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("header", "999"); request.addHeader("header", "1000"); diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/AndServerWebExchangeMatcherTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/AndServerWebExchangeMatcherTests.java index 985f184b8f..b289fc49b8 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/AndServerWebExchangeMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/AndServerWebExchangeMatcherTests.java @@ -47,12 +47,12 @@ public class AndServerWebExchangeMatcherTests { AndServerWebExchangeMatcher matcher; @Before - public void setUp() throws Exception { + public void setUp() { matcher = new AndServerWebExchangeMatcher(matcher1, matcher2); } @Test - public void matchesWhenTrueTrueThenTrue() throws Exception { + public void matchesWhenTrueTrueThenTrue() { Map params1 = Collections.singletonMap("foo", "bar"); Map params2 = Collections.singletonMap("x", "y"); when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.match(params1)); @@ -70,7 +70,7 @@ public class AndServerWebExchangeMatcherTests { } @Test - public void matchesWhenFalseFalseThenFalseAndMatcher2NotInvoked() throws Exception { + public void matchesWhenFalseFalseThenFalseAndMatcher2NotInvoked() { when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); ServerWebExchangeMatcher.MatchResult matches = matcher.matches(exchange).block(); @@ -83,7 +83,7 @@ public class AndServerWebExchangeMatcherTests { } @Test - public void matchesWhenTrueFalseThenFalse() throws Exception { + public void matchesWhenTrueFalseThenFalse() { Map params = Collections.singletonMap("foo", "bar"); when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.match(params)); when(matcher2.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); @@ -98,7 +98,7 @@ public class AndServerWebExchangeMatcherTests { } @Test - public void matchesWhenFalseTrueThenFalse() throws Exception { + public void matchesWhenFalseTrueThenFalse() { when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); ServerWebExchangeMatcher.MatchResult matches = matcher.matches(exchange).block(); diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/NegatedServerWebExchangeMatcherTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/NegatedServerWebExchangeMatcherTests.java index 0b55b2f13f..83d1fae0c2 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/NegatedServerWebExchangeMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/NegatedServerWebExchangeMatcherTests.java @@ -41,12 +41,12 @@ public class NegatedServerWebExchangeMatcherTests { NegatedServerWebExchangeMatcher matcher; @Before - public void setUp() throws Exception { + public void setUp() { matcher = new NegatedServerWebExchangeMatcher(matcher1); } @Test - public void matchesWhenFalseThenTrue() throws Exception { + public void matchesWhenFalseThenTrue() { when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); ServerWebExchangeMatcher.MatchResult matches = matcher.matches(exchange).block(); @@ -58,7 +58,7 @@ public class NegatedServerWebExchangeMatcherTests { } @Test - public void matchesWhenTrueThenFalse() throws Exception { + public void matchesWhenTrueThenFalse() { when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.match()); ServerWebExchangeMatcher.MatchResult matches = matcher.matches(exchange).block(); diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/OrServerWebExchangeMatcherTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/OrServerWebExchangeMatcherTests.java index 46527de344..8de5898c1e 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/OrServerWebExchangeMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/OrServerWebExchangeMatcherTests.java @@ -48,12 +48,12 @@ public class OrServerWebExchangeMatcherTests { OrServerWebExchangeMatcher matcher; @Before - public void setUp() throws Exception { + public void setUp() { matcher = new OrServerWebExchangeMatcher(matcher1, matcher2); } @Test - public void matchesWhenFalseFalseThenFalse() throws Exception { + public void matchesWhenFalseFalseThenFalse() { when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); when(matcher2.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); @@ -67,7 +67,7 @@ public class OrServerWebExchangeMatcherTests { } @Test - public void matchesWhenTrueFalseThenTrueAndMatcher2NotInvoked() throws Exception { + public void matchesWhenTrueFalseThenTrueAndMatcher2NotInvoked() { Map params = Collections.singletonMap("foo", "bar"); when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.match(params)); @@ -81,7 +81,7 @@ public class OrServerWebExchangeMatcherTests { } @Test - public void matchesWhenFalseTrueThenTrue() throws Exception { + public void matchesWhenFalseTrueThenTrue() { Map params = Collections.singletonMap("foo", "bar"); when(matcher1.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.notMatch()); when(matcher2.matches(exchange)).thenReturn(ServerWebExchangeMatcher.MatchResult.match(params)); diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java index e32299218f..a216521ac6 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java @@ -37,27 +37,27 @@ public class ServerWebExchangeMatchersTests { .from(MockServerHttpRequest.get("/").build()); @Test - public void pathMatchersWhenSingleAndSamePatternThenMatches() throws Exception { + public void pathMatchersWhenSingleAndSamePatternThenMatches() { assertThat(pathMatchers("/").matches(exchange).block().isMatch()).isTrue(); } @Test - public void pathMatchersWhenSingleAndSamePatternAndMethodThenMatches() throws Exception { + public void pathMatchersWhenSingleAndSamePatternAndMethodThenMatches() { assertThat(ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/").matches(exchange).block().isMatch()).isTrue(); } @Test - public void pathMatchersWhenSingleAndSamePatternAndDiffMethodThenDoesNotMatch() throws Exception { + public void pathMatchersWhenSingleAndSamePatternAndDiffMethodThenDoesNotMatch() { assertThat(ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, "/").matches(exchange).block().isMatch()).isFalse(); } @Test - public void pathMatchersWhenSingleAndDifferentPatternThenDoesNotMatch() throws Exception { + public void pathMatchersWhenSingleAndDifferentPatternThenDoesNotMatch() { assertThat(pathMatchers("/foobar").matches(exchange).block().isMatch()).isFalse(); } @Test - public void pathMatchersWhenMultiThenMatches() throws Exception { + public void pathMatchersWhenMultiThenMatches() { assertThat(pathMatchers("/foobar", "/").matches(exchange).block().isMatch()).isTrue(); } diff --git a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java index 68a380128e..928bebc339 100644 --- a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java @@ -57,7 +57,7 @@ public class MvcRequestMatcherTests { MvcRequestMatcher matcher; @Before - public void setup() throws Exception { + public void setup() { this.request = new MockHttpServletRequest(); this.request.setMethod("GET"); this.request.setServletPath("/path"); @@ -125,7 +125,7 @@ public class MvcRequestMatcherTests { } @Test - public void matchesServletPathFalse() throws Exception { + public void matchesServletPathFalse() { this.matcher.setServletPath("/spring"); this.request.setServletPath("/"); @@ -179,7 +179,7 @@ public class MvcRequestMatcherTests { } @Test - public void matchesMethodAndPathFalseMethod() throws Exception { + public void matchesMethodAndPathFalseMethod() { this.matcher.setMethod(HttpMethod.POST); assertThat(this.matcher.matches(this.request)).isFalse(); @@ -191,10 +191,9 @@ public class MvcRequestMatcherTests { * Malicious users can specify any HTTP Method to create a stacktrace and try to * expose useful information about the system. We should ensure we ignore invalid HTTP * methods. - * @throws Exception if an error occurs */ @Test - public void matchesInvalidMethodOnRequest() throws Exception { + public void matchesInvalidMethodOnRequest() { this.matcher.setMethod(HttpMethod.GET); this.request.setMethod("invalid"); @@ -213,7 +212,7 @@ public class MvcRequestMatcherTests { } @Test - public void matchesGetMatchableHandlerMappingNull() throws Exception { + public void matchesGetMatchableHandlerMappingNull() { assertThat(this.matcher.matches(this.request)).isTrue(); } diff --git a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java index c73f0b2fb5..58a1c656ff 100644 --- a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java +++ b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java @@ -36,12 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat; public class SecurityContextHolderAwareRequestWrapperTests { @Before - public void tearDown() throws Exception { + public void tearDown() { SecurityContextHolder.clearContext(); } @Test - public void testCorrectOperationWithStringBasedPrincipal() throws Exception { + public void testCorrectOperationWithStringBasedPrincipal() { Authentication auth = new TestingAuthenticationToken("rod", "koala", "ROLE_FOO"); SecurityContextHolder.getContext().setAuthentication(auth); @@ -72,7 +72,7 @@ public class SecurityContextHolderAwareRequestWrapperTests { } @Test - public void testCorrectOperationWithUserDetailsBasedPrincipal() throws Exception { + public void testCorrectOperationWithUserDetailsBasedPrincipal() { Authentication auth = new TestingAuthenticationToken( new User("rodAsUserDetails", "koala", true, true, true, true, AuthorityUtils.NO_AUTHORITIES), @@ -94,7 +94,7 @@ public class SecurityContextHolderAwareRequestWrapperTests { } @Test - public void testRoleIsntHeldIfAuthenticationIsNull() throws Exception { + public void testRoleIsntHeldIfAuthenticationIsNull() { SecurityContextHolder.getContext().setAuthentication(null); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -108,7 +108,7 @@ public class SecurityContextHolderAwareRequestWrapperTests { } @Test - public void testRolesArentHeldIfAuthenticationPrincipalIsNull() throws Exception { + public void testRolesArentHeldIfAuthenticationPrincipalIsNull() { Authentication auth = new TestingAuthenticationToken(null, "koala", "ROLE_HELLO", "ROLE_FOOBAR"); SecurityContextHolder.getContext().setAuthentication(auth); diff --git a/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java b/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java index ed05ab4287..c462675749 100644 --- a/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java +++ b/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java @@ -39,8 +39,7 @@ import org.springframework.security.web.authentication.session.SessionFixationPr public class DefaultSessionAuthenticationStrategyTests { @Test - public void newSessionShouldNotBeCreatedIfNoSessionExistsAndAlwaysCreateIsFalse() - throws Exception { + public void newSessionShouldNotBeCreatedIfNoSessionExistsAndAlwaysCreateIsFalse() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); HttpServletRequest request = new MockHttpServletRequest(); @@ -51,7 +50,7 @@ public class DefaultSessionAuthenticationStrategyTests { } @Test - public void newSessionIsCreatedIfSessionAlreadyExists() throws Exception { + public void newSessionIsCreatedIfSessionAlreadyExists() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); HttpServletRequest request = new MockHttpServletRequest(); String sessionId = request.getSession().getId(); @@ -64,8 +63,7 @@ public class DefaultSessionAuthenticationStrategyTests { // SEC-2002 @Test - public void newSessionIsCreatedIfSessionAlreadyExistsWithEventPublisher() - throws Exception { + public void newSessionIsCreatedIfSessionAlreadyExistsWithEventPublisher() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); HttpServletRequest request = new MockHttpServletRequest(); HttpSession session = request.getSession(); @@ -101,8 +99,7 @@ public class DefaultSessionAuthenticationStrategyTests { // See SEC-1077 @Test - public void onlySavedRequestAttributeIsMigratedIfMigrateAttributesIsFalse() - throws Exception { + public void onlySavedRequestAttributeIsMigratedIfMigrateAttributesIsFalse() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); strategy.setMigrateSessionAttributes(false); HttpServletRequest request = new MockHttpServletRequest(); @@ -120,8 +117,7 @@ public class DefaultSessionAuthenticationStrategyTests { // SEC-2002 @Test - public void onlySavedRequestAttributeIsMigratedIfMigrateAttributesIsFalseWithEventPublisher() - throws Exception { + public void onlySavedRequestAttributeIsMigratedIfMigrateAttributesIsFalseWithEventPublisher() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); strategy.setMigrateSessionAttributes(false); HttpServletRequest request = new MockHttpServletRequest(); @@ -156,7 +152,7 @@ public class DefaultSessionAuthenticationStrategyTests { } @Test - public void sessionIsCreatedIfAlwaysCreateTrue() throws Exception { + public void sessionIsCreatedIfAlwaysCreateTrue() { SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); strategy.setAlwaysCreateSession(true); HttpServletRequest request = new MockHttpServletRequest(); diff --git a/web/src/test/java/org/springframework/security/web/util/OnCommittedResponseWrapperTests.java b/web/src/test/java/org/springframework/security/web/util/OnCommittedResponseWrapperTests.java index 3f4f94d149..b9b55af3b5 100644 --- a/web/src/test/java/org/springframework/security/web/util/OnCommittedResponseWrapperTests.java +++ b/web/src/test/java/org/springframework/security/web/util/OnCommittedResponseWrapperTests.java @@ -1083,7 +1083,7 @@ public class OnCommittedResponseWrapperTests { } @Test - public void contentLengthDoesNotCommit() throws IOException { + public void contentLengthDoesNotCommit() { String body = "something"; response.setContentLength(body.length()); diff --git a/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java b/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java index 7bbb568bc8..337780567c 100644 --- a/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java +++ b/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java @@ -32,23 +32,23 @@ public class TextEscapeUtilsTests { } @Test - public void nullOrEmptyStringIsHandled() throws Exception { + public void nullOrEmptyStringIsHandled() { assertThat(TextEscapeUtils.escapeEntities("")).isEqualTo(""); assertThat(TextEscapeUtils.escapeEntities(null)).isNull(); } @Test(expected = IllegalArgumentException.class) - public void invalidLowSurrogateIsDetected() throws Exception { + public void invalidLowSurrogateIsDetected() { TextEscapeUtils.escapeEntities("abc\uDCCCdef"); } @Test(expected = IllegalArgumentException.class) - public void missingLowSurrogateIsDetected() throws Exception { + public void missingLowSurrogateIsDetected() { TextEscapeUtils.escapeEntities("abc\uD888a"); } @Test(expected = IllegalArgumentException.class) - public void highSurrogateAtEndOfStringIsRejected() throws Exception { + public void highSurrogateAtEndOfStringIsRejected() { TextEscapeUtils.escapeEntities("abc\uD888"); } @@ -56,12 +56,12 @@ public class TextEscapeUtilsTests { * Delta char: 𐐀 */ @Test - public void validSurrogatePairIsAccepted() throws Exception { + public void validSurrogatePairIsAccepted() { assertThat(TextEscapeUtils.escapeEntities("abc\uD801\uDC00a")).isEqualTo("abc𐐀a"); } @Test - public void undefinedSurrogatePairIsIgnored() throws Exception { + public void undefinedSurrogatePairIsIgnored() { assertThat(TextEscapeUtils.escapeEntities("abc\uD888\uDC00a")).isEqualTo("abca"); } } diff --git a/web/src/test/java/org/springframework/security/web/util/ThrowableAnalyzerTests.java b/web/src/test/java/org/springframework/security/web/util/ThrowableAnalyzerTests.java index 41c98f5cce..672a511548 100644 --- a/web/src/test/java/org/springframework/security/web/util/ThrowableAnalyzerTests.java +++ b/web/src/test/java/org/springframework/security/web/util/ThrowableAnalyzerTests.java @@ -82,7 +82,7 @@ public class ThrowableAnalyzerTests { private ThrowableAnalyzer nonstandardAnalyzer; @Before - public void setUp() throws Exception { + public void setUp() { // Set up test trace this.testTrace = new Throwable[7]; diff --git a/web/src/test/java/org/springframework/security/web/util/UrlUtilsTests.java b/web/src/test/java/org/springframework/security/web/util/UrlUtilsTests.java index 856b27f111..0c70ab811b 100644 --- a/web/src/test/java/org/springframework/security/web/util/UrlUtilsTests.java +++ b/web/src/test/java/org/springframework/security/web/util/UrlUtilsTests.java @@ -26,7 +26,7 @@ import org.junit.Test; public class UrlUtilsTests { @Test - public void absoluteUrlsAreMatchedAsAbsolute() throws Exception { + public void absoluteUrlsAreMatchedAsAbsolute() { assertThat(UrlUtils.isAbsoluteUrl("https://something/")).isTrue(); assertThat(UrlUtils.isAbsoluteUrl("http1://something/")).isTrue(); assertThat(UrlUtils.isAbsoluteUrl("HTTP://something/")).isTrue(); diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java index 29ed393366..a07a31cbe3 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java @@ -139,7 +139,7 @@ public class AntPathRequestMatcherTests { } @Test - public void exactMatchOnlyMatchesIdenticalPath() throws Exception { + public void exactMatchOnlyMatchesIdenticalPath() { AntPathRequestMatcher matcher = new AntPathRequestMatcher("/login.html"); assertThat(matcher.matches(createRequest("/login.html"))).isTrue(); assertThat(matcher.matches(createRequest("/login.html/"))).isFalse(); @@ -147,8 +147,7 @@ public class AntPathRequestMatcherTests { } @Test - public void httpMethodSpecificMatchOnlyMatchesRequestsWithCorrectMethod() - throws Exception { + public void httpMethodSpecificMatchOnlyMatchesRequestsWithCorrectMethod() { AntPathRequestMatcher matcher = new AntPathRequestMatcher("/blah", "GET"); MockHttpServletRequest request = createRequest("/blah"); request.setMethod("GET"); @@ -158,7 +157,7 @@ public class AntPathRequestMatcherTests { } @Test - public void caseSensitive() throws Exception { + public void caseSensitive() { MockHttpServletRequest request = createRequest("/UPPER"); assertThat(new AntPathRequestMatcher("/upper", null, true).matches(request)) .isFalse(); @@ -185,7 +184,7 @@ public class AntPathRequestMatcherTests { } @Test - public void equalsBehavesCorrectly() throws Exception { + public void equalsBehavesCorrectly() { // Both universal wildcard options should be equal assertThat(new AntPathRequestMatcher("**")) .isEqualTo(new AntPathRequestMatcher("/**")); @@ -204,7 +203,7 @@ public class AntPathRequestMatcherTests { } @Test - public void toStringIsOk() throws Exception { + public void toStringIsOk() { new AntPathRequestMatcher("/blah").toString(); new AntPathRequestMatcher("/blah", "GET").toString(); } diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/ELRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/ELRequestMatcherTests.java index 72be4d54d8..d483ae9cd7 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/ELRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/ELRequestMatcherTests.java @@ -28,7 +28,7 @@ import org.springframework.security.web.util.matcher.ELRequestMatcher; public class ELRequestMatcherTests { @Test - public void testHasIpAddressTrue() throws Exception { + public void testHasIpAddressTrue() { ELRequestMatcher requestMatcher = new ELRequestMatcher("hasIpAddress('1.1.1.1')"); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("1.1.1.1"); @@ -37,7 +37,7 @@ public class ELRequestMatcherTests { } @Test - public void testHasIpAddressFalse() throws Exception { + public void testHasIpAddressFalse() { ELRequestMatcher requestMatcher = new ELRequestMatcher("hasIpAddress('1.1.1.1')"); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("1.1.1.2"); @@ -46,7 +46,7 @@ public class ELRequestMatcherTests { } @Test - public void testHasHeaderTrue() throws Exception { + public void testHasHeaderTrue() { ELRequestMatcher requestMatcher = new ELRequestMatcher( "hasHeader('User-Agent','MSIE')"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -56,7 +56,7 @@ public class ELRequestMatcherTests { } @Test - public void testHasHeaderTwoEntries() throws Exception { + public void testHasHeaderTwoEntries() { ELRequestMatcher requestMatcher = new ELRequestMatcher( "hasHeader('User-Agent','MSIE') or hasHeader('User-Agent','Mozilla')"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -72,7 +72,7 @@ public class ELRequestMatcherTests { } @Test - public void testHasHeaderFalse() throws Exception { + public void testHasHeaderFalse() { ELRequestMatcher requestMatcher = new ELRequestMatcher( "hasHeader('User-Agent','MSIE')"); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -82,7 +82,7 @@ public class ELRequestMatcherTests { } @Test - public void testHasHeaderNull() throws Exception { + public void testHasHeaderNull() { ELRequestMatcher requestMatcher = new ELRequestMatcher( "hasHeader('User-Agent','MSIE')"); MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/IpAddressMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/IpAddressMatcherTests.java index 204e1e0d3a..5216c7b5b7 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/IpAddressMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/IpAddressMatcherTests.java @@ -53,7 +53,7 @@ public class IpAddressMatcherTests { } @Test - public void ipv4SubnetMatchesCorrectly() throws Exception { + public void ipv4SubnetMatchesCorrectly() { IpAddressMatcher matcher = new IpAddressMatcher("192.168.1.0/24"); assertThat(matcher.matches(ipv4Request)).isTrue(); matcher = new IpAddressMatcher("192.168.1.128/25"); @@ -63,7 +63,7 @@ public class IpAddressMatcherTests { } @Test - public void ipv6RangeMatches() throws Exception { + public void ipv6RangeMatches() { IpAddressMatcher matcher = new IpAddressMatcher("2001:DB8::/48"); assertThat(matcher.matches("2001:DB8:0:0:0:0:0:0")).isTrue(); @@ -74,7 +74,7 @@ public class IpAddressMatcherTests { // SEC-1733 @Test - public void zeroMaskMatchesAnything() throws Exception { + public void zeroMaskMatchesAnything() { IpAddressMatcher matcher = new IpAddressMatcher("0.0.0.0/0"); assertThat(matcher.matches("123.4.5.6")).isTrue(); diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/MediaTypeRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/MediaTypeRequestMatcherTests.java index eecac8e7d7..099159f966 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/MediaTypeRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/MediaTypeRequestMatcherTests.java @@ -115,35 +115,35 @@ public class MediaTypeRequestMatcherTests { } @Test - public void matchWhenAcceptHeaderAsteriskThenAll() throws Exception { + public void matchWhenAcceptHeaderAsteriskThenAll() { request.addHeader("Accept", "*/*"); matcher = new MediaTypeRequestMatcher(MediaType.ALL); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenAcceptHeaderAsteriskThenAnyone() throws Exception { + public void matchWhenAcceptHeaderAsteriskThenAnyone() { request.addHeader("Accept", "*/*"); matcher = new MediaTypeRequestMatcher(MediaType.TEXT_HTML); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenAcceptHeaderAsteriskThenAllInCollection() throws Exception { + public void matchWhenAcceptHeaderAsteriskThenAllInCollection() { request.addHeader("Accept", "*/*"); matcher = new MediaTypeRequestMatcher(Collections.singleton(MediaType.ALL)); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenAcceptHeaderAsteriskThenAnyoneInCollection() throws Exception { + public void matchWhenAcceptHeaderAsteriskThenAnyoneInCollection() { request.addHeader("Accept", "*/*"); matcher = new MediaTypeRequestMatcher(Collections.singleton(MediaType.TEXT_HTML)); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenNoAcceptHeaderThenAll() throws Exception { + public void matchWhenNoAcceptHeaderThenAll() { request.removeHeader("Accept"); // if not set Accept, it is match all matcher = new MediaTypeRequestMatcher(MediaType.ALL); @@ -151,35 +151,35 @@ public class MediaTypeRequestMatcherTests { } @Test - public void matchWhenNoAcceptHeaderThenAnyone() throws Exception { + public void matchWhenNoAcceptHeaderThenAnyone() { request.removeHeader("Accept"); matcher = new MediaTypeRequestMatcher(MediaType.TEXT_HTML); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenSingleAcceptHeaderThenOne() throws Exception { + public void matchWhenSingleAcceptHeaderThenOne() { request.addHeader("Accept", "text/html"); matcher = new MediaTypeRequestMatcher(MediaType.TEXT_HTML); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenSingleAcceptHeaderThenOneWithCollection() throws Exception { + public void matchWhenSingleAcceptHeaderThenOneWithCollection() { request.addHeader("Accept", "text/html"); matcher = new MediaTypeRequestMatcher(Collections.singleton(MediaType.TEXT_HTML)); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenMultipleAcceptHeaderThenMatchMultiple() throws Exception { + public void matchWhenMultipleAcceptHeaderThenMatchMultiple() { request.addHeader("Accept", "text/html, application/xhtml+xml, application/xml;q=0.9"); matcher = new MediaTypeRequestMatcher(MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML, MediaType.APPLICATION_XML); assertThat(matcher.matches(request)).isTrue(); } @Test - public void matchWhenMultipleAcceptHeaderThenAnyoneInCollection() throws Exception { + public void matchWhenMultipleAcceptHeaderThenAnyoneInCollection() { request.addHeader("Accept", "text/html, application/xhtml+xml, application/xml;q=0.9"); matcher = new MediaTypeRequestMatcher(Arrays.asList(MediaType.APPLICATION_XHTML_XML)); assertThat(matcher.matches(request)).isTrue(); diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/RegexRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/RegexRequestMatcherTests.java index 04d93b4ff6..b6c457d63c 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/RegexRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/RegexRequestMatcherTests.java @@ -38,7 +38,7 @@ public class RegexRequestMatcherTests { private HttpServletRequest request; @Test - public void doesntMatchIfHttpMethodIsDifferent() throws Exception { + public void doesntMatchIfHttpMethodIsDifferent() { RegexRequestMatcher matcher = new RegexRequestMatcher(".*", "GET"); MockHttpServletRequest request = new MockHttpServletRequest("POST", "/anything"); @@ -47,7 +47,7 @@ public class RegexRequestMatcherTests { } @Test - public void matchesIfHttpMethodAndPathMatch() throws Exception { + public void matchesIfHttpMethodAndPathMatch() { RegexRequestMatcher matcher = new RegexRequestMatcher(".*", "GET"); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/anything"); @@ -57,7 +57,7 @@ public class RegexRequestMatcherTests { } @Test - public void queryStringIsMatcherCorrectly() throws Exception { + public void queryStringIsMatcherCorrectly() { RegexRequestMatcher matcher = new RegexRequestMatcher(".*\\?x=y", "GET"); MockHttpServletRequest request = new MockHttpServletRequest("GET",