diff --git a/src/main/java/com/dnd/dndtravel/auth/exception/AppleTokenRevokeException.java b/src/main/java/com/dnd/dndtravel/auth/exception/AppleTokenRevokeException.java new file mode 100644 index 0000000..113f71a --- /dev/null +++ b/src/main/java/com/dnd/dndtravel/auth/exception/AppleTokenRevokeException.java @@ -0,0 +1,9 @@ +package com.dnd.dndtravel.auth.exception; + +public class AppleTokenRevokeException extends RuntimeException { + private static final String MESSAGE = "Error revoking Apple token"; + + public AppleTokenRevokeException(Exception e) { + super(MESSAGE, e); + } +} diff --git a/src/main/java/com/dnd/dndtravel/auth/service/AppleOAuthService.java b/src/main/java/com/dnd/dndtravel/auth/service/AppleOAuthService.java index 0589eca..d0372ed 100644 --- a/src/main/java/com/dnd/dndtravel/auth/service/AppleOAuthService.java +++ b/src/main/java/com/dnd/dndtravel/auth/service/AppleOAuthService.java @@ -1,5 +1,6 @@ package com.dnd.dndtravel.auth.service; +import com.dnd.dndtravel.auth.exception.AppleTokenRevokeException; import com.dnd.dndtravel.auth.service.dto.response.AppleSocialTokenInfoResponse; import io.jsonwebtoken.JwsHeader; import io.jsonwebtoken.Jwts; @@ -105,7 +106,7 @@ public void revoke(String accessToken) { "access_token" ); } catch (Exception e) { - throw new RuntimeException("Error revoking Apple token", e); + throw new AppleTokenRevokeException(e); } } } diff --git a/src/main/java/com/dnd/dndtravel/common/CommonExceptionHandler.java b/src/main/java/com/dnd/dndtravel/common/CommonExceptionHandler.java index ca037c8..5239702 100644 --- a/src/main/java/com/dnd/dndtravel/common/CommonExceptionHandler.java +++ b/src/main/java/com/dnd/dndtravel/common/CommonExceptionHandler.java @@ -1,15 +1,12 @@ package com.dnd.dndtravel.common; +import com.dnd.dndtravel.auth.exception.*; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import com.dnd.dndtravel.auth.exception.AppleTokenDecodingException; -import com.dnd.dndtravel.auth.exception.JwtTokenDecodingException; -import com.dnd.dndtravel.auth.exception.JwtTokenExpiredException; -import com.dnd.dndtravel.auth.exception.RefreshTokenInvalidException; import com.dnd.dndtravel.map.exception.MemberAttractionNotFoundException; import com.dnd.dndtravel.map.exception.MemberNotFoundException; import com.dnd.dndtravel.map.exception.PhotoDeleteFailException; @@ -63,6 +60,13 @@ public ResponseEntity runtimeException(AppleTokenDecodingException e) { .body("토큰 인증에 실패했습니다"); } + @ExceptionHandler(AppleTokenRevokeException.class) + public ResponseEntity runtimeException(AppleTokenRevokeException e) { + return ResponseEntity + .status(HttpStatus.UNAUTHORIZED) + .body("토큰 인증에 실패했습니다"); + } + @ExceptionHandler(JwtTokenExpiredException.class) public ResponseEntity runtimeException(JwtTokenExpiredException e) { return ResponseEntity