Skip to content

Commit

Permalink
Merge pull request #249 from Review-zip/dev
Browse files Browse the repository at this point in the history
[Dev] main merge
  • Loading branch information
hsuush authored Feb 20, 2024
2 parents 6091b69 + 225ae55 commit 03e441c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/com/example/ReviewZIP/global/jwt/JwtProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.ReviewZIP.domain.token.dto.response.TokenDto;
import com.example.ReviewZIP.domain.user.Users;
import com.example.ReviewZIP.global.response.code.resultCode.ErrorStatus;
import com.example.ReviewZIP.global.response.exception.handler.GeneralHandler;
import com.example.ReviewZIP.global.response.exception.handler.UsersHandler;
import io.jsonwebtoken.*;
import io.jsonwebtoken.io.Decoders;
Expand Down Expand Up @@ -30,7 +31,7 @@
@Slf4j
@ConfigurationProperties("jwt")
public class JwtProvider {
private static final long ACCESS_TOKEN_EXPIRATION_TIME = 1000 * 60 * 60;
private static final long ACCESS_TOKEN_EXPIRATION_TIME = 1000 * 60 * 60 * 24;
private static final long REFRESH_TOKEN_EXPIRATION_TIME = 1000 * 24 * 60 * 60 * 7;

private static final String AUTHORITIES_KEY = "auth";
Expand Down Expand Up @@ -108,14 +109,14 @@ public boolean validateToken(String token) {
try {
Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token);
return true;
} catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) {
throw new UsersHandler(ErrorStatus.INVALID_ACCESS_TOKEN);
} catch (ExpiredJwtException e) {
throw new UsersHandler(ErrorStatus.EXPIRED_MEMBER_TOKEN);
throw new GeneralHandler(ErrorStatus.EXPIRED_JWT_EXCEPTION);
} catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) {
throw new GeneralHandler(ErrorStatus.INVALID_ACCESS_TOKEN);
} catch (UnsupportedJwtException e) {
throw new UsersHandler(ErrorStatus.UNSUPPORTED_TOKEN);
throw new GeneralHandler(ErrorStatus.UNSUPPORTED_TOKEN);
} catch (IllegalArgumentException e) {
throw new UsersHandler(ErrorStatus.ILLEGAL_ARGUMENT_TOKEN);
throw new GeneralHandler(ErrorStatus.ILLEGAL_ARGUMENT_TOKEN);
}
}

Expand Down

0 comments on commit 03e441c

Please sign in to comment.