mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-16 07:13:30 +00:00
Add withDefaults Shortcut for Custom Configurers
Issue gh-13204
This commit is contained in:
parent
f1725b25a0
commit
728b5224cb
@ -144,6 +144,29 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
return configurer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a {@link SecurityConfigurerAdapter} to this {@link SecurityBuilder} and
|
||||
* invokes {@link SecurityConfigurerAdapter#setBuilder(SecurityBuilder)}.
|
||||
*
|
||||
* <p>
|
||||
* A shortcut for applying a configurer as-is, or in other words: <code>
|
||||
* .with(new MyConfigurer())
|
||||
* </code>
|
||||
*
|
||||
* <p>
|
||||
* Is identical to: <code>
|
||||
* .with(new MyConfigurer(), Customizer.withDefaults())
|
||||
* </code>
|
||||
* @param configurer
|
||||
* @return the {@link SecurityBuilder} for further customizations
|
||||
* @throws Exception
|
||||
* @since 7.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <C extends SecurityConfigurerAdapter<O, B>> B with(C configurer) throws Exception {
|
||||
return with(configurer, Customizer.withDefaults());
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a {@link SecurityConfigurerAdapter} to this {@link SecurityBuilder} and
|
||||
* invokes {@link SecurityConfigurerAdapter#setBuilder(SecurityBuilder)}.
|
||||
|
Loading…
x
Reference in New Issue
Block a user