11package org .dfbf .soundlink .global .auth ;
22
33import io .jsonwebtoken .security .Keys ;
4- import jakarta .annotation .PostConstruct ;
54import jakarta .servlet .http .Cookie ;
65import jakarta .servlet .http .HttpServletRequest ;
76import org .springframework .beans .factory .annotation .Autowired ;
1110import io .jsonwebtoken .*;
1211
1312import javax .crypto .SecretKey ;
14- import java .util .Base64 ;
1513import java .util .Date ;
1614import java .util .concurrent .TimeUnit ;
1715
@@ -26,32 +24,20 @@ public class JwtProvider {
2624 private long REFRESH_EXPIRATION_TIME ;
2725
2826 //시크릿 키
29- @ Value ("${jwt.secret}" )
30- private String secretKey ;
31- private SecretKey SECRET_KEY ;
32-
33- @ PostConstruct
34- public void init (){
35- byte [] keyBytes = Base64 .getDecoder ().decode (secretKey ); //인코딩된 문자열 ->바이트 배열로 변환
36- this .SECRET_KEY = Keys .hmacShaKeyFor (keyBytes ); //안전한 HMAC 키로 변환
37- System .out .println ("Decoded secretKey: " + secretKey ); // 디버깅용
38- System .out .println ("Generated SECRET_KEY: " + SECRET_KEY ); // 디버깅용
39- }
27+ SecretKey SECRET_KEY = Keys .hmacShaKeyFor ("ee7d4dcf88086125155386d999b3a2258d5c55671a390e608f49a2db31efc6e0" .getBytes ());
4028
4129 @ Autowired
4230 private RedisTemplate <String , String > redisTemplate ;
43-
4431 //Access 토큰
4532 public String createAccessToken (long userId ) {
4633 Claims claims = Jwts .claims ().setSubject (String .valueOf (userId ));
4734 Date now = new Date ();
48-
4935 return Jwts .builder ()
5036 .setClaims (claims )
5137 .setIssuedAt (now )
5238 .setExpiration (new Date (now .getTime ()+ACCESS_EXPIRATION_TIME ))
5339 .setHeaderParam ("typ" , "JWT" )
54- .signWith (SECRET_KEY , SignatureAlgorithm .HS256 )
40+ .signWith (SECRET_KEY ,SignatureAlgorithm .HS256 )
5541 .compact ();
5642 }
5743
@@ -134,5 +120,4 @@ public Long getUserId(String token){
134120 .getBody ()
135121 .getSubject ());
136122 }
137-
138123}
0 commit comments