shjung 2 anos atrás
pai
commit
4b316f55c6

+ 4 - 4
src/main/java/com/its/op/dao/repository/its/oper/TbUserInfrRepository.java

@@ -32,16 +32,16 @@ public interface TbUserInfrRepository extends JpaRepository<TbUserInfr, String>,
      * @param pswd
      * @return
      */
-    @Query(value = "SELECT crypto_encrypt(:pswd) AS PSWD FROM DUAL", nativeQuery = true)
-    String getCryptoEncrypt(@Param("pswd") String pswd);
+//    @Query(value = "SELECT crypto_encrypt(:pswd) AS PSWD FROM DUAL", nativeQuery = true)
+//    String getCryptoEncrypt(@Param("pswd") String pswd);
 
     /**
      * 복호화
      * @param pswd
      * @return
      */
-    @Query(value = "SELECT crypto_decrypt(:pswd) AS PSWD FROM DUAL", nativeQuery = true)
-    String getCryptoDecrypt(@Param("pswd") String pswd);
+//    @Query(value = "SELECT crypto_decrypt(:pswd) AS PSWD FROM DUAL", nativeQuery = true)
+//    String getCryptoDecrypt(@Param("pswd") String pswd);
 
     /**
      * 사용자 ID 갯수 조회

+ 1 - 1
src/main/java/com/its/op/security/UserDetailsServiceImpl.java

@@ -25,7 +25,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
         //log.info("loadUserByUsername: {}", userId);
         Optional<TbUserInfr> optUserInfr = this.userRepo.findById(userId);
         if (optUserInfr.isPresent()) {
-            optUserInfr.get().setPswd((this.userRepo.getCryptoDecrypt(optUserInfr.get().getPwd())));
+            //optUserInfr.get().setPswd((this.userRepo.getCryptoDecrypt(optUserInfr.get().getPwd())));
             return optUserInfr.get().toVo();
         }
         else {

+ 6 - 3
src/main/java/com/its/op/service/its/oper/TbUserInfrService.java

@@ -7,6 +7,7 @@ import com.its.op.dto.its.oper.TbUserInfrDto;
 import com.its.op.dto.its.oper.UserGropMenuInf;
 import com.its.op.dto.its.oper.UserMenuDto;
 import com.its.op.entity.its.oper.TbUserInfr;
+import com.its.utils.SHA256Util;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -138,7 +139,7 @@ public class TbUserInfrService {
         /**
          * 입력한 비밀번호를 암호화 한다.
          */
-        String pswd = this.repo.getCryptoEncrypt(orgPswd);
+        String pswd = SHA256Util.encrypt(orgPswd);//this.repo.getCryptoEncrypt(orgPswd);
         if (entity.getPwd().equals(pswd)) {
             // 입력한 비밀번호 암호화한 값이 이전 비밀번호 암호화 내용과 같음
             throw new NoSuchElementException("현재 비빌번호와 같습니다[2]: " + id);
@@ -197,12 +198,14 @@ public class TbUserInfrService {
 
     @Transactional(readOnly = true)
     public String getCryptoEncrypt(String pswd) {
-        return this.repo.getCryptoEncrypt(pswd);
+        return SHA256Util.encrypt(pswd);
+        //return this.repo.getCryptoEncrypt(pswd);
     }
 
     @Transactional(readOnly = true)
     public String getCryptoDecrypt(String pswd) {
-        return this.repo.getCryptoDecrypt(pswd);
+        return pswd;
+        //return this.repo.getCryptoDecrypt(pswd);
     }
 
     @Transactional(readOnly = true)

+ 2 - 2
src/test/java/com/its/op/ItsOpServerApplicationTests.java

@@ -18,8 +18,8 @@ public class ItsOpServerApplicationTests {
 
     @Test
     void encrypt() {
-        log.error("{}", SHA256Util.encrypt("1"));
-        log.error("{}", SHA256Util.encrypt2("admin12#$!"));
+        log.error("{}", SHA256Util.encrypt("1"));               // 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b
+        log.error("{}", SHA256Util.encrypt2("admin12#$!")); // 3de9f98e4b5b4e52ff7d78cfa3140cf23e2b33c5a3143d1b2d1048237c31593c
     }
     void reference1() {
         String name = "test";