Commit d4b80e3 1 parent 2ed9ffa commit d4b80e3 Copy full SHA for d4b80e3
File tree 2 files changed +50
-0
lines changed
application/wypl-core/src/main/java/com/wypl/wyplcore
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .wypl .wyplcore .auth .utils ;
2
+
3
+ import org .springframework .core .MethodParameter ;
4
+ import org .springframework .stereotype .Component ;
5
+ import org .springframework .web .bind .support .WebDataBinderFactory ;
6
+ import org .springframework .web .context .request .NativeWebRequest ;
7
+ import org .springframework .web .method .support .HandlerMethodArgumentResolver ;
8
+ import org .springframework .web .method .support .ModelAndViewContainer ;
9
+
10
+ import com .wypl .wyplcore .auth .annotation .Authenticated ;
11
+ import com .wypl .wyplcore .auth .domain .AuthMember ;
12
+
13
+ @ Component
14
+ public class AuthenticatedArgumentResolver implements HandlerMethodArgumentResolver {
15
+
16
+ @ Override
17
+ public boolean supportsParameter (MethodParameter parameter ) {
18
+ boolean hasParameterAnnotation = parameter .hasParameterAnnotation (Authenticated .class );
19
+ boolean assignableFrom = AuthMember .class .isAssignableFrom (parameter .getParameterType ());
20
+ return hasParameterAnnotation && assignableFrom ;
21
+ }
22
+
23
+ @ Override
24
+ public AuthMember resolveArgument (
25
+ MethodParameter parameter ,
26
+ ModelAndViewContainer mavContainer ,
27
+ NativeWebRequest webRequest ,
28
+ WebDataBinderFactory binderFactory
29
+ ) {
30
+ return null ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ package com .wypl .wyplcore .global .config ;
2
+
3
+ import java .util .List ;
4
+
5
+ import org .springframework .context .annotation .Configuration ;
6
+ import org .springframework .web .method .support .HandlerMethodArgumentResolver ;
7
+ import org .springframework .web .servlet .config .annotation .WebMvcConfigurer ;
8
+
9
+ import com .wypl .wyplcore .auth .utils .AuthenticatedArgumentResolver ;
10
+
11
+ @ Configuration
12
+ public class WebConfig implements WebMvcConfigurer {
13
+
14
+ @ Override
15
+ public void addArgumentResolvers (List <HandlerMethodArgumentResolver > resolvers ) {
16
+ resolvers .add (new AuthenticatedArgumentResolver ());
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments