Class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>>
- java.lang.Object
-
- org.springframework.security.config.annotation.SecurityConfigurerAdapter<DefaultSecurityFilterChain,B>
-
- org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<HttpBasicConfigurer<B>,B>
-
- org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer<B>
-
- All Implemented Interfaces:
SecurityConfigurer<DefaultSecurityFilterChain,B>
public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends AbstractHttpConfigurer<HttpBasicConfigurer<B>,B>
Adds HTTP basic based authentication. All attributes have reasonable defaults making all parameters are optional.Security Filters
The following Filters are populatedShared Objects Created
- AuthenticationEntryPoint - populated with the
authenticationEntryPoint(AuthenticationEntryPoint)
(defaultBasicAuthenticationEntryPoint
)
Shared Objects Used
The following shared objects are used:- Since:
- 3.2
-
-
Constructor Summary
Constructors Constructor Description HttpBasicConfigurer()
Creates a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpBasicConfigurer<B>
authenticationDetailsSource(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource)
Specifies a customAuthenticationDetailsSource
to use for basic authentication.HttpBasicConfigurer<B>
authenticationEntryPoint(AuthenticationEntryPoint authenticationEntryPoint)
TheAuthenticationEntryPoint
to be populated onBasicAuthenticationFilter
in the event that authentication fails.void
configure(B http)
Configure theSecurityBuilder
by setting the necessary properties on theSecurityBuilder
.void
init(B http)
Initialize theSecurityBuilder
.HttpBasicConfigurer<B>
realmName(java.lang.String realmName)
Allows easily changing the realm, but leaving the remaining defaults in place.-
Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, withObjectPostProcessor
-
Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
-
-
-
-
Constructor Detail
-
HttpBasicConfigurer
public HttpBasicConfigurer()
Creates a new instance- See Also:
HttpSecurity.httpBasic()
-
-
Method Detail
-
realmName
public HttpBasicConfigurer<B> realmName(java.lang.String realmName)
Allows easily changing the realm, but leaving the remaining defaults in place. IfauthenticationEntryPoint(AuthenticationEntryPoint)
has been invoked, invoking this method will result in an error.- Parameters:
realmName
- the HTTP Basic realm to use- Returns:
HttpBasicConfigurer
for additional customization
-
authenticationEntryPoint
public HttpBasicConfigurer<B> authenticationEntryPoint(AuthenticationEntryPoint authenticationEntryPoint)
TheAuthenticationEntryPoint
to be populated onBasicAuthenticationFilter
in the event that authentication fails. The default to useBasicAuthenticationEntryPoint
with the realm "Realm".- Parameters:
authenticationEntryPoint
- theAuthenticationEntryPoint
to use- Returns:
HttpBasicConfigurer
for additional customization
-
authenticationDetailsSource
public HttpBasicConfigurer<B> authenticationDetailsSource(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource)
Specifies a customAuthenticationDetailsSource
to use for basic authentication. The default isWebAuthenticationDetailsSource
.- Parameters:
authenticationDetailsSource
- the customAuthenticationDetailsSource
to use- Returns:
HttpBasicConfigurer
for additional customization
-
init
public void init(B http)
Description copied from interface:SecurityConfigurer
Initialize theSecurityBuilder
. Here only shared state should be created and modified, but not properties on theSecurityBuilder
used for building the object. This ensures that theSecurityConfigurer.configure(SecurityBuilder)
method uses the correct shared objects when building. Configurers should be applied here.- Specified by:
init
in interfaceSecurityConfigurer<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
- Overrides:
init
in classSecurityConfigurerAdapter<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
-
configure
public void configure(B http)
Description copied from interface:SecurityConfigurer
Configure theSecurityBuilder
by setting the necessary properties on theSecurityBuilder
.- Specified by:
configure
in interfaceSecurityConfigurer<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
- Overrides:
configure
in classSecurityConfigurerAdapter<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
-
-