diff --git a/.github/workflows/reformat-java.yml b/.github/workflows/reformat-java.yml deleted file mode 100644 index a81ad0a..0000000 --- a/.github/workflows/reformat-java.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: reformat-java -on: push - -jobs: - replace-google-format: - runs-on: ubuntu-latest - steps: - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: "17" - distribution: "temurin" - - uses: actions/checkout@v3 - - uses: axel-op/googlejavaformat-action@v3 - with: - commit-message: 'style : Google Java Format ${{ github.head_ref }}' - args: '--replace --aosp' diff --git a/src/main/java/online/partyrun/jwtmanager/JwtExtractor.java b/src/main/java/online/partyrun/jwtmanager/JwtExtractor.java index 13718d5..7605145 100644 --- a/src/main/java/online/partyrun/jwtmanager/JwtExtractor.java +++ b/src/main/java/online/partyrun/jwtmanager/JwtExtractor.java @@ -3,5 +3,7 @@ import online.partyrun.jwtmanager.dto.JwtPayload; public interface JwtExtractor { - JwtPayload extract(String accessToken); + JwtPayload extractAccessToken(String accessToken); + + JwtPayload extractRefreshToken(String refreshToken); } diff --git a/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java b/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java index de72d48..d670422 100644 --- a/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java +++ b/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java @@ -4,10 +4,8 @@ import lombok.RequiredArgsConstructor; import lombok.experimental.FieldDefaults; import lombok.extern.slf4j.Slf4j; - import online.partyrun.jwtmanager.manager.JwtManager; import online.partyrun.jwtmanager.manager.TokenManager; - import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; @@ -22,9 +20,8 @@ public class JwtConfig { public JwtManager jwtManager( @Value("${jwt.access-secret-key}") String accessKey, @Value("${jwt.access-expire-second:#{'1'}}") Long accessExpireSecond, - @Value( - "${jwt.refresh-secret-key:#{'DefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefault'}}") - String refreshKey, + @Value("${jwt.refresh-secret-key:#{'DefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefault'}}") + String refreshKey, @Value("${jwt.refresh-expire-second:#{'1'}}") Long refreshExpireSecond) { log.info("Starting JwtManager"); return new JwtManager( diff --git a/src/main/java/online/partyrun/jwtmanager/dto/JwtPayload.java b/src/main/java/online/partyrun/jwtmanager/dto/JwtPayload.java index 169f460..a6a3edc 100644 --- a/src/main/java/online/partyrun/jwtmanager/dto/JwtPayload.java +++ b/src/main/java/online/partyrun/jwtmanager/dto/JwtPayload.java @@ -3,4 +3,5 @@ import java.time.LocalDateTime; import java.util.List; -public record JwtPayload(String id, List roles, LocalDateTime expireAt) {} +public record JwtPayload(String id, List roles, LocalDateTime expireAt) { +} diff --git a/src/main/java/online/partyrun/jwtmanager/dto/JwtToken.java b/src/main/java/online/partyrun/jwtmanager/dto/JwtToken.java index a922729..0aed395 100644 --- a/src/main/java/online/partyrun/jwtmanager/dto/JwtToken.java +++ b/src/main/java/online/partyrun/jwtmanager/dto/JwtToken.java @@ -3,4 +3,5 @@ import lombok.Builder; @Builder -public record JwtToken(String accessToken, String refreshToken) {} +public record JwtToken(String accessToken, String refreshToken) { +} diff --git a/src/main/java/online/partyrun/jwtmanager/manager/JwtManager.java b/src/main/java/online/partyrun/jwtmanager/manager/JwtManager.java index bf72e91..6c7940e 100644 --- a/src/main/java/online/partyrun/jwtmanager/manager/JwtManager.java +++ b/src/main/java/online/partyrun/jwtmanager/manager/JwtManager.java @@ -3,7 +3,6 @@ import lombok.AccessLevel; import lombok.RequiredArgsConstructor; import lombok.experimental.FieldDefaults; - import online.partyrun.jwtmanager.JwtExtractor; import online.partyrun.jwtmanager.JwtGenerator; import online.partyrun.jwtmanager.dto.JwtPayload; @@ -26,11 +25,6 @@ public JwtToken generate(String id, Set roles) { .build(); } - @Override - public JwtPayload extract(String accessToken) { - return accessTokenManager.extract(accessToken); - } - @Override public JwtToken refresh(String refreshToken) { final JwtPayload jwtPayload = refreshTokenManager.extract(refreshToken); @@ -39,4 +33,14 @@ public JwtToken refresh(String refreshToken) { .refreshToken(refreshTokenManager.generate(jwtPayload.id(), jwtPayload.roles())) .build(); } + + @Override + public JwtPayload extractAccessToken(String accessToken) { + return accessTokenManager.extract(accessToken); + } + + @Override + public JwtPayload extractRefreshToken(String refreshToken) { + return refreshTokenManager.extract(refreshToken); + } } diff --git a/src/main/java/online/partyrun/jwtmanager/manager/TokenManager.java b/src/main/java/online/partyrun/jwtmanager/manager/TokenManager.java index 4d140e1..3f6ff56 100644 --- a/src/main/java/online/partyrun/jwtmanager/manager/TokenManager.java +++ b/src/main/java/online/partyrun/jwtmanager/manager/TokenManager.java @@ -5,19 +5,19 @@ import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; - import lombok.AccessLevel; import lombok.experimental.FieldDefaults; - import online.partyrun.jwtmanager.dto.JwtPayload; - import org.springframework.util.StringUtils; import java.security.Key; import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) public class TokenManager { diff --git a/src/test/java/online/partyrun/jwtmanager/manager/JwtManagerTest.java b/src/test/java/online/partyrun/jwtmanager/manager/JwtManagerTest.java index 555bad6..c15372a 100644 --- a/src/test/java/online/partyrun/jwtmanager/manager/JwtManagerTest.java +++ b/src/test/java/online/partyrun/jwtmanager/manager/JwtManagerTest.java @@ -1,17 +1,15 @@ package online.partyrun.jwtmanager.manager; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; - import lombok.AccessLevel; import lombok.experimental.FieldDefaults; - import online.partyrun.jwtmanager.dto.JwtToken; - import org.junit.jupiter.api.*; import java.util.Set; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + @DisplayName("JwtManagerTest 클래스") @FieldDefaults(level = AccessLevel.PRIVATE) class JwtManagerTest { diff --git a/src/test/java/online/partyrun/jwtmanager/manager/TokenManagerTest.java b/src/test/java/online/partyrun/jwtmanager/manager/TokenManagerTest.java index e6663ec..018676e 100644 --- a/src/test/java/online/partyrun/jwtmanager/manager/TokenManagerTest.java +++ b/src/test/java/online/partyrun/jwtmanager/manager/TokenManagerTest.java @@ -1,17 +1,10 @@ package online.partyrun.jwtmanager.manager; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; - import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.MalformedJwtException; - import lombok.AccessLevel; import lombok.experimental.FieldDefaults; - import online.partyrun.jwtmanager.dto.JwtPayload; - import org.junit.jupiter.api.*; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EmptySource; @@ -22,6 +15,10 @@ import java.time.temporal.ChronoUnit; import java.util.Set; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; + @DisplayName("TokenManager 클래스") @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) class TokenManagerTest {