Remove unnecessary throws Exception from spring-security-config

Closes gh-17957
This commit is contained in:
Rob Winch 2025-09-25 11:48:10 -05:00
parent be20201bf7
commit 667cd4aa7c
No known key found for this signature in database
56 changed files with 204 additions and 307 deletions

View File

@ -96,10 +96,10 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
}
/**
* Similar to {@link #build()} and {@link #getObject()} but checks the state to
* determine if {@link #build()} needs to be called first.
* @return the result of {@link #build()} or {@link #getObject()}. If an error occurs
* while building, returns null.
* Similar to {@link SecurityBuilder#build()} and {@link #getObject()} but checks the
* state to determine if {@link SecurityBuilder#build()} needs to be called first.
* @return the result of {@link SecurityBuilder#build()} or {@link #getObject()}. If
* an error occurs while building, returns null.
*/
public O getOrBuild() {
if (!isUnbuilt()) {
@ -122,7 +122,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* @return the {@link SecurityConfigurerAdapter} for further customizations
* @throws Exception
*/
public <C extends SecurityConfigurer<O, B>> C apply(C configurer) throws Exception {
public <C extends SecurityConfigurer<O, B>> C apply(C configurer) {
add(configurer);
return configurer;
}
@ -145,7 +145,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* @throws Exception
* @since 7.0
*/
public <C extends SecurityConfigurerAdapter<O, B>> B with(C configurer) throws Exception {
public <C extends SecurityConfigurerAdapter<O, B>> B with(C configurer) {
return with(configurer, Customizer.withDefaults());
}
@ -158,7 +158,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* @since 6.2
*/
@SuppressWarnings("unchecked")
public <C extends SecurityConfigurerAdapter<O, B>> B with(C configurer, Customizer<C> customizer) throws Exception {
public <C extends SecurityConfigurerAdapter<O, B>> B with(C configurer, Customizer<C> customizer) {
configurer.addObjectPostProcessor(this.objectPostProcessor);
configurer.setBuilder((B) this);
add(configurer);
@ -326,7 +326,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* </ul>
*/
@Override
protected final O doBuild() throws Exception {
protected final O doBuild() {
synchronized (this.configurers) {
this.buildState = BuildState.INITIALIZING;
beforeInit();
@ -346,7 +346,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* method. Subclasses may override this method to hook into the lifecycle without
* using a {@link SecurityConfigurer}.
*/
protected void beforeInit() throws Exception {
protected void beforeInit() {
}
/**
@ -355,17 +355,17 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* override this method to hook into the lifecycle without using a
* {@link SecurityConfigurer}.
*/
protected void beforeConfigure() throws Exception {
protected void beforeConfigure() {
}
/**
* Subclasses must implement this method to build the object that is being returned.
* @return the Object to be buit or null if the implementation allows it
*/
protected abstract O performBuild() throws Exception;
protected abstract O performBuild();
@SuppressWarnings("unchecked")
private void init() throws Exception {
private void init() {
Collection<SecurityConfigurer<O, B>> configurers = getConfigurers();
for (SecurityConfigurer<O, B> configurer : configurers) {
configurer.init((B) this);
@ -380,7 +380,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
}
@SuppressWarnings("unchecked")
private void configure() throws Exception {
private void configure() {
Collection<SecurityConfigurer<O, B>> configurers = getConfigurers();
for (SecurityConfigurer<O, B> configurer : configurers) {
configurer.configure((B) this);

View File

@ -33,7 +33,7 @@ public abstract class AbstractSecurityBuilder<O> implements SecurityBuilder<O> {
private O object;
@Override
public final O build() throws Exception {
public final O build() {
if (this.building.compareAndSet(false, true)) {
this.object = doBuild();
return this.object;
@ -55,9 +55,9 @@ public abstract class AbstractSecurityBuilder<O> implements SecurityBuilder<O> {
/**
* Subclasses should implement this to perform the build.
* @return the object that should be returned by {@link #build()}.
* @return the object that should be returned by {@link SecurityBuilder#build()}.
* @throws Exception if an error occurs
*/
protected abstract O doBuild() throws Exception;
protected abstract O doBuild();
}

View File

@ -17,7 +17,7 @@
package org.springframework.security.config.annotation;
/**
* Thrown when {@link AbstractSecurityBuilder#build()} is two or more times.
* Thrown when {@link SecurityBuilder#build()} is two or more times.
*
* @author Rob Winch
* @since 3.2

View File

@ -30,6 +30,6 @@ public interface SecurityBuilder<O> {
* @return the Object to be built or null if the implementation allows it.
* @throws Exception if an error occurred when building the Object
*/
O build() throws Exception;
O build();
}

View File

@ -38,7 +38,7 @@ public interface SecurityConfigurer<O, B extends SecurityBuilder<O>> {
* @param builder
* @throws Exception
*/
void init(B builder) throws Exception;
void init(B builder);
/**
* Configure the {@link SecurityBuilder} by setting the necessary properties on the
@ -46,6 +46,6 @@ public interface SecurityConfigurer<O, B extends SecurityBuilder<O>> {
* @param builder
* @throws Exception
*/
void configure(B builder) throws Exception;
void configure(B builder);
}

View File

@ -44,11 +44,11 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
private CompositeObjectPostProcessor objectPostProcessor = new CompositeObjectPostProcessor();
@Override
public void init(B builder) throws Exception {
public void init(B builder) {
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
}
/**

View File

@ -127,8 +127,7 @@ public class AuthenticationManagerBuilder
* the in memory authentication
* @throws Exception if an error occurs when adding the in memory authentication
*/
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication()
throws Exception {
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() {
return apply(new InMemoryUserDetailsManagerConfigurer<>());
}
@ -156,7 +155,7 @@ public class AuthenticationManagerBuilder
* JDBC authentication
* @throws Exception if an error occurs when adding the JDBC authentication
*/
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() throws Exception {
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() {
return apply(new JdbcUserDetailsManagerConfigurer<>());
}
@ -177,7 +176,7 @@ public class AuthenticationManagerBuilder
* based authentication
*/
public <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T> userDetailsService(
T userDetailsService) throws Exception {
T userDetailsService) {
this.defaultUserDetailsService = userDetailsService;
return apply(new DaoAuthenticationConfigurer<>(userDetailsService));
}
@ -222,7 +221,7 @@ public class AuthenticationManagerBuilder
}
@Override
protected ProviderManager performBuild() throws Exception {
protected ProviderManager performBuild() {
if (!isConfigured()) {
this.logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
return null;
@ -277,7 +276,7 @@ public class AuthenticationManagerBuilder
* @throws Exception if an error occurs
*/
private <C extends UserDetailsAwareConfigurer<AuthenticationManagerBuilder, ? extends UserDetailsService>> C apply(
C configurer) throws Exception {
C configurer) {
this.defaultUserDetailsService = configurer.getUserDetailsService();
with(configurer);
return configurer;

View File

@ -107,7 +107,7 @@ public class AuthenticationConfiguration {
return new InitializeAuthenticationProviderBeanManagerConfigurer(context);
}
public AuthenticationManager getAuthenticationManager() throws Exception {
public AuthenticationManager getAuthenticationManager() {
if (this.authenticationManagerInitialized) {
return this.authenticationManager;
}
@ -274,19 +274,18 @@ public class AuthenticationConfiguration {
}
@Override
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication()
throws Exception {
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() {
return super.inMemoryAuthentication().passwordEncoder(this.defaultPasswordEncoder);
}
@Override
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() throws Exception {
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() {
return super.jdbcAuthentication().passwordEncoder(this.defaultPasswordEncoder);
}
@Override
public <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T> userDetailsService(
T userDetailsService) throws Exception {
T userDetailsService) {
return super.userDetailsService(userDetailsService).passwordEncoder(this.defaultPasswordEncoder);
}

View File

@ -35,11 +35,11 @@ public abstract class GlobalAuthenticationConfigurerAdapter
implements SecurityConfigurer<AuthenticationManager, AuthenticationManagerBuilder> {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
public void configure(AuthenticationManagerBuilder auth) {
}
}

View File

@ -49,7 +49,7 @@ class InitializeAuthenticationProviderBeanManagerConfigurer extends GlobalAuthen
}
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
auth.apply(new InitializeAuthenticationProviderManagerConfigurer());
}

View File

@ -56,7 +56,7 @@ class InitializeUserDetailsBeanManagerConfigurer extends GlobalAuthenticationCon
}
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
auth.apply(new InitializeUserDetailsManagerConfigurer());
}
@ -65,7 +65,7 @@ class InitializeUserDetailsBeanManagerConfigurer extends GlobalAuthenticationCon
private final Log logger = LogFactory.getLog(getClass());
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
public void configure(AuthenticationManagerBuilder auth) {
String[] beanNames = InitializeUserDetailsBeanManagerConfigurer.this.context
.getBeanNamesForType(UserDetailsService.class);
if (auth.isConfigured()) {

View File

@ -98,7 +98,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
unboundIdPresent = ClassUtils.isPresent(UNBOUNDID_CLASSNAME, classLoader);
}
private LdapAuthenticationProvider build() throws Exception {
private LdapAuthenticationProvider build() {
BaseLdapPathContextSource contextSource = getContextSource();
LdapAuthenticator ldapAuthenticator = createLdapAuthenticator(contextSource);
LdapAuthoritiesPopulator authoritiesPopulator = getLdapAuthoritiesPopulator();
@ -172,7 +172,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
* @return the {@link GrantedAuthoritiesMapper}
* @throws Exception if errors in {@link SimpleAuthorityMapper#afterPropertiesSet()}
*/
protected GrantedAuthoritiesMapper getAuthoritiesMapper() throws Exception {
protected GrantedAuthoritiesMapper getAuthoritiesMapper() {
if (this.authoritiesMapper != null) {
return this.authoritiesMapper;
}
@ -381,12 +381,12 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
LdapAuthenticationProvider provider = postProcess(build());
builder.authenticationProvider(provider);
}
private BaseLdapPathContextSource getContextSource() throws Exception {
private BaseLdapPathContextSource getContextSource() {
if (this.contextSource == null) {
this.contextSource = this.contextSourceBuilder.build();
}
@ -554,7 +554,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
return LdapAuthenticationProviderConfigurer.this;
}
private DefaultSpringSecurityContextSource build() throws Exception {
private DefaultSpringSecurityContextSource build() {
if (this.url == null) {
startEmbeddedLdapServer();
}

View File

@ -150,7 +150,7 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
}
@Override
protected void initUserDetailsService() throws Exception {
protected void initUserDetailsService() {
if (!this.initScripts.isEmpty()) {
getDataSourceInit().afterPropertiesSet();
}

View File

@ -54,7 +54,7 @@ public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C
* @throws Exception
*/
@Override
protected void initUserDetailsService() throws Exception {
protected void initUserDetailsService() {
for (UserDetailsBuilder userBuilder : this.userBuilders) {
getUserDetailsService().createUser(userBuilder.build());
}

View File

@ -81,7 +81,7 @@ public abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderMana
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
this.provider = postProcess(this.provider);
builder.authenticationProvider(this.provider);
}

View File

@ -43,7 +43,7 @@ public class UserDetailsServiceConfigurer<B extends ProviderManagerBuilder<B>, C
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
initUserDetailsService();
super.configure(builder);
}
@ -52,7 +52,7 @@ public class UserDetailsServiceConfigurer<B extends ProviderManagerBuilder<B>, C
* Allows subclasses to initialize the {@link UserDetailsService}. For example, it
* might add users, initialize schema, etc.
*/
protected void initUserDetailsService() throws Exception {
protected void initUserDetailsService() {
}
}

View File

@ -118,7 +118,7 @@ import org.springframework.web.filter.CorsFilter;
* public class FormLoginSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .requestMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;)
@ -199,7 +199,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CsrfSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .headers((headers) -&gt;
* headers
@ -222,7 +222,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CsrfSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .headers((headers) -&gt; headers.disable());
* return http.build();
@ -242,7 +242,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CsrfSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .headers((headers) -&gt;
* headers
@ -265,7 +265,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CsrfSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .headers((headers) -&gt;
* headers
@ -277,10 +277,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param headersCustomizer the {@link Customizer} to provide more options for the
* {@link HeadersConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity headers(Customizer<HeadersConfigurer<HttpSecurity>> headersCustomizer) throws Exception {
public HttpSecurity headers(Customizer<HeadersConfigurer<HttpSecurity>> headersCustomizer) {
headersCustomizer.customize(getOrApply(new HeadersConfigurer<>()));
return HttpSecurity.this;
}
@ -296,7 +295,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CorsSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .cors(withDefaults());
* return http.build();
@ -305,10 +304,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param corsCustomizer the {@link Customizer} to provide more options for the
* {@link CorsConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity cors(Customizer<CorsConfigurer<HttpSecurity>> corsCustomizer) throws Exception {
public HttpSecurity cors(Customizer<CorsConfigurer<HttpSecurity>> corsCustomizer) {
corsCustomizer.customize(getOrApply(new CorsConfigurer<>()));
return HttpSecurity.this;
}
@ -329,7 +327,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class SessionManagementSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -379,11 +377,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* could return true.
* @param sessionManagementCustomizer the {@link Customizer} to provide more options
* for the {@link SessionManagementConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity sessionManagement(
Customizer<SessionManagementConfigurer<HttpSecurity>> sessionManagementCustomizer) throws Exception {
Customizer<SessionManagementConfigurer<HttpSecurity>> sessionManagementCustomizer) {
sessionManagementCustomizer.customize(getOrApply(new SessionManagementConfigurer<>()));
return HttpSecurity.this;
}
@ -410,7 +407,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class PortMapperSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .requiresChannel((requiresChannel) -&gt;
* requiresChannel
@ -438,11 +435,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param portMapperCustomizer the {@link Customizer} to provide more options for the
* {@link PortMapperConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @see #requiresChannel(Customizer)
* @ @see #requiresChannel(Customizer)
*/
public HttpSecurity portMapper(Customizer<PortMapperConfigurer<HttpSecurity>> portMapperCustomizer)
throws Exception {
public HttpSecurity portMapper(Customizer<PortMapperConfigurer<HttpSecurity>> portMapperCustomizer) {
portMapperCustomizer.customize(getOrApply(new PortMapperConfigurer<>()));
return HttpSecurity.this;
}
@ -463,7 +458,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class JeeSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -520,10 +515,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* Servlet Container's documentation.
* @param jeeCustomizer the {@link Customizer} to provide more options for the
* {@link JeeConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity jee(Customizer<JeeConfigurer<HttpSecurity>> jeeCustomizer) throws Exception {
public HttpSecurity jee(Customizer<JeeConfigurer<HttpSecurity>> jeeCustomizer) {
jeeCustomizer.customize(getOrApply(new JeeConfigurer<>()));
return HttpSecurity.this;
}
@ -543,7 +537,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class X509SecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -556,10 +550,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param x509Customizer the {@link Customizer} to provide more options for the
* {@link X509Configurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity x509(Customizer<X509Configurer<HttpSecurity>> x509Customizer) throws Exception {
public HttpSecurity x509(Customizer<X509Configurer<HttpSecurity>> x509Customizer) {
x509Customizer.customize(getOrApply(new X509Configurer<>()));
return HttpSecurity.this;
}
@ -580,7 +573,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RememberMeSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -604,11 +597,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param rememberMeCustomizer the {@link Customizer} to provide more options for the
* {@link RememberMeConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity rememberMe(Customizer<RememberMeConfigurer<HttpSecurity>> rememberMeCustomizer)
throws Exception {
public HttpSecurity rememberMe(Customizer<RememberMeConfigurer<HttpSecurity>> rememberMeCustomizer) {
rememberMeCustomizer.customize(getOrApply(new RememberMeConfigurer<>()));
return HttpSecurity.this;
}
@ -629,7 +620,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class AuthorizeUrlsSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .requestMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;)
@ -665,7 +656,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class AuthorizeUrlsSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .requestMatchers(&quot;/admin/**&quot;).hasRole(&quot;ADMIN&quot;)
@ -702,7 +693,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class AuthorizeUrlsSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .requestMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;)
@ -715,12 +706,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param authorizeHttpRequestsCustomizer the {@link Customizer} to provide more
* options for the {@link AuthorizationManagerRequestMatcherRegistry}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 5.5
* @ @since 5.5
*/
public HttpSecurity authorizeHttpRequests(
Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry> authorizeHttpRequestsCustomizer)
throws Exception {
Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry> authorizeHttpRequestsCustomizer) {
ApplicationContext context = getContext();
authorizeHttpRequestsCustomizer
.customize(getOrApply(new AuthorizeHttpRequestsConfigurer<>(context)).getRegistry());
@ -744,7 +733,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RequestCacheDisabledSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -759,11 +748,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param requestCacheCustomizer the {@link Customizer} to provide more options for
* the {@link RequestCacheConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity requestCache(Customizer<RequestCacheConfigurer<HttpSecurity>> requestCacheCustomizer)
throws Exception {
public HttpSecurity requestCache(Customizer<RequestCacheConfigurer<HttpSecurity>> requestCacheCustomizer) {
requestCacheCustomizer.customize(getOrApply(new RequestCacheConfigurer<>()));
return HttpSecurity.this;
}
@ -783,7 +770,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class ExceptionHandlingSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -800,11 +787,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param exceptionHandlingCustomizer the {@link Customizer} to provide more options
* for the {@link ExceptionHandlingConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity exceptionHandling(
Customizer<ExceptionHandlingConfigurer<HttpSecurity>> exceptionHandlingCustomizer) throws Exception {
Customizer<ExceptionHandlingConfigurer<HttpSecurity>> exceptionHandlingCustomizer) {
exceptionHandlingCustomizer.customize(getOrApply(new ExceptionHandlingConfigurer<>()));
return HttpSecurity.this;
}
@ -822,7 +808,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class SecurityContextSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .securityContext((securityContext) -&gt;
* securityContext
@ -834,11 +820,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param securityContextCustomizer the {@link Customizer} to provide more options for
* the {@link SecurityContextConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity securityContext(Customizer<SecurityContextConfigurer<HttpSecurity>> securityContextCustomizer)
throws Exception {
public HttpSecurity securityContext(Customizer<SecurityContextConfigurer<HttpSecurity>> securityContextCustomizer) {
securityContextCustomizer.customize(getOrApply(new SecurityContextConfigurer<>()));
return HttpSecurity.this;
}
@ -854,7 +838,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class ServletApiSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .servletApi((servletApi) -&gt;
* servletApi.disable()
@ -865,11 +849,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param servletApiCustomizer the {@link Customizer} to provide more options for the
* {@link ServletApiConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity servletApi(Customizer<ServletApiConfigurer<HttpSecurity>> servletApiCustomizer)
throws Exception {
public HttpSecurity servletApi(Customizer<ServletApiConfigurer<HttpSecurity>> servletApiCustomizer) {
servletApiCustomizer.customize(getOrApply(new ServletApiConfigurer<>()));
return HttpSecurity.this;
}
@ -884,7 +866,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class CsrfSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .csrf((csrf) -&gt; csrf.disable());
* return http.build();
@ -893,10 +875,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param csrfCustomizer the {@link Customizer} to provide more options for the
* {@link CsrfConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity csrf(Customizer<CsrfConfigurer<HttpSecurity>> csrfCustomizer) throws Exception {
public HttpSecurity csrf(Customizer<CsrfConfigurer<HttpSecurity>> csrfCustomizer) {
ApplicationContext context = getContext();
csrfCustomizer.customize(getOrApply(new CsrfConfigurer<>(context)));
return HttpSecurity.this;
@ -921,7 +902,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class LogoutSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -951,10 +932,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param logoutCustomizer the {@link Customizer} to provide more options for the
* {@link LogoutConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity logout(Customizer<LogoutConfigurer<HttpSecurity>> logoutCustomizer) throws Exception {
public HttpSecurity logout(Customizer<LogoutConfigurer<HttpSecurity>> logoutCustomizer) {
logoutCustomizer.customize(getOrApply(new LogoutConfigurer<>()));
return HttpSecurity.this;
}
@ -977,7 +957,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class AnonymousSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1014,7 +994,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class AnonymousSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1041,10 +1021,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param anonymousCustomizer the {@link Customizer} to provide more options for the
* {@link AnonymousConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity anonymous(Customizer<AnonymousConfigurer<HttpSecurity>> anonymousCustomizer) throws Exception {
public HttpSecurity anonymous(Customizer<AnonymousConfigurer<HttpSecurity>> anonymousCustomizer) {
anonymousCustomizer.customize(getOrApply(new AnonymousConfigurer<>()));
return HttpSecurity.this;
}
@ -1067,7 +1046,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class FormLoginSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1097,7 +1076,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class FormLoginSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1128,10 +1107,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param formLoginCustomizer the {@link Customizer} to provide more options for the
* {@link FormLoginConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @see FormLoginConfigurer#loginPage(String)
* @ @see FormLoginConfigurer#loginPage(String)
*/
public HttpSecurity formLogin(Customizer<FormLoginConfigurer<HttpSecurity>> formLoginCustomizer) throws Exception {
public HttpSecurity formLogin(Customizer<FormLoginConfigurer<HttpSecurity>> formLoginCustomizer) {
formLoginCustomizer.customize(getOrApply(new FormLoginConfigurer<>()));
return HttpSecurity.this;
}
@ -1177,7 +1155,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class Saml2LoginSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1220,11 +1198,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param saml2LoginCustomizer the {@link Customizer} to provide more options for the
* {@link Saml2LoginConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 5.2
* @ @since 5.2
*/
public HttpSecurity saml2Login(Customizer<Saml2LoginConfigurer<HttpSecurity>> saml2LoginCustomizer)
throws Exception {
public HttpSecurity saml2Login(Customizer<Saml2LoginConfigurer<HttpSecurity>> saml2LoginCustomizer) {
saml2LoginCustomizer.customize(getOrApply(new Saml2LoginConfigurer<>()));
return HttpSecurity.this;
}
@ -1266,7 +1242,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* &#064;Configuration
* public class Saml2LogoutSecurityConfig {
* &#064;Bean
* public SecurityFilterChain web(HttpSecurity http) throws Exception {
* public SecurityFilterChain web(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .anyRequest().authenticated()
@ -1289,11 +1265,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
*
* <p>
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 5.6
* @ @since 5.6
*/
public HttpSecurity saml2Logout(Customizer<Saml2LogoutConfigurer<HttpSecurity>> saml2LogoutCustomizer)
throws Exception {
public HttpSecurity saml2Logout(Customizer<Saml2LogoutConfigurer<HttpSecurity>> saml2LogoutCustomizer) {
saml2LogoutCustomizer.customize(getOrApply(new Saml2LogoutConfigurer<>(getContext())));
return HttpSecurity.this;
}
@ -1319,7 +1293,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* &#064;Configuration
* public class Saml2LogoutSecurityConfig {
* &#064;Bean
* public SecurityFilterChain web(HttpSecurity http) throws Exception {
* public SecurityFilterChain web(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
* .saml2Metadata(Customizer.withDefaults());
@ -1339,11 +1313,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param saml2MetadataConfigurer the {@link Customizer} to provide more options for
* the {@link Saml2MetadataConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 6.1
* @ @since 6.1
*/
public HttpSecurity saml2Metadata(Customizer<Saml2MetadataConfigurer<HttpSecurity>> saml2MetadataConfigurer)
throws Exception {
public HttpSecurity saml2Metadata(Customizer<Saml2MetadataConfigurer<HttpSecurity>> saml2MetadataConfigurer) {
saml2MetadataConfigurer.customize(getOrApply(new Saml2MetadataConfigurer<>(getContext())));
return HttpSecurity.this;
}
@ -1395,7 +1367,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class OAuth2LoginSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1435,28 +1407,25 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param oauth2LoginCustomizer the {@link Customizer} to provide more options for the
* {@link OAuth2LoginConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @see <a target="_blank" href=
* "https://tools.ietf.org/html/rfc6749#section-4.1">Section 4.1 Authorization Code
* Grant</a>
* @ @see
* <a target="_blank" href= "https://tools.ietf.org/html/rfc6749#section-4.1">Section
* 4.1 Authorization Code Grant</a>
* @see <a target="_blank" href=
* "https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth">Section 3.1
* Authorization Code Flow</a>
* @see org.springframework.security.oauth2.client.registration.ClientRegistration
* @see org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
*/
public HttpSecurity oauth2Login(Customizer<OAuth2LoginConfigurer<HttpSecurity>> oauth2LoginCustomizer)
throws Exception {
public HttpSecurity oauth2Login(Customizer<OAuth2LoginConfigurer<HttpSecurity>> oauth2LoginCustomizer) {
oauth2LoginCustomizer.customize(getOrApply(new OAuth2LoginConfigurer<>()));
return HttpSecurity.this;
}
public OidcLogoutConfigurer<HttpSecurity> oidcLogout() throws Exception {
public OidcLogoutConfigurer<HttpSecurity> oidcLogout() {
return getOrApply(new OidcLogoutConfigurer<>());
}
public HttpSecurity oidcLogout(Customizer<OidcLogoutConfigurer<HttpSecurity>> oidcLogoutCustomizer)
throws Exception {
public HttpSecurity oidcLogout(Customizer<OidcLogoutConfigurer<HttpSecurity>> oidcLogoutCustomizer) {
oidcLogoutCustomizer.customize(getOrApply(new OidcLogoutConfigurer<>()));
return HttpSecurity.this;
}
@ -1475,7 +1444,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class OAuth2ClientSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1489,13 +1458,11 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param oauth2ClientCustomizer the {@link Customizer} to provide more options for
* the {@link OAuth2ClientConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @see <a target="_blank" href=
* "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
* Framework</a>
* @ @see
* <a target="_blank" href= "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth
* 2.0 Authorization Framework</a>
*/
public HttpSecurity oauth2Client(Customizer<OAuth2ClientConfigurer<HttpSecurity>> oauth2ClientCustomizer)
throws Exception {
public HttpSecurity oauth2Client(Customizer<OAuth2ClientConfigurer<HttpSecurity>> oauth2ClientCustomizer) {
oauth2ClientCustomizer.customize(getOrApply(new OAuth2ClientConfigurer<>()));
return HttpSecurity.this;
}
@ -1514,7 +1481,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class OAuth2ResourceServerSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1539,13 +1506,12 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param oauth2ResourceServerCustomizer the {@link Customizer} to provide more
* options for the {@link OAuth2ResourceServerConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @see <a target="_blank" href=
* "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization
* Framework</a>
* @ @see
* <a target="_blank" href= "https://tools.ietf.org/html/rfc6749#section-1.1">OAuth
* 2.0 Authorization Framework</a>
*/
public HttpSecurity oauth2ResourceServer(
Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>> oauth2ResourceServerCustomizer) throws Exception {
Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>> oauth2ResourceServerCustomizer) {
OAuth2ResourceServerConfigurer<HttpSecurity> configurer = getOrApply(
new OAuth2ResourceServerConfigurer<>(getContext()));
this.postProcess(configurer);
@ -1558,14 +1524,13 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param oauth2AuthorizationServerCustomizer the {@link Customizer} providing access
* to the {@link OAuth2AuthorizationServerConfigurer} for further customizations
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 7.0
* @ @since 7.0
* @see <a target="_blank" href=
* "https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-13.html">OAuth 2.1
* Authorization Framework</a>
*/
public HttpSecurity oauth2AuthorizationServer(
Customizer<OAuth2AuthorizationServerConfigurer> oauth2AuthorizationServerCustomizer) throws Exception {
Customizer<OAuth2AuthorizationServerConfigurer> oauth2AuthorizationServerCustomizer) {
oauth2AuthorizationServerCustomizer.customize(getOrApply(new OAuth2AuthorizationServerConfigurer()));
return HttpSecurity.this;
}
@ -1581,7 +1546,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class SecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* .anyRequest().authenticated()
@ -1599,12 +1564,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param oneTimeTokenLoginConfigurerCustomizer the {@link Customizer} to provide more
* options for the {@link OneTimeTokenLoginConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity oneTimeTokenLogin(
Customizer<OneTimeTokenLoginConfigurer<HttpSecurity>> oneTimeTokenLoginConfigurerCustomizer)
throws Exception {
Customizer<OneTimeTokenLoginConfigurer<HttpSecurity>> oneTimeTokenLoginConfigurerCustomizer) {
oneTimeTokenLoginConfigurerCustomizer.customize(getOrApply(new OneTimeTokenLoginConfigurer<>(getContext())));
return HttpSecurity.this;
}
@ -1627,7 +1590,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class ChannelSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1655,13 +1618,11 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param requiresChannelCustomizer the {@link Customizer} to provide more options for
* the {@link ChannelSecurityConfigurer.ChannelRequestMatcherRegistry}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @deprecated Use {@link #redirectToHttps}
*/
@Deprecated
public HttpSecurity requiresChannel(
Customizer<ChannelSecurityConfigurer<HttpSecurity>.ChannelRequestMatcherRegistry> requiresChannelCustomizer)
throws Exception {
Customizer<ChannelSecurityConfigurer<HttpSecurity>.ChannelRequestMatcherRegistry> requiresChannelCustomizer) {
ApplicationContext context = getContext();
requiresChannelCustomizer.customize(getOrApply(new ChannelSecurityConfigurer<>(context)).getRegistry());
return HttpSecurity.this;
@ -1683,7 +1644,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RequireHttpsConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorize) -&gt; authorize
* anyRequest().authenticated()
@ -1709,7 +1670,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @return the {@link HttpSecurity} for further customizations
*/
public HttpSecurity redirectToHttps(
Customizer<HttpsRedirectConfigurer<HttpSecurity>> httpsRedirectConfigurerCustomizer) throws Exception {
Customizer<HttpsRedirectConfigurer<HttpSecurity>> httpsRedirectConfigurerCustomizer) {
httpsRedirectConfigurerCustomizer.customize(getOrApply(new HttpsRedirectConfigurer<>()));
return HttpSecurity.this;
}
@ -1729,7 +1690,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class HttpBasicSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests((authorizeHttpRequests) -&gt;
* authorizeHttpRequests
@ -1752,10 +1713,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* </pre>
* @param httpBasicCustomizer the {@link Customizer} to provide more options for the
* {@link HttpBasicConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity httpBasic(Customizer<HttpBasicConfigurer<HttpSecurity>> httpBasicCustomizer) throws Exception {
public HttpSecurity httpBasic(Customizer<HttpBasicConfigurer<HttpSecurity>> httpBasicCustomizer) {
httpBasicCustomizer.customize(getOrApply(new HttpBasicConfigurer<>()));
return HttpSecurity.this;
}
@ -1774,7 +1734,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class PasswordManagementSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .authorizeHttpRequests(authorizeHttpRequests -&gt;
* authorizeHttpRequests
@ -1791,11 +1751,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* @param passwordManagementCustomizer the {@link Customizer} to provide more options
* for the {@link PasswordManagementConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @since 5.6
* @ @since 5.6
*/
public HttpSecurity passwordManagement(
Customizer<PasswordManagementConfigurer<HttpSecurity>> passwordManagementCustomizer) throws Exception {
Customizer<PasswordManagementConfigurer<HttpSecurity>> passwordManagementCustomizer) {
passwordManagementCustomizer.customize(getOrApply(new PasswordManagementConfigurer<>()));
return HttpSecurity.this;
}
@ -1818,7 +1777,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
}
@Override
protected void beforeConfigure() throws Exception {
protected void beforeConfigure() {
if (this.authenticationManager != null) {
setSharedObject(AuthenticationManager.class, this.authenticationManager);
}
@ -1849,7 +1808,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
}
@Override
public HttpSecurity userDetailsService(UserDetailsService userDetailsService) throws Exception {
public HttpSecurity userDetailsService(UserDetailsService userDetailsService) {
getAuthenticationRegistry().userDetailsService(userDetailsService);
return this;
}
@ -1937,7 +1896,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RequestMatchersSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .securityMatchers((matchers) -&gt; matchers
* .requestMatchers(&quot;/api/**&quot;, &quot;/oauth/**&quot;)
@ -1969,7 +1928,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RequestMatchersSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .securityMatchers((matchers) -&gt; matchers
* .requestMatchers(&quot;/api/**&quot;)
@ -2002,7 +1961,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* public class RequestMatchersSecurityConfig {
*
* &#064;Bean
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* public SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* .securityMatchers((matchers) -&gt; matchers
* .requestMatchers(&quot;/api/**&quot;)
@ -2089,7 +2048,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
*
* <pre>
* &#064;Bean
* SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
* SecurityFilterChain securityFilterChain(HttpSecurity http) {
* http
* // ...
* .webAuthn((webAuthn) -&gt; webAuthn
@ -2101,10 +2060,9 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* }
* </pre>
* @param webAuthn the customizer to apply
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
* @return the {@link HttpSecurity} for further customizations @
*/
public HttpSecurity webAuthn(Customizer<WebAuthnConfigurer<HttpSecurity>> webAuthn) throws Exception {
public HttpSecurity webAuthn(Customizer<WebAuthnConfigurer<HttpSecurity>> webAuthn) {
webAuthn.customize(getOrApply(new WebAuthnConfigurer<>()));
return HttpSecurity.this;
}
@ -2114,12 +2072,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
* otherwise apply the new {@link SecurityConfigurerAdapter}.
* @param configurer the {@link SecurityConfigurer} to apply if one is not found for
* this {@link SecurityConfigurer} class.
* @return the current {@link SecurityConfigurer} for the configurer passed in
* @throws Exception
* @return the current {@link SecurityConfigurer} for the configurer passed in @
*/
@SuppressWarnings("unchecked")
private <C extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity>> C getOrApply(C configurer)
throws Exception {
private <C extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity>> C getOrApply(C configurer) {
C existingConfig = (C) getConfigurer(configurer.getClass());
if (existingConfig != null) {
return existingConfig;

View File

@ -302,7 +302,7 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
}
@Override
protected Filter performBuild() throws Exception {
protected Filter performBuild() {
Assert.state(!this.securityFilterChainBuilders.isEmpty(),
() -> "At least one SecurityBuilder<? extends SecurityFilterChain> needs to be specified. "
+ "Typically this is done by exposing a SecurityFilterChain bean. "

View File

@ -112,7 +112,7 @@ class HttpSecurityConfiguration {
@Bean(HTTPSECURITY_BEAN_NAME)
@Scope("prototype")
HttpSecurity httpSecurity() throws Exception {
HttpSecurity httpSecurity() {
LazyPasswordEncoder passwordEncoder = new LazyPasswordEncoder(this.context);
AuthenticationManagerBuilder authenticationBuilder = new DefaultPasswordEncoderAuthenticationManagerBuilder(
this.objectPostProcessor, passwordEncoder);
@ -142,13 +142,13 @@ class HttpSecurityConfiguration {
return http;
}
private void applyCorsIfAvailable(HttpSecurity http) throws Exception {
private void applyCorsIfAvailable(HttpSecurity http) {
if (this.context.getBeanNamesForType(UrlBasedCorsConfigurationSource.class).length > 0) {
http.cors(withDefaults());
}
}
private AuthenticationManager authenticationManager() throws Exception {
private AuthenticationManager authenticationManager() {
return this.authenticationConfiguration.getAuthenticationManager();
}
@ -159,7 +159,7 @@ class HttpSecurityConfiguration {
return this.objectPostProcessor.postProcess(new DefaultAuthenticationEventPublisher());
}
private void applyDefaultConfigurers(HttpSecurity http) throws Exception {
private void applyDefaultConfigurers(HttpSecurity http) {
ClassLoader classLoader = this.context.getClassLoader();
List<AbstractHttpConfigurer> defaultHttpConfigurers = SpringFactoriesLoader
.loadFactories(AbstractHttpConfigurer.class, classLoader);
@ -197,8 +197,7 @@ class HttpSecurityConfiguration {
* with the {@link Customizer} Bean as the argument</li>
* </ul>
* @param context the {@link ApplicationContext}
* @param http the {@link HttpSecurity}
* @throws Exception
* @param http the {@link HttpSecurity} @
*/
private void applyTopLevelCustomizers(ApplicationContext context, HttpSecurity http) {
ReflectionUtils.MethodFilter isCustomizerMethod = (method) -> {
@ -266,19 +265,18 @@ class HttpSecurityConfiguration {
}
@Override
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication()
throws Exception {
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() {
return super.inMemoryAuthentication().passwordEncoder(this.defaultPasswordEncoder);
}
@Override
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() throws Exception {
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() {
return super.jdbcAuthentication().passwordEncoder(this.defaultPasswordEncoder);
}
@Override
public <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T> userDetailsService(
T userDetailsService) throws Exception {
T userDetailsService) {
return super.userDetailsService(userDetailsService).passwordEncoder(this.defaultPasswordEncoder);
}

View File

@ -232,7 +232,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
}
@Override
public void init(B http) throws Exception {
public void init(B http) {
updateAuthenticationDefaults();
updateAccessDefaults(http);
registerDefaultAuthenticationEntryPoint(http);
@ -268,7 +268,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
}
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
PortMapper portMapper = http.getSharedObject(PortMapper.class);
if (portMapper != null) {
this.authenticationEntryPoint.setPortMapper(portMapper);

View File

@ -229,7 +229,7 @@ public final class FormLoginConfigurer<H extends HttpSecurityBuilder<H>> extends
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
super.init(http);
initDefaultLoginFilter(http);
ExceptionHandlingConfigurer<H> exceptions = http.getConfigurer(ExceptionHandlingConfigurer.class);

View File

@ -61,7 +61,7 @@ public final class HttpsRedirectConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
HttpsRedirectFilter filter = new HttpsRedirectFilter();
if (this.requestMatcher != null) {
filter.setRequestMatcher(this.requestMatcher);

View File

@ -23,6 +23,7 @@ import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.SecurityConfigurer;
import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.authority.mapping.SimpleMappableAttributesRetriever;
@ -186,7 +187,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends Abstr
* and a {@link Http403ForbiddenEntryPoint} into
* {@link HttpSecurityBuilder#setSharedObject(Class, Object)}
*
* @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder)
* @see SecurityConfigurer#init(org.springframework.security.config.annotation.SecurityBuilder)
*/
@Override
public void init(H http) {

View File

@ -45,7 +45,8 @@ import org.springframework.util.Assert;
/**
* Adds logout support. Other {@link SecurityConfigurer} instances may invoke
* {@link #addLogoutHandler(LogoutHandler)} in the {@link #init(HttpSecurityBuilder)}
* {@link #addLogoutHandler(LogoutHandler)} in the
* {@link SecurityConfigurer#init(org.springframework.security.config.annotation.SecurityBuilder)}
* phase.
*
* <h2>Security Filters</h2>
@ -288,7 +289,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
LogoutFilter logoutFilter = createLogoutFilter(http);
http.addFilter(logoutFilter);
}

View File

@ -52,7 +52,7 @@ public final class PasswordManagementConfigurer<B extends HttpSecurityBuilder<B>
* {@inheritDoc}
*/
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
RequestMatcherRedirectFilter changePasswordFilter = new RequestMatcherRedirectFilter(
getRequestMatcherBuilder().matcher(WELL_KNOWN_CHANGE_PASSWORD_PATTERN), this.changePasswordPage);
http.addFilterBefore(postProcess(changePasswordFilter), UsernamePasswordAuthenticationFilter.class);

View File

@ -268,7 +268,7 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
@SuppressWarnings("unchecked")
@Override
public void init(H http) throws Exception {
public void init(H http) {
validateInput();
String key = getKey();
RememberMeServices rememberMeServices = getRememberMeServices(http, key);
@ -346,7 +346,7 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
* @return the {@link RememberMeServices} to use
* @throws Exception
*/
private RememberMeServices getRememberMeServices(H http, String key) throws Exception {
private RememberMeServices getRememberMeServices(H http, String key) {
if (this.rememberMeServices != null) {
if (this.rememberMeServices instanceof LogoutHandler && this.logoutHandler == null) {
this.logoutHandler = (LogoutHandler) this.rememberMeServices;

View File

@ -154,7 +154,7 @@ public class WebAuthnConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
ExceptionHandlingConfigurer<H> exceptions = http.getConfigurer(ExceptionHandlingConfigurer.class);
if (exceptions != null) {
AuthenticationEntryPoint entryPoint = new LoginUrlAuthenticationEntryPoint("/login");
@ -164,7 +164,7 @@ public class WebAuthnConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
UserDetailsService userDetailsService = getSharedOrBean(http, UserDetailsService.class)
.orElseThrow(() -> new IllegalStateException("Missing UserDetailsService Bean"));
PublicKeyCredentialUserEntityRepository userEntities = getSharedOrBean(http,

View File

@ -306,7 +306,7 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>>
}
@Override
public void init(B http) throws Exception {
public void init(B http) {
OAuth2LoginAuthenticationFilter authenticationFilter = new OAuth2LoginAuthenticationFilter(
this.getClientRegistrationRepository(), this.getAuthorizedClientRepository(), this.loginProcessingUrl);
RequestMatcher processUri = getRequestMatcherBuilder().matcher(this.loginProcessingUrl);
@ -377,7 +377,7 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>>
}
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter(
getAuthorizationRequestResolver());
if (this.authorizationEndpointConfig.authorizationRequestRepository != null) {

View File

@ -112,7 +112,7 @@ public final class OidcLogoutConfigurer<B extends HttpSecurityBuilder<B>>
}
@Override
public void configure(B builder) throws Exception {
public void configure(B builder) {
if (this.backChannel != null) {
this.backChannel.configure(builder);
}

View File

@ -295,7 +295,7 @@ public final class OAuth2AuthorizationServerConfigurer
}
@Override
public void init(HttpSecurity httpSecurity) throws Exception {
public void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
validateAuthorizationServerSettings(authorizationServerSettings);

View File

@ -129,7 +129,7 @@ public final class OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void init(H http) throws Exception {
public void init(H http) {
if (getLoginProcessingUrl() == null) {
loginProcessingUrl(OneTimeTokenAuthenticationFilter.DEFAULT_LOGIN_PROCESSING_URL);
}
@ -165,7 +165,7 @@ public final class OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
super.configure(http);
configureSubmitPage(http);
configureOttGenerateFilter(http);

View File

@ -273,7 +273,7 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
* </ul>
*/
@Override
public void init(B http) throws Exception {
public void init(B http) {
registerDefaultCsrfOverride(http);
relyingPartyRegistrationRepository(http);
this.saml2WebSsoAuthenticationFilter = new Saml2WebSsoAuthenticationFilter(getAuthenticationConverter(http));
@ -316,7 +316,7 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
* AuthNRequest redirects
*/
@Override
public void configure(B http) throws Exception {
public void configure(B http) {
Saml2WebSsoAuthenticationRequestFilter filter = getAuthenticationRequestFilter(http);
filter.setAuthenticationRequestRepository(getAuthenticationRequestRepository(http));
http.addFilter(postProcess(filter));

View File

@ -199,7 +199,7 @@ public final class Saml2LogoutConfigurer<H extends HttpSecurityBuilder<H>>
* {@inheritDoc}
*/
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
LogoutConfigurer<H> logout = http.getConfigurer(LogoutConfigurer.class);
if (logout != null) {
this.logoutHandlers = logout.getLogoutHandlers();

View File

@ -135,7 +135,7 @@ public class Saml2MetadataConfigurer<H extends HttpSecurityBuilder<H>>
}
@Override
public void configure(H http) throws Exception {
public void configure(H http) {
Saml2MetadataResponseResolver metadataResponseResolver = createMetadataResponseResolver(http);
http.addFilterBefore(new Saml2MetadataFilter(metadataResponseResolver), BasicAuthenticationFilter.class);
}

View File

@ -24,7 +24,6 @@ import org.springframework.core.MethodParameter
import org.springframework.core.ResolvableType
import org.springframework.core.annotation.AnnotationUtils
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.config.Customizer
import org.springframework.security.config.annotation.SecurityConfigurerAdapter
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository

View File

@ -55,7 +55,7 @@ public class SecurityConfigurerAdapterClosureTests {
private List<Object> list = new ArrayList<>();
@Override
public void configure(SecurityBuilder<Object> builder) throws Exception {
public void configure(SecurityBuilder<Object> builder) {
this.list = postProcess(this.list);
}

View File

@ -355,7 +355,7 @@ public class AuthenticationConfigurationTests {
static class UserGlobalAuthenticationConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
auth.inMemoryAuthentication().withUser(PasswordEncodedUser.user());
}
@ -428,7 +428,7 @@ public class AuthenticationConfigurationTests {
static List<Class<?>> configs = new ArrayList<>();
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
inits.add(getClass());
}
@ -454,7 +454,7 @@ public class AuthenticationConfigurationTests {
static class ConfiguresInMemoryConfigurerAdapter extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
// @formatter:off
auth
.inMemoryAuthentication()
@ -468,7 +468,7 @@ public class AuthenticationConfigurationTests {
static class BootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
auth.apply(new DefaultBootGlobalAuthenticationConfigurerAdapter());
}

View File

@ -453,7 +453,7 @@ public class GlobalMethodSecurityConfigurationTests {
DataSource dataSource;
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
auth.inMemoryAuthentication();
}

View File

@ -173,7 +173,7 @@ public class AbstractConfiguredSecurityBuilderTests {
extends SecurityConfigurerAdapter<Object, TestConfiguredSecurityBuilder> {
@Override
public void init(TestConfiguredSecurityBuilder builder) throws Exception {
public void init(TestConfiguredSecurityBuilder builder) {
builder.with(new NestedConfigurer(), Customizer.withDefaults());
}
@ -182,7 +182,7 @@ public class AbstractConfiguredSecurityBuilderTests {
private static class NestedConfigurer extends SecurityConfigurerAdapter<Object, TestConfiguredSecurityBuilder> {
@Override
public void init(TestConfiguredSecurityBuilder http) throws Exception {
public void init(TestConfiguredSecurityBuilder http) {
http.with(new DoubleNestedConfigurer(), Customizer.withDefaults());
}
@ -199,7 +199,7 @@ public class AbstractConfiguredSecurityBuilderTests {
private static SecurityConfigurer<Object, TestConfiguredSecurityBuilder> CONFIGURER;
@Override
public void init(TestConfiguredSecurityBuilder builder) throws Exception {
public void init(TestConfiguredSecurityBuilder builder) {
builder.apply(CONFIGURER);
builder.removeConfigurer(CONFIGURER.getClass());
}
@ -212,7 +212,7 @@ public class AbstractConfiguredSecurityBuilderTests {
private static SecurityConfigurer<Object, TestConfiguredSecurityBuilder> CONFIGURER;
@Override
public void init(TestConfiguredSecurityBuilder builder) throws Exception {
public void init(TestConfiguredSecurityBuilder builder) {
builder.apply(CONFIGURER);
builder.removeConfigurers(CONFIGURER.getClass());
}
@ -225,7 +225,7 @@ public class AbstractConfiguredSecurityBuilderTests {
private static SecurityConfigurer<Object, TestConfiguredSecurityBuilder> CONFIGURER;
@Override
public void init(TestConfiguredSecurityBuilder builder) throws Exception {
public void init(TestConfiguredSecurityBuilder builder) {
builder.apply(CONFIGURER);
}

View File

@ -720,7 +720,7 @@ public class HttpSecurityConfigurationTests {
static class CustomDsl extends AbstractHttpConfigurer<CustomDsl, HttpSecurity> {
@Override
public void init(HttpSecurity http) throws Exception {
public void init(HttpSecurity http) {
http.formLogin(FormLoginConfigurer::disable);
}
@ -824,7 +824,7 @@ public class HttpSecurityConfigurationTests {
static class WithCustomDsl extends AbstractHttpConfigurer<WithCustomDsl, HttpSecurity> {
@Override
public void init(HttpSecurity builder) throws Exception {
public void init(HttpSecurity builder) {
builder.formLogin(Customizer.withDefaults());
}

View File

@ -200,7 +200,7 @@ public class AnonymousConfigurerTests {
static class CustomDsl extends AbstractHttpConfigurer<CustomDsl, HttpSecurity> {
@Override
public void init(HttpSecurity http) throws Exception {
public void init(HttpSecurity http) {
http.anonymous((anonymous) -> anonymous.principal("myAnonymousUser"));
}

View File

@ -94,7 +94,7 @@ public class AuthenticationConfigurationGh3935Tests {
}
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
public void init(AuthenticationManagerBuilder auth) {
AuthenticationConfiguration configuration = this.context.getBean(AuthenticationConfiguration.class);
this.authenticationManager = configuration.getAuthenticationManager();
}

View File

@ -38,7 +38,7 @@ public class CustomConfigurer extends SecurityConfigurerAdapter<DefaultSecurityF
@SuppressWarnings("unchecked")
@Override
public void init(HttpSecurity http) throws Exception {
public void init(HttpSecurity http) {
// autowire this bean
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
context.getAutowireCapableBeanFactory().autowireBean(this);

View File

@ -16,7 +16,6 @@
package org.springframework.security.config.annotation.web
import io.mockk.Called
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify

View File

@ -24,11 +24,9 @@ import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configurers.oauth2.client.OidcBackChannelLogoutHandler
import org.springframework.security.config.annotation.web.oauth2.login.OidcBackChannelLogoutDsl
import org.springframework.security.config.test.SpringTestContext
import org.springframework.security.config.test.SpringTestContextExtension
import org.springframework.security.oauth2.client.oidc.session.InMemoryOidcSessionRegistry
import org.springframework.security.oauth2.client.oidc.session.OidcSessionRegistry
import org.springframework.security.oauth2.client.registration.ClientRegistration
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository

View File

@ -40,7 +40,6 @@ import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.MvcResult
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
import java.util.*
/**
* Tests for [Saml2LogoutDsl]

View File

@ -18,7 +18,6 @@ package org.springframework.security.config.annotation.web
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.verify
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Test
@ -28,29 +27,20 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.io.ClassPathResource
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.authentication.ProviderManager
import org.springframework.security.authentication.TestingAuthenticationProvider
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.test.SpringTestContext
import org.springframework.security.config.test.SpringTestContextExtension
import org.springframework.security.saml2.core.Saml2X509Credential
import org.springframework.security.saml2.provider.service.metadata.Saml2MetadataResponse
import org.springframework.security.saml2.provider.service.metadata.Saml2MetadataResponseResolver
import org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository
import org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations
import org.springframework.security.saml2.provider.service.web.authentication.Saml2WebSsoAuthenticationFilter
import org.springframework.security.web.SecurityFilterChain
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.security.cert.Certificate
import java.security.cert.CertificateFactory
import java.util.Base64
/**
* Tests for [Saml2Dsl]

View File

@ -122,7 +122,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException;
@Override
public final void afterPropertiesSet() throws Exception {
public final void afterPropertiesSet() {
Assert.notNull(this.userCache, "A user cache must be set");
Assert.notNull(this.messages, "A message source must be set");
Assert.notNull(this.preAuthenticationChecks, "A pre authentication checks must be set");
@ -215,7 +215,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
return result;
}
protected void doAfterPropertiesSet() throws Exception {
protected void doAfterPropertiesSet() {
}
public UserCache getUserCache() {

View File

@ -16,28 +16,16 @@
package org.springframework.security.docs.servlet.configuration.httpsecuritycustomizerbean;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.ThrowingCustomizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.config.test.SpringTestContext;
import org.springframework.security.config.test.SpringTestContextExtension;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultMatcher;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
/**
*

View File

@ -16,26 +16,16 @@
package org.springframework.security.docs.servlet.configuration.toplevelcustomizerbean;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.ThrowingCustomizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.config.test.SpringTestContext;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultMatcher;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
/**
*

View File

@ -4,11 +4,7 @@ import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.authorization.AllAuthoritiesAuthorizationManager.hasAllAuthorities
import org.springframework.security.authorization.AuthorizationDecision
import org.springframework.security.authorization.AuthorizationManager
import org.springframework.security.authorization.AuthorizationManagerFactory
import org.springframework.security.authorization.AuthorizationManagers.allOf
import org.springframework.security.authorization.DefaultAuthorizationManagerFactory
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
@ -21,7 +17,6 @@ import org.springframework.security.oauth2.client.registration.InMemoryClientReg
import org.springframework.security.oauth2.client.registration.TestClientRegistrations
import org.springframework.security.web.AuthenticationEntryPoint
import org.springframework.security.web.DefaultSecurityFilterChain
import org.springframework.security.web.access.intercept.RequestAuthorizationContext
import org.springframework.stereotype.Component
@EnableWebSecurity

View File

@ -23,7 +23,6 @@ import org.springframework.security.config.Customizer
import org.springframework.security.config.ThrowingCustomizer
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer
import org.springframework.security.config.annotation.web.configurers.HttpsRedirectConfigurer
import org.springframework.security.web.SecurityFilterChain

View File

@ -19,15 +19,11 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.Ordered
import org.springframework.core.annotation.Order
import org.springframework.security.config.Customizer
import org.springframework.security.config.ThrowingCustomizer
import org.springframework.security.config.annotation.web.HeadersDsl
import org.springframework.security.config.annotation.web.HttpSecurityDsl
import org.springframework.security.config.annotation.web.HttpsRedirectDsl
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer
import org.springframework.security.config.annotation.web.configurers.HttpsRedirectConfigurer
import org.springframework.security.config.annotation.web.invoke
import org.springframework.security.web.SecurityFilterChain
import org.springframework.web.servlet.config.annotation.EnableWebMvc

View File

@ -6,7 +6,6 @@ import org.springframework.security.config.Customizer
import org.springframework.security.config.ThrowingCustomizer
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer
import org.springframework.security.config.annotation.web.invoke
import org.springframework.security.web.SecurityFilterChain

View File

@ -1,20 +1,12 @@
package org.springframework.security.kt.docs.servlet.configuration.httpsecuritydslbean
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.HeadersDsl
import org.springframework.security.config.annotation.web.HttpSecurityDsl
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.invoke
import org.springframework.security.config.test.SpringTestContext
import org.springframework.security.config.test.SpringTestContextExtension
import org.springframework.security.web.SecurityFilterChain
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get
import org.springframework.web.servlet.config.annotation.EnableWebMvc

View File

@ -3,7 +3,6 @@ package org.springframework.security.kt.docs.servlet.configuration.topleveldslbe
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.HeadersDsl
import org.springframework.security.config.annotation.web.HttpSecurityDsl
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.invoke