shjung 2 yıl önce
ebeveyn
işleme
8896383717

+ 12 - 11
src/main/java/com/its/op/controller/its/LoginController.java

@@ -5,6 +5,7 @@ import com.its.op.config.JasyptConfig;
 import com.its.op.dto.its.LoginDto;
 import com.its.op.dto.its.common.UserInfoDto;
 import com.its.op.dto.its.oper.UserMenuDto;
+import com.its.op.security.WebConstants;
 import com.its.op.security.WebMvcConfig;
 import com.its.op.service.its.LoginService;
 import com.its.op.service.its.oper.TbUserInfrService;
@@ -73,8 +74,8 @@ public class LoginController {
         Authentication auth = SecurityContextHolder.getContext().getAuthentication();
         if (auth != null) {
             //log.info("getLogin3: auth, {}", auth.toString());
-            expiredCookie(response, WebMvcConfig.USER_UUID);
-            expiredCookie(response, WebMvcConfig.USER_TIME);
+            expiredCookie(response, WebConstants.USER_UUID);
+            expiredCookie(response, WebConstants.USER_TIME);
             new SecurityContextLogoutHandler().logout(request, response, auth);
         }
         HttpSession session = request.getSession(false);
@@ -96,7 +97,7 @@ public class LoginController {
 //        else {
 //            HttpSession session = request.getSession(false);
 //            if (session != null) {
-//                String encUserId = (String)session.getAttribute(WebMvcConfig.USER_UUID);
+//                String encUserId = (String)session.getAttribute(WebConstants.USER_UUID);
 //                if (!"".equals(encUserId)) {
 //                    userId = WebMvcConfig.decUserId(encUserId);
 //                }
@@ -113,8 +114,8 @@ public class LoginController {
         String encUserId = "";
         String loginHms = "";
         if (cookies != null && cookies.length > 0) {
-            encUserId = CookieUtils.getCookie(request, WebMvcConfig.USER_UUID);
-            loginHms = CookieUtils.getCookie(request, WebMvcConfig.USER_TIME);
+            encUserId = CookieUtils.getCookie(request, WebConstants.USER_UUID);
+            loginHms = CookieUtils.getCookie(request, WebConstants.USER_TIME);
         }
         if (!"".equals(encUserId)) {
             String userId = WebMvcConfig.decUserId(encUserId);
@@ -148,10 +149,10 @@ public class LoginController {
             for (Cookie cookie : cookies) {
                 log.info("logout: {}, {}", cookie.getName(), cookie.getValue());
             }
-            encUserId = CookieUtils.getCookie(request, WebMvcConfig.USER_UUID);
-            loginHms = CookieUtils.getCookie(request, WebMvcConfig.USER_TIME);
-            expiredCookie(response, WebMvcConfig.USER_UUID);
-            expiredCookie(response, WebMvcConfig.USER_TIME);
+            encUserId = CookieUtils.getCookie(request, WebConstants.USER_UUID);
+            loginHms = CookieUtils.getCookie(request, WebConstants.USER_TIME);
+            expiredCookie(response, WebConstants.USER_UUID);
+            expiredCookie(response, WebConstants.USER_TIME);
         }
         if (!"".equals(encUserId)) {
             String userId = WebMvcConfig.decUserId(encUserId);
@@ -167,8 +168,8 @@ public class LoginController {
 //        if (auth != null) {
 //            // 여기로 안들어오네... 나중에 확인.....
 //            log.error("Authentication: {}", auth.toString());
-//            expiredCookie(response, WebMvcConfig.USER_UUID);
-//            expiredCookie(response, WebMvcConfig.USER_TIME);
+//            expiredCookie(response, WebConstants.USER_UUID);
+//            expiredCookie(response, WebConstants.USER_TIME);
 //            //new SecurityContextLogoutHandler().logout(request, response, auth);
 //        }
 

+ 8 - 0
src/main/java/com/its/op/security/WebConstants.java

@@ -0,0 +1,8 @@
+package com.its.op.security;
+
+public interface WebConstants {
+
+    String USER_UUID = "UUID";
+    String USER_TIME = "TIME";
+
+}

+ 4 - 4
src/main/java/com/its/op/security/WebLoginSuccessHandler.java

@@ -61,11 +61,11 @@ public class WebLoginSuccessHandler implements AuthenticationSuccessHandler {
         String uri = defaultSuccessUrl;
         String domain = "/";
 
-        request.getSession().setAttribute(WebMvcConfig.USER_UUID, WebMvcConfig.encUserId(cnncHs.getUserId()));
-        request.getSession().setAttribute(WebMvcConfig.USER_TIME, cnncHs.getLoginHms());
+        request.getSession().setAttribute(WebConstants.USER_UUID, WebMvcConfig.encUserId(cnncHs.getUserId()));
+        request.getSession().setAttribute(WebConstants.USER_TIME, cnncHs.getLoginHms());
 
-        CookieUtils.setCookie(response, WebMvcConfig.USER_UUID, WebMvcConfig.encUserId(cnncHs.getUserId()), 60*60, domain);
-        CookieUtils.setCookie(response, WebMvcConfig.USER_TIME, cnncHs.getLoginHms(), 60*60, domain);
+        CookieUtils.setCookie(response, WebConstants.USER_UUID, WebMvcConfig.encUserId(cnncHs.getUserId()), 60*60, domain);
+        CookieUtils.setCookie(response, WebConstants.USER_TIME, cnncHs.getLoginHms(), 60*60, domain);
         CookieUtils.setCookie(response, "OPER_SYST_ID", userInfr.getOperSystId(), 60*60, domain);
 
         // Security 가 요청을 가로챈 경우 사용자가 원래 요청했던 URI 정보를 저장한 객체

+ 0 - 3
src/main/java/com/its/op/security/WebMvcConfig.java

@@ -9,9 +9,6 @@ import org.springframework.web.servlet.config.annotation.*;
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
-    public static final String USER_UUID = "UUID";
-    public static final String USER_TIME = "TIME";
-
     /**
      * Controller Handler 인터셉서 등록
      * @param registry

+ 4 - 4
src/main/java/com/its/op/security/WebSecurityConfig.java

@@ -110,8 +110,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     //.logoutSuccessUrl("/api/auth/login.do").permitAll()
                     .invalidateHttpSession(true)
                     .deleteCookies("JSESSIONID")
-                    .deleteCookies(WebMvcConfig.USER_UUID)
-                    .deleteCookies(WebMvcConfig.USER_TIME)
+                    .deleteCookies(WebConstants.USER_UUID)
+                    .deleteCookies(WebConstants.USER_TIME)
                     .and()
                     .sessionManagement()
                     .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)   // 스프링 시큐리티가 필요 시 생성 (default)
@@ -182,8 +182,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     .logoutSuccessUrl(loginPage).permitAll()
                     .invalidateHttpSession(true)
                     .deleteCookies("JSESSIONID")
-                    .deleteCookies(WebMvcConfig.USER_UUID)
-                    .deleteCookies(WebMvcConfig.USER_TIME)
+                    .deleteCookies(WebConstants.USER_UUID)
+                    .deleteCookies(WebConstants.USER_TIME)
                     .and()
                     .sessionManagement()
                     .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)   // 스프링 시큐리티가 필요 시 생성 (default)

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

@@ -28,7 +28,7 @@ public class ApiInterceptor implements HandlerInterceptor {
             }
         }
 //        else {
-//            String encUserId = (String)session.getAttribute(WebMvcConfig.USER_UUID);
+//            String encUserId = (String)session.getAttribute(WebConstants.USER_UUID);
 //            String userId = "";
 //            if (!("").equals(encUserId)) {
 //                userId = WebMvcConfig.decUserId(encUserId);

+ 1 - 0
src/main/resources/application.yml

@@ -87,6 +87,7 @@ spring:
         synonyms: true
         default_batch_fetch_size: 1000
         format_sql: true
+        show-sql: false
         use_sql_columns: true
         hbm2ddl.auto: validate
         implicit_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

+ 26 - 0
src/test/java/com/its/op/ItsOpServerApplicationTests.java

@@ -1,5 +1,6 @@
 package com.its.op;
 
+import com.its.op.entity.its.atrd.TbAtrd;
 import com.its.utils.AES256Util;
 import com.its.utils.SHA256Util;
 import lombok.extern.slf4j.Slf4j;
@@ -8,14 +9,17 @@ import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
 import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
 import org.jasypt.salt.StringFixedSaltGenerator;
 import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ActiveProfiles;
 
+import javax.persistence.EntityManager;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Date;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 @Slf4j
@@ -25,6 +29,28 @@ public class ItsOpServerApplicationTests {
 //    @Autowired
 //    DefaultListableBeanFactory bf;
 
+    @Autowired
+    private EntityManager em;
+
+    @Test
+    void qry() {
+        List<TbAtrd> result = em.createQuery("select m from TbAtrd m", TbAtrd.class)
+                .getResultList();
+        log.error("{} EA.", result.size());
+        result.forEach(obj -> {
+            log.error("{}", obj.getAtrdId());
+        });
+
+        log.error("======================================================================================");
+        List<TbAtrd> result_ = em.createQuery("select m from TbAtrd m where m.atrdId = :id", TbAtrd.class)
+                .setParameter("id", "ATRD010")
+                .getResultList();
+        log.error("{} EA.", result_.size());
+        result_.forEach(obj -> {
+            log.error("{}", obj.getAtrdId());
+        });
+    }
+
     @Test
     void ttl() {
         ExpiringMap<String, String> tokenEventMap;