-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathExpiredTokenAuthenticationProvider.java
More file actions
35 lines (27 loc) · 1.46 KB
/
ExpiredTokenAuthenticationProvider.java
File metadata and controls
35 lines (27 loc) · 1.46 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.security.provider;
import com.example.solidconnection.config.security.JwtProperties;
import com.example.solidconnection.custom.security.authentication.ExpiredTokenAuthentication;
import com.example.solidconnection.custom.security.authentication.JwtAuthentication;
import lombok.RequiredArgsConstructor;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
import static com.example.solidconnection.util.JwtUtils.parseSubjectIgnoringExpiration;
// todo: 사용되지 않음, 다른 PR에서 삭제하고 더 효율적인 구조를 고민해봐야 함
@Component
@RequiredArgsConstructor
public class ExpiredTokenAuthenticationProvider implements AuthenticationProvider {
private final JwtProperties jwtProperties;
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
JwtAuthentication jwtAuth = (JwtAuthentication) auth;
String token = jwtAuth.getToken();
String subject = parseSubjectIgnoringExpiration(token, jwtProperties.secret());
return new ExpiredTokenAuthentication(token, subject);
}
@Override
public boolean supports(Class<?> authentication) {
return ExpiredTokenAuthentication.class.isAssignableFrom(authentication);
}
}