Skip to content

Commit

Permalink
refactor - #111 메서드 접근 제어 범위 축소
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Mar 16, 2024
1 parent 4d738ce commit 6c61130
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class JwtGenerator {
private Long ACCESS_TOKEN_EXPIRATION_TIME;
@Value("${jwt.refresh-token-expiration-time}")
private Long REFRESH_TOKEN_EXPIRATION_TIME;

private final TokenRepository tokenRepository;

public String generateToken(Long userId, boolean isRefreshToken) {
Expand All @@ -49,6 +50,12 @@ public String generateToken(Long userId, boolean isRefreshToken) {
return token;
}

public JwtParser getJwtParser() {
return Jwts.parserBuilder()
.setSigningKey(getSigningKey())
.build();
}

private Date generateNowDate() {
return new Date();
}
Expand All @@ -57,7 +64,7 @@ private Date generateExpirationDate(boolean isRefreshToken, Date now) {
return new Date(now.getTime() + calculateExpirationTime(isRefreshToken));
}

public SecretKey getSigningKey() {
private SecretKey getSigningKey() {
return Keys.hmacShaKeyFor(encodeSecretKey().getBytes());
}

Expand All @@ -73,9 +80,4 @@ private String encodeSecretKey() {
.encodeToString(JWT_SECRET.getBytes(StandardCharsets.UTF_8));
}

public JwtParser getJwtParser() {
return Jwts.parserBuilder()
.setSigningKey(getSigningKey())
.build();
}
}

0 comments on commit 6c61130

Please sign in to comment.