|
3 | 3 | import io.jsonwebtoken.security.Keys; |
4 | 4 | import jakarta.servlet.http.Cookie; |
5 | 5 | import jakarta.servlet.http.HttpServletRequest; |
| 6 | +import lombok.extern.slf4j.Slf4j; |
| 7 | +import org.dfbf.soundlink.domain.user.exception.CustomJwtException; |
6 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 9 | import org.springframework.beans.factory.annotation.Value; |
8 | 10 | import org.springframework.data.redis.core.RedisTemplate; |
|
13 | 15 | import java.util.Date; |
14 | 16 | import java.util.concurrent.TimeUnit; |
15 | 17 |
|
| 18 | +@Slf4j |
16 | 19 | @Component |
17 | 20 | public class JwtProvider { |
18 | 21 |
|
@@ -71,15 +74,14 @@ public boolean validateToken(String token) { |
71 | 74 |
|
72 | 75 | // 토큰이 유효한 경우 |
73 | 76 | return true; |
74 | | - } catch (ExpiredJwtException e) { |
75 | | - System.out.println("[ERROR] Token is expired."); |
76 | | - throw e; // 만료된 토큰에 대해 예외를 던짐 |
| 77 | + }catch (ExpiredJwtException e) { |
| 78 | + log.warn("[ERROR] Token is expired."); |
| 79 | + throw new CustomJwtException("토큰이 만료.", e); |
77 | 80 | } catch (JwtException e) { |
78 | | - System.out.println("[ERROR] Token validation failed: " + e.getMessage()); |
79 | | - throw e; // JWT 예외는 다시 던짐 |
| 81 | + log.warn("[ERROR] Token validation failed: {}", e.getMessage()); |
| 82 | + throw new CustomJwtException("토큰 검증 실패", e); |
80 | 83 | } catch (Exception e) { |
81 | | - System.out.println("[ERROR] Unexpected error: " + e.getMessage()); |
82 | | - throw new RuntimeException("Unexpected error", e); |
| 84 | + throw new CustomJwtException("예기치 않은 오류 발생", e); |
83 | 85 | } |
84 | 86 | } |
85 | 87 |
|
|
0 commit comments