-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathExpiredTokenResolver.java
More file actions
35 lines (31 loc) · 1.52 KB
/
ExpiredTokenResolver.java
File metadata and controls
35 lines (31 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.example.solidconnection.custom.resolver;
import com.example.solidconnection.custom.security.authentication.ExpiredTokenAuthentication;
import lombok.RequiredArgsConstructor;
import org.springframework.core.MethodParameter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
// todo: 사용되지 않음, 다른 PR에서 삭제하고 더 효율적인 구조를 고민해봐야 함
@Component
@RequiredArgsConstructor
public class ExpiredTokenResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(ExpiredToken.class)
&& parameter.getParameterType().equals(ExpiredTokenAuthentication.class);
}
@Override
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer,
NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
try {
return SecurityContextHolder.getContext().getAuthentication();
} catch (Exception e) {
return null;
}
}
}