1919import com .fasterxml .jackson .databind .ObjectMapper ;
2020import com .naturalprogrammer .spring .lemon .commons .LemonCommonsAutoConfiguration ;
2121import com .naturalprogrammer .spring .lemon .commons .LemonProperties ;
22- import com .naturalprogrammer .spring .lemon .commons .exceptions .handlers .BadCredentialsExceptionHandler ;
2322import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .DefaultExceptionHandlerControllerAdvice ;
2423import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .LemonErrorAttributes ;
2524import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .LemonErrorController ;
3231import org .apache .commons .logging .Log ;
3332import org .apache .commons .logging .LogFactory ;
3433import org .springframework .boot .autoconfigure .AutoConfigureBefore ;
34+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
3535import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
3636import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
3737import org .springframework .boot .autoconfigure .security .servlet .SecurityAutoConfiguration ;
5050import org .springframework .data .web .config .EnableSpringDataWebSupport ;
5151import org .springframework .http .converter .json .MappingJackson2HttpMessageConverter ;
5252import org .springframework .security .config .annotation .method .configuration .EnableGlobalMethodSecurity ;
53+ import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
54+ import org .springframework .security .web .SecurityFilterChain ;
5355import org .springframework .web .cors .CorsConfigurationSource ;
5456
5557import java .io .Serializable ;
@@ -107,9 +109,9 @@ public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(
107109 public <T extends Throwable >
108110 DefaultExceptionHandlerControllerAdvice <T > defaultExceptionHandlerControllerAdvice (
109111 ErrorResponseComposer <T > errorResponseComposer ) {
110-
111- log .info ("Configuring DefaultExceptionHandlerControllerAdvice" );
112- return new DefaultExceptionHandlerControllerAdvice <T >(errorResponseComposer );
112+
113+ log .info ("Configuring DefaultExceptionHandlerControllerAdvice" );
114+ return new DefaultExceptionHandlerControllerAdvice <>(errorResponseComposer );
113115 }
114116
115117 /**
@@ -120,8 +122,8 @@ DefaultExceptionHandlerControllerAdvice<T> defaultExceptionHandlerControllerAdvi
120122 public <T extends Throwable >
121123 ErrorAttributes errorAttributes (ErrorResponseComposer <T > errorResponseComposer ) {
122124
123- log .info ("Configuring LemonErrorAttributes" );
124- return new LemonErrorAttributes <T >(errorResponseComposer );
125+ log .info ("Configuring LemonErrorAttributes" );
126+ return new LemonErrorAttributes <>(errorResponseComposer );
125127 }
126128
127129 /**
@@ -148,16 +150,16 @@ public LemonCorsConfigurationSource corsConfigurationSource(LemonProperties prop
148150 log .info ("Configuring LemonCorsConfigurationSource" );
149151 return new LemonCorsConfigurationSource (properties );
150152 }
151-
153+
152154 /**
153155 * Configures LemonSecurityConfig if missing
154156 */
155157 @ Bean
156- @ ConditionalOnMissingBean (LemonWebSecurityConfig .class )
157- public LemonWebSecurityConfig lemonSecurityConfig () {
158-
159- log .info ("Configuring LemonWebSecurityConfig " );
160- return new LemonWebSecurityConfig ();
158+ @ ConditionalOnBean (LemonWebSecurityConfig .class )
159+ public SecurityFilterChain lemonSecurityFilterChain ( HttpSecurity http , LemonWebSecurityConfig securityConfig ) throws Exception {
160+
161+ log .info ("Configuring lemonSecurityFilterChain " );
162+ return securityConfig . configure ( http ). build ();
161163 }
162164
163165 /**
@@ -167,9 +169,9 @@ public LemonWebSecurityConfig lemonSecurityConfig() {
167169 @ ConditionalOnMissingBean (AuditorAware .class )
168170 public <ID extends Serializable >
169171 AuditorAware <ID > auditorAware () {
170-
171- log .info ("Configuring LemonAuditorAware" );
172- return new LemonWebAuditorAware <ID >();
172+
173+ log .info ("Configuring LemonAuditorAware" );
174+ return new LemonWebAuditorAware <>();
173175 }
174176
175177 /**
0 commit comments