19
19
import com .fasterxml .jackson .databind .ObjectMapper ;
20
20
import com .naturalprogrammer .spring .lemon .commons .LemonCommonsAutoConfiguration ;
21
21
import com .naturalprogrammer .spring .lemon .commons .LemonProperties ;
22
- import com .naturalprogrammer .spring .lemon .commons .exceptions .handlers .BadCredentialsExceptionHandler ;
23
22
import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .DefaultExceptionHandlerControllerAdvice ;
24
23
import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .LemonErrorAttributes ;
25
24
import com .naturalprogrammer .spring .lemon .commonsweb .exceptions .LemonErrorController ;
32
31
import org .apache .commons .logging .Log ;
33
32
import org .apache .commons .logging .LogFactory ;
34
33
import org .springframework .boot .autoconfigure .AutoConfigureBefore ;
34
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
35
35
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
36
36
import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
37
37
import org .springframework .boot .autoconfigure .security .servlet .SecurityAutoConfiguration ;
50
50
import org .springframework .data .web .config .EnableSpringDataWebSupport ;
51
51
import org .springframework .http .converter .json .MappingJackson2HttpMessageConverter ;
52
52
import 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 ;
53
55
import org .springframework .web .cors .CorsConfigurationSource ;
54
56
55
57
import java .io .Serializable ;
@@ -107,9 +109,9 @@ public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(
107
109
public <T extends Throwable >
108
110
DefaultExceptionHandlerControllerAdvice <T > defaultExceptionHandlerControllerAdvice (
109
111
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 );
113
115
}
114
116
115
117
/**
@@ -120,8 +122,8 @@ DefaultExceptionHandlerControllerAdvice<T> defaultExceptionHandlerControllerAdvi
120
122
public <T extends Throwable >
121
123
ErrorAttributes errorAttributes (ErrorResponseComposer <T > errorResponseComposer ) {
122
124
123
- log .info ("Configuring LemonErrorAttributes" );
124
- return new LemonErrorAttributes <T >(errorResponseComposer );
125
+ log .info ("Configuring LemonErrorAttributes" );
126
+ return new LemonErrorAttributes <>(errorResponseComposer );
125
127
}
126
128
127
129
/**
@@ -148,16 +150,16 @@ public LemonCorsConfigurationSource corsConfigurationSource(LemonProperties prop
148
150
log .info ("Configuring LemonCorsConfigurationSource" );
149
151
return new LemonCorsConfigurationSource (properties );
150
152
}
151
-
153
+
152
154
/**
153
155
* Configures LemonSecurityConfig if missing
154
156
*/
155
157
@ 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 ();
161
163
}
162
164
163
165
/**
@@ -167,9 +169,9 @@ public LemonWebSecurityConfig lemonSecurityConfig() {
167
169
@ ConditionalOnMissingBean (AuditorAware .class )
168
170
public <ID extends Serializable >
169
171
AuditorAware <ID > auditorAware () {
170
-
171
- log .info ("Configuring LemonAuditorAware" );
172
- return new LemonWebAuditorAware <ID >();
172
+
173
+ log .info ("Configuring LemonAuditorAware" );
174
+ return new LemonWebAuditorAware <>();
173
175
}
174
176
175
177
/**
0 commit comments