Class WebSecurityConfigurer
java.lang.Object
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
es.kukenan.smartfi.springboot.config.security.WebSecurityConfigurer
- All Implemented Interfaces:
org.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,,org.springframework.security.config.annotation.web.builders.WebSecurity> org.springframework.security.config.annotation.web.WebSecurityConfigurer<org.springframework.security.config.annotation.web.builders.WebSecurity>
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled=true,
securedEnabled=true)
public class WebSecurityConfigurer
extends org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
REST API security configuration.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classAccess denied handler to configure how access denied errors are managed (a response is created by theRestExceptionHandler.private classAuthentication error handler to configure how authentication errors are managed (a response is created by theRestExceptionHandler. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContextPropagationInFilterContext propagation filter.private static final CustomObjectMapperObject mapper used to serialize http response bodies.private RestExceptionHandlerTheRestExceptionHandler.private JwtAuthorizationFilterJWT authorization filter.private WebSecurityConfigurerCustomizer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) (package private) voiddoDefaultConfigure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) Default web security configuration.private javax.servlet.Filterprivate voidhandleResponse(org.springframework.http.ResponseEntity<Object> response, javax.servlet.http.HttpServletResponse httpServletResponse) Handles a response created at theRestExceptionHandlerand writes the required http json error response.private voidoutputResponse(org.springframework.http.ResponseEntity<Object> responseEntity, javax.servlet.http.HttpServletResponse httpServletResponse) Write the given response entity to the http servlet response.Methods inherited from class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
authenticationManager, authenticationManagerBean, configure, configure, getApplicationContext, getHttp, init, setApplicationContext, setAuthenticationConfiguration, setContentNegotationStrategy, setObjectPostProcessor, setTrustResolver, userDetailsService, userDetailsServiceBean
-
Field Details
-
customObjectMapper
Object mapper used to serialize http response bodies. -
exceptionHandler
TheRestExceptionHandler. -
contextPropagationInFilter
Context propagation filter. -
jwtAuthorizationFilter
JWT authorization filter. -
webSecurityConfigurerCustomizer
-
-
Constructor Details
-
WebSecurityConfigurer
public WebSecurityConfigurer()
-
-
Method Details
-
configure
protected void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) throws Exception - Overrides:
configurein classorg.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter- Throws:
Exception
-
doDefaultConfigure
void doDefaultConfigure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) throws Exception Default web security configuration.- Parameters:
http-HttpSecurityinstance.- Throws:
Exception- if any exception is thrown.
-
handleResponse
private void handleResponse(org.springframework.http.ResponseEntity<Object> response, javax.servlet.http.HttpServletResponse httpServletResponse) throws IOException Handles a response created at theRestExceptionHandlerand writes the required http json error response.- Parameters:
response- the response created atRestExceptionHandler.httpServletResponse- theHttpServletResponse.- Throws:
IOException- if an exception is thrown writing the response to the output stream.
-
exceptionHandlerFilter
private javax.servlet.Filter exceptionHandlerFilter() -
outputResponse
private void outputResponse(org.springframework.http.ResponseEntity<Object> responseEntity, javax.servlet.http.HttpServletResponse httpServletResponse) Write the given response entity to the http servlet response.- Parameters:
responseEntity- the response entity.httpServletResponse- the http servlet request.
-