From 93a9c893c5051547ac844bbc55bd3853c7a11725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=A7=80=EB=A5=9C?= Date: Fri, 4 Oct 2024 15:13:44 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=8A=A4=ED=94=84=EB=A7=81=20?= =?UTF-8?q?=EB=B6=80=ED=8A=B8=20=EB=B2=84=EC=A0=84=203.3.4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 6 +-- .../stard/domain/admin/api/FaqController.java | 2 +- .../domain/admin/api/NoticeController.java | 2 +- .../board/community/api/QnaController.java | 2 +- .../global/application/ReplyService.java | 2 +- .../global/application/ReportService.java | 2 +- .../domain/board/global/domain/Post.java | 4 +- .../domain/board/global/domain/Reply.java | 4 +- .../domain/board/global/domain/Report.java | 4 +- .../board/global/domain/ReportDetail.java | 2 +- .../domain/board/global/domain/StarScrap.java | 4 +- .../domain/board/study/domain/Applicant.java | 5 +-- .../domain/board/study/domain/Assignee.java | 2 +- .../domain/board/study/domain/Evaluation.java | 5 +-- .../domain/board/study/domain/Schedule.java | 5 +-- .../domain/board/study/domain/Study.java | 4 +- .../board/study/domain/StudyMember.java | 4 +- .../domain/board/study/domain/StudyPost.java | 4 +- .../stard/domain/board/study/domain/ToDo.java | 4 +- .../domain/board/study/dto/StudyDto.java | 2 +- .../application/ChatRoomService.java | 2 +- .../domain/chat_stomp/domain/ChatMessage.java | 4 +- .../domain/chat_stomp/domain/ChatRoom.java | 5 +-- .../domain/member/api/PasswordController.java | 5 +-- .../domain/member/api/SignController.java | 4 +- .../member/application/EmailService.java | 2 +- .../member/application/EmailServiceImpl.java | 17 +++---- .../member/application/MemberService.java | 5 ++- .../member/application/SignService.java | 21 +++++---- .../stard/domain/member/domain/Interest.java | 2 +- .../stard/domain/member/domain/Member.java | 4 +- .../stard/domain/member/domain/Profile.java | 2 +- .../web/stard/domain/member/dto/EmailDto.java | 2 +- .../domain/member/dto/MemberRequestDto.java | 2 +- .../notification/domain/Notification.java | 2 +- .../domain/NotificationContent.java | 4 +- .../notification/domain/RelatedURL.java | 5 +-- .../config/jwt/JwtAuthenticationFilter.java | 15 ++++--- .../config/redis/RedisRepositoryConfig.java | 34 -------------- .../config/security/WebSecurityConfig.java | 45 +++++++------------ .../web/stard/global/domain/BaseEntity.java | 6 +-- .../CustomAuthenticationFailureHandler.java | 6 +-- .../CustomAuthenticationSuccessHandler.java | 6 +-- .../global/handler/LoginSuccessHandler.java | 8 ++-- .../com/web/stard/global/util/RedisUtil.java | 25 +++++++++++ 45 files changed, 138 insertions(+), 164 deletions(-) delete mode 100644 src/main/java/com/web/stard/global/config/redis/RedisRepositoryConfig.java create mode 100644 src/main/java/com/web/stard/global/util/RedisUtil.java diff --git a/build.gradle b/build.gradle index d608665..977ee02 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ plugins { id 'java' - id 'org.springframework.boot' version '2.7.13' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' + id 'org.springframework.boot' version '3.3.4' + id 'io.spring.dependency-management' version '1.1.6' } group = 'com.web' version = '0.0.1-SNAPSHOT' java { - sourceCompatibility = '11' + sourceCompatibility = '17' } configurations { diff --git a/src/main/java/com/web/stard/domain/admin/api/FaqController.java b/src/main/java/com/web/stard/domain/admin/api/FaqController.java index d4ca53a..cd308ca 100644 --- a/src/main/java/com/web/stard/domain/admin/api/FaqController.java +++ b/src/main/java/com/web/stard/domain/admin/api/FaqController.java @@ -11,7 +11,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; @Transactional @Getter diff --git a/src/main/java/com/web/stard/domain/admin/api/NoticeController.java b/src/main/java/com/web/stard/domain/admin/api/NoticeController.java index 3b761f8..b890891 100644 --- a/src/main/java/com/web/stard/domain/admin/api/NoticeController.java +++ b/src/main/java/com/web/stard/domain/admin/api/NoticeController.java @@ -11,7 +11,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import java.util.Optional; @Transactional diff --git a/src/main/java/com/web/stard/domain/board/community/api/QnaController.java b/src/main/java/com/web/stard/domain/board/community/api/QnaController.java index 2adff97..fc0a088 100644 --- a/src/main/java/com/web/stard/domain/board/community/api/QnaController.java +++ b/src/main/java/com/web/stard/domain/board/community/api/QnaController.java @@ -11,7 +11,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; @Transactional @Getter @Setter diff --git a/src/main/java/com/web/stard/domain/board/global/application/ReplyService.java b/src/main/java/com/web/stard/domain/board/global/application/ReplyService.java index 32f1658..6175d1a 100644 --- a/src/main/java/com/web/stard/domain/board/global/application/ReplyService.java +++ b/src/main/java/com/web/stard/domain/board/global/application/ReplyService.java @@ -28,7 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.EntityNotFoundException; +import jakarta.persistence.EntityNotFoundException; import java.util.List; import java.util.Optional; diff --git a/src/main/java/com/web/stard/domain/board/global/application/ReportService.java b/src/main/java/com/web/stard/domain/board/global/application/ReportService.java index 1975655..0dccf95 100644 --- a/src/main/java/com/web/stard/domain/board/global/application/ReportService.java +++ b/src/main/java/com/web/stard/domain/board/global/application/ReportService.java @@ -29,7 +29,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.EntityNotFoundException; +import jakarta.persistence.EntityNotFoundException; import java.util.*; @Transactional diff --git a/src/main/java/com/web/stard/domain/board/global/domain/Post.java b/src/main/java/com/web/stard/domain/board/global/domain/Post.java index 39eec2b..ac05e52 100644 --- a/src/main/java/com/web/stard/domain/board/global/domain/Post.java +++ b/src/main/java/com/web/stard/domain/board/global/domain/Post.java @@ -1,12 +1,12 @@ package com.web.stard.domain.board.global.domain; -import com.sun.istack.NotNull; import com.web.stard.domain.board.global.domain.enums.PostType; import com.web.stard.domain.member.domain.Member; import com.web.stard.global.domain.BaseEntity; +import jakarta.validation.constraints.NotNull; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/global/domain/Reply.java b/src/main/java/com/web/stard/domain/board/global/domain/Reply.java index 6b56bb1..c8c12ea 100644 --- a/src/main/java/com/web/stard/domain/board/global/domain/Reply.java +++ b/src/main/java/com/web/stard/domain/board/global/domain/Reply.java @@ -7,8 +7,8 @@ import com.web.stard.global.domain.BaseEntity; import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/global/domain/Report.java b/src/main/java/com/web/stard/domain/board/global/domain/Report.java index 4407746..bba913a 100644 --- a/src/main/java/com/web/stard/domain/board/global/domain/Report.java +++ b/src/main/java/com/web/stard/domain/board/global/domain/Report.java @@ -6,8 +6,8 @@ import com.web.stard.domain.member.domain.Member; import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/global/domain/ReportDetail.java b/src/main/java/com/web/stard/domain/board/global/domain/ReportDetail.java index 6f6f14f..806083f 100644 --- a/src/main/java/com/web/stard/domain/board/global/domain/ReportDetail.java +++ b/src/main/java/com/web/stard/domain/board/global/domain/ReportDetail.java @@ -5,7 +5,7 @@ import com.web.stard.global.domain.BaseEntity; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/global/domain/StarScrap.java b/src/main/java/com/web/stard/domain/board/global/domain/StarScrap.java index 7b41e55..802d19b 100644 --- a/src/main/java/com/web/stard/domain/board/global/domain/StarScrap.java +++ b/src/main/java/com/web/stard/domain/board/global/domain/StarScrap.java @@ -1,6 +1,6 @@ package com.web.stard.domain.board.global.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import com.web.stard.domain.board.global.domain.enums.ActType; import com.web.stard.domain.board.global.domain.enums.PostType; import com.web.stard.domain.board.study.domain.Study; @@ -8,7 +8,7 @@ import com.web.stard.domain.member.domain.Member; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/study/domain/Applicant.java b/src/main/java/com/web/stard/domain/board/study/domain/Applicant.java index bef9a84..d4ddbcf 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/Applicant.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/Applicant.java @@ -1,13 +1,12 @@ package com.web.stard.domain.board.study.domain; -import com.web.stard.domain.board.study.domain.Study; import com.web.stard.domain.member.domain.Member; import lombok.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; @Entity diff --git a/src/main/java/com/web/stard/domain/board/study/domain/Assignee.java b/src/main/java/com/web/stard/domain/board/study/domain/Assignee.java index 5339246..2fca565 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/Assignee.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/Assignee.java @@ -3,7 +3,7 @@ import com.web.stard.domain.member.domain.Member; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/study/domain/Evaluation.java b/src/main/java/com/web/stard/domain/board/study/domain/Evaluation.java index 51c016a..586260f 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/Evaluation.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/Evaluation.java @@ -1,11 +1,10 @@ package com.web.stard.domain.board.study.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import com.web.stard.domain.member.domain.Member; -import com.web.stard.domain.board.study.domain.Study; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/study/domain/Schedule.java b/src/main/java/com/web/stard/domain/board/study/domain/Schedule.java index 8b3962f..7d93124 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/Schedule.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/Schedule.java @@ -1,11 +1,10 @@ package com.web.stard.domain.board.study.domain; -import com.sun.istack.NotNull; -import com.web.stard.domain.board.study.domain.Study; +import jakarta.validation.constraints.NotNull; import lombok.*; import org.springframework.format.annotation.DateTimeFormat; -import javax.persistence.*; +import jakarta.persistence.*; import java.time.LocalDateTime; @Entity diff --git a/src/main/java/com/web/stard/domain/board/study/domain/Study.java b/src/main/java/com/web/stard/domain/board/study/domain/Study.java index 7bfa045..4dd492e 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/Study.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/Study.java @@ -1,6 +1,6 @@ package com.web.stard.domain.board.study.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import com.web.stard.domain.board.global.domain.enums.PostType; import com.web.stard.domain.board.study.domain.enums.ProgressStatus; import com.web.stard.domain.board.study.domain.enums.RecruitStatus; @@ -10,7 +10,7 @@ import org.springframework.data.annotation.CreatedDate; import org.springframework.format.annotation.DateTimeFormat; -import javax.persistence.*; +import jakarta.persistence.*; import java.time.LocalDate; @Entity diff --git a/src/main/java/com/web/stard/domain/board/study/domain/StudyMember.java b/src/main/java/com/web/stard/domain/board/study/domain/StudyMember.java index 81a44e3..4e69348 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/StudyMember.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/StudyMember.java @@ -3,8 +3,8 @@ import com.web.stard.domain.member.domain.Member; import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; @Entity @Builder diff --git a/src/main/java/com/web/stard/domain/board/study/domain/StudyPost.java b/src/main/java/com/web/stard/domain/board/study/domain/StudyPost.java index e00fb59..670cc84 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/StudyPost.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/StudyPost.java @@ -1,12 +1,12 @@ package com.web.stard.domain.board.study.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import com.web.stard.domain.board.global.domain.enums.PostType; import com.web.stard.domain.member.domain.Member; import com.web.stard.global.domain.BaseEntity; import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/board/study/domain/ToDo.java b/src/main/java/com/web/stard/domain/board/study/domain/ToDo.java index db1c5ea..2521885 100644 --- a/src/main/java/com/web/stard/domain/board/study/domain/ToDo.java +++ b/src/main/java/com/web/stard/domain/board/study/domain/ToDo.java @@ -1,10 +1,10 @@ package com.web.stard.domain.board.study.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import lombok.*; import org.springframework.format.annotation.DateTimeFormat; -import javax.persistence.*; +import jakarta.persistence.*; import java.time.LocalDateTime; @Entity diff --git a/src/main/java/com/web/stard/domain/board/study/dto/StudyDto.java b/src/main/java/com/web/stard/domain/board/study/dto/StudyDto.java index f8912cd..769acc6 100644 --- a/src/main/java/com/web/stard/domain/board/study/dto/StudyDto.java +++ b/src/main/java/com/web/stard/domain/board/study/dto/StudyDto.java @@ -1,6 +1,6 @@ package com.web.stard.domain.board.study.dto; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/web/stard/domain/chat_stomp/application/ChatRoomService.java b/src/main/java/com/web/stard/domain/chat_stomp/application/ChatRoomService.java index 762b4ec..785a1f2 100644 --- a/src/main/java/com/web/stard/domain/chat_stomp/application/ChatRoomService.java +++ b/src/main/java/com/web/stard/domain/chat_stomp/application/ChatRoomService.java @@ -2,11 +2,11 @@ import com.web.stard.domain.chat_stomp.domain.ChatRoom; import com.web.stard.domain.chat_stomp.repository.ChatRoomRepository; +import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; import java.util.*; @Service diff --git a/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatMessage.java b/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatMessage.java index 5c24548..988c4ba 100644 --- a/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatMessage.java +++ b/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatMessage.java @@ -7,8 +7,8 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; @Getter @Setter diff --git a/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatRoom.java b/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatRoom.java index 983799a..a5d4385 100644 --- a/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatRoom.java +++ b/src/main/java/com/web/stard/domain/chat_stomp/domain/ChatRoom.java @@ -2,9 +2,8 @@ import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.util.UUID; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; @Getter @Setter diff --git a/src/main/java/com/web/stard/domain/member/api/PasswordController.java b/src/main/java/com/web/stard/domain/member/api/PasswordController.java index c302b68..e1110f6 100644 --- a/src/main/java/com/web/stard/domain/member/api/PasswordController.java +++ b/src/main/java/com/web/stard/domain/member/api/PasswordController.java @@ -2,16 +2,13 @@ import com.web.stard.domain.member.dto.EmailDto; import com.web.stard.domain.member.application.EmailService; -import com.web.stard.domain.member.dto.PasswordUpdateDto; import com.web.stard.domain.member.dto.ResetPasswordResponse; import com.web.stard.domain.member.application.MemberService; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; -import javax.mail.MessagingException; +import jakarta.mail.MessagingException; @RestController @RequiredArgsConstructor diff --git a/src/main/java/com/web/stard/domain/member/api/SignController.java b/src/main/java/com/web/stard/domain/member/api/SignController.java index 5949d58..72d35ac 100644 --- a/src/main/java/com/web/stard/domain/member/api/SignController.java +++ b/src/main/java/com/web/stard/domain/member/api/SignController.java @@ -11,8 +11,8 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; @Slf4j @RequiredArgsConstructor diff --git a/src/main/java/com/web/stard/domain/member/application/EmailService.java b/src/main/java/com/web/stard/domain/member/application/EmailService.java index 510d762..3609671 100644 --- a/src/main/java/com/web/stard/domain/member/application/EmailService.java +++ b/src/main/java/com/web/stard/domain/member/application/EmailService.java @@ -2,7 +2,7 @@ import com.web.stard.domain.member.dto.EmailDto; -import javax.mail.MessagingException; +import jakarta.mail.MessagingException; public interface EmailService { diff --git a/src/main/java/com/web/stard/domain/member/application/EmailServiceImpl.java b/src/main/java/com/web/stard/domain/member/application/EmailServiceImpl.java index e12d537..2fc8189 100644 --- a/src/main/java/com/web/stard/domain/member/application/EmailServiceImpl.java +++ b/src/main/java/com/web/stard/domain/member/application/EmailServiceImpl.java @@ -3,6 +3,7 @@ import com.web.stard.domain.member.domain.Member; import com.web.stard.domain.member.dto.EmailDto; import com.web.stard.domain.member.repository.MemberRepository; +import com.web.stard.global.util.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -12,9 +13,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.mail.MessagingException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; import java.time.Duration; import java.util.Random; import java.util.UUID; @@ -34,7 +35,7 @@ public class EmailServiceImpl implements EmailService { private static final String RESET_PW_PREFIX = "ResetPwToken "; - private final RedisTemplate redisTemplate; + private final RedisUtil redisUtil; @Value("${spring.mail.auth-code-expiration-millis}") private long authCodeExpirationMillis; @@ -106,7 +107,7 @@ public void sendCodeToEmail(String toEmail) throws Exception { sendEmail(toEmail, authCode); // 이메일 인증 요청 시 인증 번호 Redis에 저장 ( key = "AuthCode " + Email / value = AuthCode ) - redisTemplate.opsForValue().set(AUTH_CODE_PREFIX + toEmail, authCode, Duration.ofMillis(authCodeExpirationMillis)); + redisUtil.setData(AUTH_CODE_PREFIX + toEmail, authCode, authCodeExpirationMillis); } @@ -117,7 +118,7 @@ public void sendCodeToEmail(String toEmail) throws Exception { */ @Override public boolean verifiedCode(String email, String authCode) throws Exception{ - String redisAuthCode = (String) redisTemplate.opsForValue().get(AUTH_CODE_PREFIX + email); + String redisAuthCode = redisUtil.getData(AUTH_CODE_PREFIX + email); if (redisAuthCode == null) throw new Exception("시간 초과"); @@ -144,7 +145,7 @@ public void sendEmailResetPw(EmailDto emailDto) throws MessagingException { while(isExist){ - String existEmail = (String) redisTemplate.opsForValue().get(RESET_PW_PREFIX + pwResetToken); + String existEmail = redisUtil.getData(RESET_PW_PREFIX + pwResetToken); if (existEmail == null) break; else @@ -171,7 +172,7 @@ public void sendEmailResetPw(EmailDto emailDto) throws MessagingException { // TODO 로그 삭제 log.info("비밀번호 재설정 Url 생성: " + pwResetUrl); emailSender.send(message); - redisTemplate.opsForValue().set(RESET_PW_PREFIX + pwResetToken, emailDto.getEmail(), Duration.ofMillis(RESET_PW_TOKEN_EXPIRE_TIME)); + redisUtil.setData(RESET_PW_PREFIX + pwResetToken, emailDto.getEmail(), RESET_PW_TOKEN_EXPIRE_TIME); } catch (MailException e) { e.printStackTrace(); log.debug("MailService.sendEmail exception occur toEmail: {}", emailDto.getEmail()); diff --git a/src/main/java/com/web/stard/domain/member/application/MemberService.java b/src/main/java/com/web/stard/domain/member/application/MemberService.java index 4b418c5..0d5c616 100644 --- a/src/main/java/com/web/stard/domain/member/application/MemberService.java +++ b/src/main/java/com/web/stard/domain/member/application/MemberService.java @@ -26,6 +26,7 @@ import com.web.stard.domain.member.domain.Role; import com.web.stard.global.error.CustomException; import com.web.stard.global.error.ErrorCode; +import com.web.stard.global.util.RedisUtil; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; @@ -66,7 +67,7 @@ public class MemberService { private final ReportRepository reportRepository; private final ReportDetailRepository reportDetailRepository; - private final RedisTemplate redisTemplate; + private final RedisUtil redisUtil; private final JwtTokenProvider jwtTokenProvider; private static final String RESET_PW_PREFIX = "ResetPwToken "; @@ -312,7 +313,7 @@ public ResetPasswordResponse verificationPassword(String token) throws Exception } private String validateResetPwToken(String token) throws Exception { - String email = (String)redisTemplate.opsForValue().get(RESET_PW_PREFIX + token); + String email = redisUtil.getData(RESET_PW_PREFIX + token); if (email == null) throw new CustomException(ErrorCode.INVALID_TOKEN); diff --git a/src/main/java/com/web/stard/domain/member/application/SignService.java b/src/main/java/com/web/stard/domain/member/application/SignService.java index 3eb9956..a4f69cc 100644 --- a/src/main/java/com/web/stard/domain/member/application/SignService.java +++ b/src/main/java/com/web/stard/domain/member/application/SignService.java @@ -8,6 +8,7 @@ import com.web.stard.domain.member.repository.MemberRepository; import com.web.stard.global.error.CustomException; import com.web.stard.global.error.ErrorCode; +import com.web.stard.global.util.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; @@ -19,7 +20,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.concurrent.TimeUnit; @Slf4j @@ -28,10 +29,9 @@ public class SignService { private final MemberRepository memberRepository; - private final Response response; private final JwtTokenProvider jwtTokenProvider; private final AuthenticationManagerBuilder authenticationManagerBuilder; - private final RedisTemplate redisTemplate; + private final RedisUtil redisUtil; private static final String AUTHORIZATION_HEADER = "Authorization"; private static final String BEARER_TYPE = "Bearer"; @@ -54,8 +54,8 @@ public TokenInfo signIn(MemberRequestDto.SignInDto dto) { TokenInfo tokenInfo = jwtTokenProvider.generateToken(authentication); // 4. RefreshToken Redis 저장 (expirationTime 설정을 통해 자동 삭제 처리) - redisTemplate.opsForValue() - .set("RT:" + authentication.getName(), tokenInfo.getRefreshToken(), tokenInfo.getRefreshTokenExpirationTime(), TimeUnit.MILLISECONDS); + redisUtil + .setData("RT:" + authentication.getName(), tokenInfo.getRefreshToken(), tokenInfo.getRefreshTokenExpirationTime()); return tokenInfo; } catch (BadCredentialsException exception) { @@ -70,7 +70,7 @@ public TokenInfo reissue(HttpServletRequest request) { // 2. 추출된 Access Token 에 담긴 Authentication 객체를 가져와 사용자의 id로 redis 에 저장된 Refresh Token 추출 Authentication authentication = jwtTokenProvider.getAuthentication(expiredAccessToken); - String refreshToken = (String) redisTemplate.opsForValue().get("RT:" + authentication.getName()); + String refreshToken = redisUtil.getData("RT:" + authentication.getName()); // 3. Refresh Token 검증 if (!jwtTokenProvider.validateToken(refreshToken)) @@ -87,8 +87,7 @@ public TokenInfo reissue(HttpServletRequest request) { TokenInfo tokenInfo = jwtTokenProvider.generateToken(authentication); // 5. RefreshToken Redis 업데이트 - redisTemplate.opsForValue() - .set("RT:" + authentication.getName(), tokenInfo.getRefreshToken(), tokenInfo.getRefreshTokenExpirationTime(), TimeUnit.MILLISECONDS); + redisUtil.setData("RT:" + authentication.getName(), tokenInfo.getRefreshToken(), tokenInfo.getRefreshTokenExpirationTime()); return tokenInfo; } @@ -105,12 +104,12 @@ public void signOut(HttpServletRequest request) { Authentication authentication = jwtTokenProvider.getAuthentication(accessToken); // 3. Redis 에서 해당 User email 로 저장된 Refresh Token 존재 여부 확인 후 있을 경우 삭제 - if (redisTemplate.opsForValue().get("RT:" + authentication.getName()) != null) - redisTemplate.delete("RT:" + authentication.getName()); + if (redisUtil.getData("RT:" + authentication.getName()) != null) + redisUtil.deleteData("RT:" + authentication.getName()); // 4. 유효 시간이 만료되지 않는 경우, 해당 Access Token 유효시간 가지고 와서 BlackList 로 저장하기 Long expiration = jwtTokenProvider.getExpiration(accessToken); - redisTemplate.opsForValue().set(accessToken, "logout", expiration, TimeUnit.MILLISECONDS); + redisUtil.setData(accessToken, "logout", expiration); } else { // 만료된 access Token throw new CustomException(ErrorCode.EXPIRED_TOKEN); diff --git a/src/main/java/com/web/stard/domain/member/domain/Interest.java b/src/main/java/com/web/stard/domain/member/domain/Interest.java index c569e28..afe6c10 100644 --- a/src/main/java/com/web/stard/domain/member/domain/Interest.java +++ b/src/main/java/com/web/stard/domain/member/domain/Interest.java @@ -4,7 +4,7 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/member/domain/Member.java b/src/main/java/com/web/stard/domain/member/domain/Member.java index aa5546a..ee1698f 100644 --- a/src/main/java/com/web/stard/domain/member/domain/Member.java +++ b/src/main/java/com/web/stard/domain/member/domain/Member.java @@ -1,12 +1,12 @@ package com.web.stard.domain.member.domain; -import com.sun.istack.NotNull; +import jakarta.validation.constraints.NotNull; import lombok.*; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/src/main/java/com/web/stard/domain/member/domain/Profile.java b/src/main/java/com/web/stard/domain/member/domain/Profile.java index 8d1f75b..3ff0eec 100644 --- a/src/main/java/com/web/stard/domain/member/domain/Profile.java +++ b/src/main/java/com/web/stard/domain/member/domain/Profile.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table diff --git a/src/main/java/com/web/stard/domain/member/dto/EmailDto.java b/src/main/java/com/web/stard/domain/member/dto/EmailDto.java index 6a92217..98810e5 100644 --- a/src/main/java/com/web/stard/domain/member/dto/EmailDto.java +++ b/src/main/java/com/web/stard/domain/member/dto/EmailDto.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Data @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/com/web/stard/domain/member/dto/MemberRequestDto.java b/src/main/java/com/web/stard/domain/member/dto/MemberRequestDto.java index b9e14d8..9b9826d 100644 --- a/src/main/java/com/web/stard/domain/member/dto/MemberRequestDto.java +++ b/src/main/java/com/web/stard/domain/member/dto/MemberRequestDto.java @@ -4,7 +4,7 @@ import lombok.Setter; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import javax.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotEmpty; public class MemberRequestDto { diff --git a/src/main/java/com/web/stard/domain/notification/domain/Notification.java b/src/main/java/com/web/stard/domain/notification/domain/Notification.java index a3df0e7..64b3f72 100644 --- a/src/main/java/com/web/stard/domain/notification/domain/Notification.java +++ b/src/main/java/com/web/stard/domain/notification/domain/Notification.java @@ -8,7 +8,7 @@ import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/com/web/stard/domain/notification/domain/NotificationContent.java b/src/main/java/com/web/stard/domain/notification/domain/NotificationContent.java index 20eff8b..b24bcf7 100644 --- a/src/main/java/com/web/stard/domain/notification/domain/NotificationContent.java +++ b/src/main/java/com/web/stard/domain/notification/domain/NotificationContent.java @@ -3,8 +3,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.Embeddable; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Embeddable; +import jakarta.validation.constraints.NotNull; @Getter @Embeddable diff --git a/src/main/java/com/web/stard/domain/notification/domain/RelatedURL.java b/src/main/java/com/web/stard/domain/notification/domain/RelatedURL.java index fbe278c..3d91aed 100644 --- a/src/main/java/com/web/stard/domain/notification/domain/RelatedURL.java +++ b/src/main/java/com/web/stard/domain/notification/domain/RelatedURL.java @@ -1,11 +1,10 @@ package com.web.stard.domain.notification.domain; -import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.Embeddable; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Embeddable; +import jakarta.validation.constraints.NotNull; @Getter @Embeddable diff --git a/src/main/java/com/web/stard/global/config/jwt/JwtAuthenticationFilter.java b/src/main/java/com/web/stard/global/config/jwt/JwtAuthenticationFilter.java index 17d0374..70b9966 100644 --- a/src/main/java/com/web/stard/global/config/jwt/JwtAuthenticationFilter.java +++ b/src/main/java/com/web/stard/global/config/jwt/JwtAuthenticationFilter.java @@ -1,5 +1,6 @@ package com.web.stard.global.config.jwt; +import com.web.stard.global.util.RedisUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; @@ -9,11 +10,11 @@ import org.springframework.util.StringUtils; import org.springframework.web.filter.GenericFilterBean; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; @Slf4j @@ -24,7 +25,7 @@ public class JwtAuthenticationFilter extends GenericFilterBean { private static final String BEARER_TYPE = "Bearer"; private final JwtTokenProvider jwtTokenProvider; - private final RedisTemplate redisTemplate; + private final RedisUtil redisUtil; @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { @@ -35,7 +36,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha // 2. validateToken 으로 토큰 유효성 검사 if (token != null && jwtTokenProvider.validateToken(token)) { // (추가) Redis 에 해당 accessToken logout 여부 확인 - String isLogout = (String)redisTemplate.opsForValue().get(token); + String isLogout = redisUtil.getData(token); if (ObjectUtils.isEmpty(isLogout)) { // 토큰이 유효할 경우 토큰에서 Authentication 객체를 가지고 와서 SecurityContext 에 저장 Authentication authentication = jwtTokenProvider.getAuthentication(token); diff --git a/src/main/java/com/web/stard/global/config/redis/RedisRepositoryConfig.java b/src/main/java/com/web/stard/global/config/redis/RedisRepositoryConfig.java deleted file mode 100644 index a9f5ee3..0000000 --- a/src/main/java/com/web/stard/global/config/redis/RedisRepositoryConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.web.stard.global.config.redis; - -import lombok.RequiredArgsConstructor; -import org.springframework.boot.autoconfigure.data.redis.RedisProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; -import org.springframework.data.redis.serializer.StringRedisSerializer; - -@RequiredArgsConstructor -@Configuration -@EnableRedisRepositories -public class RedisRepositoryConfig { - - private final RedisProperties redisProperties; - - // lettuce - @Bean - public RedisConnectionFactory redisConnectionFactory() { - return new LettuceConnectionFactory(redisProperties.getHost(), redisProperties.getPort()); - } - - @Bean - public RedisTemplate redisTemplate() { - RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(redisConnectionFactory()); - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setValueSerializer(new StringRedisSerializer()); - return redisTemplate; - } -} \ No newline at end of file diff --git a/src/main/java/com/web/stard/global/config/security/WebSecurityConfig.java b/src/main/java/com/web/stard/global/config/security/WebSecurityConfig.java index 37c9472..331c4d7 100644 --- a/src/main/java/com/web/stard/global/config/security/WebSecurityConfig.java +++ b/src/main/java/com/web/stard/global/config/security/WebSecurityConfig.java @@ -2,26 +2,28 @@ import com.web.stard.global.config.jwt.JwtAuthenticationFilter; import com.web.stard.global.config.jwt.JwtTokenProvider; +import com.web.stard.global.util.RedisUtil; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -@RequiredArgsConstructor @EnableWebSecurity @Configuration +@RequiredArgsConstructor public class WebSecurityConfig { private final JwtTokenProvider jwtTokenProvider; - private final RedisTemplate redisTemplate; - + private final RedisUtil redisUtil; private static final String[] PERMIT_URL_ARRAY = { /* swagger v2 */ @@ -80,34 +82,21 @@ public class WebSecurityConfig { "/notifications/**" }; - @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception { - httpSecurity - .cors().and() - .httpBasic().disable() - .csrf().disable() - .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) - .and() - - .authorizeRequests() - .antMatchers(PERMIT_URL_ARRAY).permitAll() -// .antMatchers("/api/v1/users/userTest").hasRole("USER") -// .antMatchers("/api/v1/users/adminTest").hasRole("ADMIN") - .anyRequest().authenticated() - - // 해당 url 요청에 대해서는 로그인 요구 X -// .antMatchers("/", "/signup", "/checkDuplicateID", "/checkDuplicateNickname", "/login", "/current-member").permitAll() //TODO 주석 제거 - // admin 요청에 대해서는 ROLE_ADMIN 역할을 가지고 있어야 함 -// .antMatchers("/admin").hasRole("ADMIN") - // 나머지 요청에 대해서는 로그인 요구 O -// .anyRequest().authenticated() //TODO 주석 제거 - - .and() + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http + .csrf(AbstractHttpConfigurer::disable) + .httpBasic(AbstractHttpConfigurer::disable) + .sessionManagement(session -> session + .sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((authorize) -> authorize + .requestMatchers(PERMIT_URL_ARRAY).permitAll() + .anyRequest().authenticated()) // JwtAuthenticationFilter를 UsernamePasswordAuthenticationFilter 전에 적용 - .addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider, redisTemplate), UsernamePasswordAuthenticationFilter.class); + .addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider, redisUtil), UsernamePasswordAuthenticationFilter.class); - return httpSecurity.build(); + return http.build(); } // 암호화에 필요한 PasswordEncoder Bean 등록 diff --git a/src/main/java/com/web/stard/global/domain/BaseEntity.java b/src/main/java/com/web/stard/global/domain/BaseEntity.java index 9d32e78..e24b663 100644 --- a/src/main/java/com/web/stard/global/domain/BaseEntity.java +++ b/src/main/java/com/web/stard/global/domain/BaseEntity.java @@ -5,9 +5,9 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import javax.persistence.Column; -import javax.persistence.EntityListeners; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; import java.time.LocalDateTime; @EntityListeners(AuditingEntityListener.class) diff --git a/src/main/java/com/web/stard/global/handler/CustomAuthenticationFailureHandler.java b/src/main/java/com/web/stard/global/handler/CustomAuthenticationFailureHandler.java index 8e4595f..b5c2729 100644 --- a/src/main/java/com/web/stard/global/handler/CustomAuthenticationFailureHandler.java +++ b/src/main/java/com/web/stard/global/handler/CustomAuthenticationFailureHandler.java @@ -4,9 +4,9 @@ import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.stereotype.Component; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; @Component diff --git a/src/main/java/com/web/stard/global/handler/CustomAuthenticationSuccessHandler.java b/src/main/java/com/web/stard/global/handler/CustomAuthenticationSuccessHandler.java index 727f538..5f5dfa1 100644 --- a/src/main/java/com/web/stard/global/handler/CustomAuthenticationSuccessHandler.java +++ b/src/main/java/com/web/stard/global/handler/CustomAuthenticationSuccessHandler.java @@ -4,9 +4,9 @@ import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.stereotype.Component; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; @Component diff --git a/src/main/java/com/web/stard/global/handler/LoginSuccessHandler.java b/src/main/java/com/web/stard/global/handler/LoginSuccessHandler.java index 16a17ed..f218c3b 100644 --- a/src/main/java/com/web/stard/global/handler/LoginSuccessHandler.java +++ b/src/main/java/com/web/stard/global/handler/LoginSuccessHandler.java @@ -3,10 +3,10 @@ import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import java.io.IOException; public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { diff --git a/src/main/java/com/web/stard/global/util/RedisUtil.java b/src/main/java/com/web/stard/global/util/RedisUtil.java new file mode 100644 index 0000000..3e96bc8 --- /dev/null +++ b/src/main/java/com/web/stard/global/util/RedisUtil.java @@ -0,0 +1,25 @@ +package com.web.stard.global.util; +import lombok.RequiredArgsConstructor; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.concurrent.TimeUnit; + +@Service +@RequiredArgsConstructor +public class RedisUtil { + + private final RedisTemplate redisTemplate; + + public void setData(String key, String value, Long expiredTime){ + redisTemplate.opsForValue().set(key, value, expiredTime, TimeUnit.MILLISECONDS); + } + + public String getData(String key){ + return (String) redisTemplate.opsForValue().get(key); + } + + public void deleteData(String key){ + redisTemplate.delete(key); + } +} \ No newline at end of file