From 35caa909ee66a9656944054572415757472b4516 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Mon, 8 May 2023 05:36:03 +0900 Subject: [PATCH] authenticationDao -> policyMapper, authenticationBean --- .../authentication/dao/AuthenticationDao.java | 166 ------------------ .../authentication/dao/PolicyMapper.java | 120 +++++++++++++ .../service/AuthenticationService.java | 8 +- .../service/bean/AuthenticationBean.java | 62 +++---- .../bean/AuthenticationServiceBean.java | 44 +++-- .../web/AuthenticationFailure.java | 2 + .../web/AuthenticationSuccess.java | 2 + .../authentication/web/LogoutSuccess.java | 2 + .../authentication/web/PolicyController.java | 7 +- .../resources/spring/context-security.xml | 8 +- .../{authentication.xml => policy-mapper.xml} | 12 +- 11 files changed, 180 insertions(+), 253 deletions(-) delete mode 100644 src/main/java/cokr/xit/base/security/authentication/dao/AuthenticationDao.java create mode 100644 src/main/java/cokr/xit/base/security/authentication/dao/PolicyMapper.java rename src/test/resources/sql/mapper/base/{authentication.xml => policy-mapper.xml} (87%) diff --git a/src/main/java/cokr/xit/base/security/authentication/dao/AuthenticationDao.java b/src/main/java/cokr/xit/base/security/authentication/dao/AuthenticationDao.java deleted file mode 100644 index 1f429a3..0000000 --- a/src/main/java/cokr/xit/base/security/authentication/dao/AuthenticationDao.java +++ /dev/null @@ -1,166 +0,0 @@ -package cokr.xit.base.security.authentication.dao; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.security.core.Authentication; - -import cokr.xit.base.security.authentication.AuthenticationPolicy; -import cokr.xit.foundation.User; -import cokr.xit.foundation.component.AbstractDao; -import cokr.xit.foundation.data.DataObject; - -/**사용자 인증 정보 DAO - * @author mjkhan - */ -public class AuthenticationDao extends AbstractDao { - /**새 AuthenticationDao를 생성한다. - */ - public AuthenticationDao() { - setNamespace("authentication"); - } - - /**주어진 파라미터에 해당하는 사용자를 가져온다. - * @param params 조회 조건 파라미터 - * @return 사용자 - */ - public User getUser(Map params) { - HashMap copy = new HashMap<>(params); - if (isEmpty(copy.get("userIDs"))) - copy.put("userIDs", new Object[] {params.get("userID")}); - copy.put("password", true); - List users = selectList( - sqlID("user.getUsers"), - copy - ); - return !users.isEmpty() ? users.get(0) : null; - } - - /**주어진 아이디의 사용자를 가져온다. - * @param userID 사용자 아이디 - * @return 사용자 - */ - public User getUser(String userID) { - return getUser( - params().set("userIDs", new String[] {userID}) - ); - } - - /**인증 성공 시 실행되는 핸들러 메소드 - * @param authentication 인증 정보 - * @return 결과값 - */ - public int onSuccess(Authentication authentication) { - return 0; - } - - /**인증 실패 시 실행되는 핸들러 메소드 - * @param params 인증 시 사용한 파라미터 - * @return 결과값 - */ - public int onFailure(Map params) { - return 0; - } - - /**로그 아웃 시 실행되는 핸들러 메소드 - * @param authentication 인증 정보 - * @return 결과값 - */ - public int onLogout(Authentication authentication) { - return 0; - } - - /**주어진 조건의 사용자 인증 정책 목록을 반환한다. - * @param by 조건 필드 이름 - *
  • userName - 사용자 이름
  • - *
  • 그 이외는 사용자 아이디
  • - *
- * @param term 조건 필드값 - * @param pageNum 페이지 이름 - * @param fetchSize 한 번에 가져올 인증 정책 갯수 - * @return 사용자 인증 정책 목록 - */ - public List getPolicyList(String by, String term, int pageNum, int fetchSize) { - switch (ifEmpty(by, () -> "")) { - case "userName": by = "USER_NM"; break; - default: by = "USER_ID"; break; - } - - DataObject params = params() - .set("by", by) - .set("term", ifEmpty(term, () -> null)) - .set("pageNum", pageNum) - .set("fetchSize", fetchSize); - return selectList(sqlID("getPolicyList"), params); - } - - /**지정한 사용자들의 인증 정책 목록을 가져온다. - * @param userIDs 사용자 아이디 - * @return 인증 정책 목록 - */ - public List getPolicies(String... userIDs) { - DataObject params = params() - .set("userIDs", ifEmpty(userIDs, () -> null)) - .set("pageNum", 1) - .set("fetchSize", userIDs.length); - return selectList(sqlID("getPolicies"), params); - } - - /**지정한 사용자의 인증 정책을 가져온다. - * @param userID 사용자 아이디 - * @return 인증 정책 - */ - public AuthenticationPolicy getPolicy(String userID) { - List found = getPolicies(userID); - return !found.isEmpty() ? found.get(0) : null; - } - - /**인증 정책을 등록한다. - * @param policy 인증 정책 - * @return 등록 여부 - *
  • 등록 되었으면 true
  • - *
  • 그렇지 않으면 false
  • - *
- */ - public boolean create(AuthenticationPolicy policy) { - if (policy == null) - return false; - - AuthenticationPolicy found = getPolicy(policy.getUserID()); - if (found != null) - throw applicationException(null); - - DataObject params = params() - .set("policy", policy) - .set("currentUser", currentUser()); - return insert(sqlID("insertPolicy"), params) > 0; - } - - /**인증 정책을 수정한다. - * @param policy 인증 정책 - * @return 수정 여부 - *
  • 수정 되었으면 true
  • - *
  • 그렇지 않으면 false
  • - *
- */ - public boolean update(AuthenticationPolicy policy) { - if (policy == null) - return false; - - DataObject params = params() - .set("policy", policy) - .set("currentUser", currentUser()); - return insert(sqlID("updatePolicy"), params) > 0; - } - - /**지정한 사용자의 인증 정책을 제거한다. - * @param userIDs 사용자 아이디 - * @return 저장된 정보수 - */ - public int removePolicies(String... userIDs) { - if (isEmpty(userIDs)) return 0; - - return delete(sqlID("removePolicy"), params().set("userIDs", userIDs)); - } -} \ No newline at end of file diff --git a/src/main/java/cokr/xit/base/security/authentication/dao/PolicyMapper.java b/src/main/java/cokr/xit/base/security/authentication/dao/PolicyMapper.java new file mode 100644 index 0000000..949dcf2 --- /dev/null +++ b/src/main/java/cokr/xit/base/security/authentication/dao/PolicyMapper.java @@ -0,0 +1,120 @@ +package cokr.xit.base.security.authentication.dao; + +import java.util.List; +import java.util.Map; + +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +import cokr.xit.base.security.authentication.AuthenticationPolicy; +import cokr.xit.foundation.component.AbstractMapper; +import cokr.xit.foundation.component.QueryRequest; +import cokr.xit.foundation.data.DataObject; + +/**사용자 인증 정보 DAO + * @author mjkhan + */ +@Mapper("policyMapper") +public interface PolicyMapper extends AbstractMapper { + /**주어진 조건의 사용자 인증 정책 목록을 반환한다. + * @param by 조건 필드 이름 + *
  • userName - 사용자 이름
  • + *
  • 그 이외는 사용자 아이디
  • + *
+ * @param term 조건 필드값 + * @param pageNum 페이지 이름 + * @param fetchSize 한 번에 가져올 인증 정책 갯수 + * @return 사용자 인증 정책 목록 + */ + List getPolicyList(QueryRequest req); + + /**지정한 사용자들의 인증 정책 목록을 가져온다. + * @param userIDs 사용자 아이디 + * @return 인증 정책 목록 + */ + List getPolicies(Map params); + + /**지정한 사용자들의 인증 정책 목록을 가져온다. + * @param userIDs 사용자 아이디 + * @return 인증 정책 목록 + */ + default List getPolicies(String... userIDs) { + DataObject params = params() + .set("userIDs", ifEmpty(userIDs, () -> null)) + .set("pageNum", 1) + .set("fetchSize", userIDs.length); + return getPolicies(params); + } + + /**지정한 사용자의 인증 정책을 가져온다. + * @param userID 사용자 아이디 + * @return 인증 정책 + */ + default AuthenticationPolicy getPolicy(String userID) { + List found = getPolicies(userID); + return !found.isEmpty() ? found.get(0) : null; + } + + int insertPolicy(Map params); + + /**인증 정책을 등록한다. + * @param policy 인증 정책 + * @return 등록 여부 + *
  • 등록 되었으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + default boolean create(AuthenticationPolicy policy) { + if (policy == null) + return false; + + AuthenticationPolicy found = getPolicy(policy.getUserID()); + if (found != null) + throw applicationException(null); + + DataObject params = params() + .set("policy", policy) + .set("currentUser", currentUser()); + return insertPolicy(params) > 0; + } + + /**인증 정책을 수정한다. + * @param policy 인증 정책 + * @return 수정 여부 + *
  • 수정 되었으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + int updatePolicy(Map params); + + /**인증 정책을 수정한다. + * @param policy 인증 정책 + * @return 수정 여부 + *
  • 수정 되었으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + default boolean update(AuthenticationPolicy policy) { + return policy != null + && updatePolicy( + params() + .set("policy", policy) + .set("currentUser", currentUser()) + ) > 0; + } + + /**지정한 사용자의 인증 정책을 제거한다. + * @param userIDs 사용자 아이디 + * @return 저장된 정보수 + */ + int removePolicy(Map params); + + /**지정한 사용자의 인증 정책을 제거한다. + * @param userIDs 사용자 아이디 + * @return 저장된 정보수 + */ + default int removePolicies(String... userIDs) { + return !isEmpty(userIDs) ? + removePolicy(params().set("userIDs", userIDs)) : + 0; + } +} \ No newline at end of file diff --git a/src/main/java/cokr/xit/base/security/authentication/service/AuthenticationService.java b/src/main/java/cokr/xit/base/security/authentication/service/AuthenticationService.java index b434b25..655ac99 100644 --- a/src/main/java/cokr/xit/base/security/authentication/service/AuthenticationService.java +++ b/src/main/java/cokr/xit/base/security/authentication/service/AuthenticationService.java @@ -7,6 +7,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.userdetails.UserDetailsService; import cokr.xit.base.security.authentication.AuthenticationPolicy; +import cokr.xit.foundation.component.QueryRequest; import cokr.xit.foundation.data.DataObject; /**사용자 인증 서비스를 제공한다. @@ -44,7 +45,7 @@ public interface AuthenticationService extends UserDetailsService { * @param fetchSize 한 번에 가져올 인증 정책 갯수 * @return 사용자 인증 정책 목록 */ - List getPolicyList(String by, String term, int pageNum, int fetchSize); + List getPolicyList(QueryRequest req); /**지정한 사용자들의 인증 정책 목록을 가져온다. * @param userIDs 사용자 아이디 @@ -56,10 +57,7 @@ public interface AuthenticationService extends UserDetailsService { * @param userID 사용자 아이디 * @return 인증 정책 */ - default AuthenticationPolicy getPolicy(String userID) { - List list = getPolicies(userID); - return !list.isEmpty() ? list.get(0) : null; - } + AuthenticationPolicy getPolicy(String userID); /**인증 정책을 등록한다. * @param policy 인증 정책 diff --git a/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationBean.java b/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationBean.java index fc5a515..ae66fc5 100644 --- a/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationBean.java +++ b/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationBean.java @@ -6,20 +6,26 @@ import java.util.Map; import javax.annotation.Resource; import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Component; import cokr.xit.base.security.authentication.AuthenticationPolicy; +import cokr.xit.base.security.authentication.dao.PolicyMapper; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.user.service.UserQuery; +import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.User; -import cokr.xit.foundation.component.AbstractDao; +import cokr.xit.foundation.component.QueryRequest; import cokr.xit.foundation.data.DataObject; /**사용자 인증 정보 DAO * @author mjkhan */ -public class AuthenticationBean extends AbstractDao { +@Component("authenticationBean") +public class AuthenticationBean extends AbstractComponent { @Resource(name = "userMapper") private UserMapper userMapper; + @Resource(name = "policyMapper") + private PolicyMapper policyMapper; /**주어진 파라미터에 해당하는 사용자를 가져온다. * @param params 조회 조건 파라미터 @@ -40,7 +46,7 @@ public class AuthenticationBean extends AbstractDao { */ public User getUser(String userID) { return getUser( - params().set("userIDs", new String[] {userID}) + new DataObject().set("userIDs", new String[] {userID}) ); } @@ -78,18 +84,13 @@ public class AuthenticationBean extends AbstractDao { * @param fetchSize 한 번에 가져올 인증 정책 갯수 * @return 사용자 인증 정책 목록 */ - public List getPolicyList(String by, String term, int pageNum, int fetchSize) { - switch (ifEmpty(by, () -> "")) { - case "userName": by = "USER_NM"; break; - default: by = "USER_ID"; break; + public List getPolicyList(QueryRequest req) { + switch (ifEmpty(req.getBy(), () -> "")) { + case "userName": req.setBy("USER_NM"); break; + default: req.setBy("USER_ID"); break; } - - DataObject params = params() - .set("by", by) - .set("term", ifEmpty(term, () -> null)) - .set("pageNum", pageNum) - .set("fetchSize", fetchSize); - return selectList(sqlID("getPolicyList"), params); + req.setOrderBy(req.getBy()); + return policyMapper.getPolicyList(req); } /**지정한 사용자들의 인증 정책 목록을 가져온다. @@ -97,11 +98,7 @@ public class AuthenticationBean extends AbstractDao { * @return 인증 정책 목록 */ public List getPolicies(String... userIDs) { - DataObject params = params() - .set("userIDs", ifEmpty(userIDs, () -> null)) - .set("pageNum", 1) - .set("fetchSize", userIDs.length); - return selectList(sqlID("getPolicies"), params); + return policyMapper.getPolicies(userIDs); } /**지정한 사용자의 인증 정책을 가져온다. @@ -109,8 +106,7 @@ public class AuthenticationBean extends AbstractDao { * @return 인증 정책 */ public AuthenticationPolicy getPolicy(String userID) { - List found = getPolicies(userID); - return !found.isEmpty() ? found.get(0) : null; + return policyMapper.getPolicy(userID); } /**인증 정책을 등록한다. @@ -121,17 +117,7 @@ public class AuthenticationBean extends AbstractDao { * */ public boolean create(AuthenticationPolicy policy) { - if (policy == null) - return false; - - AuthenticationPolicy found = getPolicy(policy.getUserID()); - if (found != null) - throw applicationException(null); - - DataObject params = params() - .set("policy", policy) - .set("currentUser", currentUser()); - return insert(sqlID("insertPolicy"), params) > 0; + return policyMapper.create(policy); } /**인증 정책을 수정한다. @@ -142,13 +128,7 @@ public class AuthenticationBean extends AbstractDao { * */ public boolean update(AuthenticationPolicy policy) { - if (policy == null) - return false; - - DataObject params = params() - .set("policy", policy) - .set("currentUser", currentUser()); - return insert(sqlID("updatePolicy"), params) > 0; + return policyMapper.update(policy); } /**지정한 사용자의 인증 정책을 제거한다. @@ -156,8 +136,6 @@ public class AuthenticationBean extends AbstractDao { * @return 저장된 정보수 */ public int removePolicies(String... userIDs) { - if (isEmpty(userIDs)) return 0; - - return delete(sqlID("removePolicy"), params().set("userIDs", userIDs)); + return policyMapper.removePolicies(userIDs); } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationServiceBean.java b/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationServiceBean.java index 5c453fa..6713156 100644 --- a/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationServiceBean.java +++ b/src/main/java/cokr/xit/base/security/authentication/service/bean/AuthenticationServiceBean.java @@ -19,7 +19,6 @@ import cokr.xit.base.security.Authority; import cokr.xit.base.security.SecuredUserInfo; import cokr.xit.base.security.access.dao.AuthorityMapper; import cokr.xit.base.security.authentication.AuthenticationPolicy; -import cokr.xit.base.security.authentication.dao.AuthenticationDao; import cokr.xit.base.security.authentication.service.AuthenticationService; import cokr.xit.base.security.authentication.web.AuthenticationExtraDetails; import cokr.xit.foundation.Access; @@ -27,6 +26,7 @@ import cokr.xit.foundation.ApplicationContainer; import cokr.xit.foundation.Log; import cokr.xit.foundation.User; import cokr.xit.foundation.UserInfo; +import cokr.xit.foundation.component.QueryRequest; import cokr.xit.foundation.data.DataObject; /**사용자 인증 서비스 인터페이스 구현체 @@ -36,9 +36,9 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme /** 애플리케이션 컨테이너 */ @Resource(name="applicationContainer") protected ApplicationContainer applicationContainer; - /** 사용자 인증 DAO */ - @Resource(name="authenticationDao") - private AuthenticationDao authenticationDao; + /** 사용자 인증 Bean */ + @Resource(name="authenticationBean") + private AuthenticationBean authenticationBean; /** 접근 권한 정보 */ @Resource(name="accessContext") protected AccessContext accessContext; @@ -60,16 +60,9 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme return Log.get(getClass()); } - /**사용자 인증 DAO를 반환한다. - * @return 사용자 인증 DAO - */ - protected AuthenticationDao authenticationDao() { - return authenticationDao; - } - @Override public SecuredUserInfo loadUserByUsername(String username) throws UsernameNotFoundException { - User user = authenticationDao.getUser(username); + User user = authenticationBean.getUser(username); if (user == null) new BadCredentialsException("Bad credentials"); @@ -110,7 +103,7 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme * @param user 사용자 정보 */ protected void checkAgainstPolicy(AuthenticationExtraDetails extraDetails, UserInfo user) { - AuthenticationPolicy policy = authenticationDao.getPolicy(user.getId()); + AuthenticationPolicy policy = authenticationBean.getPolicy(user.getId()); if (policy == null || !policy.limits()) return; String clientAddress = Access.getClientAddress(extraDetails.getRemoteAddress(), applicationContainer.getHostAddress()); @@ -123,7 +116,7 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme * @return 사용자 정보 */ private SecuredUserInfo loadUser(Map params) { - User user = authenticationDao.getUser(params); + User user = authenticationBean.getUser(params); if (user == null) throw new BadCredentialsException("Bad credentials"); @@ -182,19 +175,19 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme @Override public void onSuccess(Authentication authentication) { log().debug("{} authenticated.", authentication.getPrincipal()); - authenticationDao.onSuccess(authentication); + authenticationBean.onSuccess(authentication); } @Override public void onFailure(Map params) { log().debug("Authentication failed: {}", params); - authenticationDao.onFailure(params); + authenticationBean.onFailure(params); } @Override public void onLogout(Authentication authentication) { log().debug("{} logged out.", authentication.getPrincipal()); - authenticationDao.onLogout(authentication); + authenticationBean.onLogout(authentication); } @Override @@ -203,27 +196,32 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme } @Override - public List getPolicyList(String by, String term, int pageNum, int fetchSize) { - return authenticationDao.getPolicyList(by, term, pageNum, fetchSize); + public List getPolicyList(QueryRequest req) { + return authenticationBean.getPolicyList(req); } @Override public List getPolicies(String... userIDs) { - return authenticationDao.getPolicies(userIDs); + return authenticationBean.getPolicies(userIDs); + } + + @Override + public AuthenticationPolicy getPolicy(String userID) { + return authenticationBean.getPolicy(userID); } @Override public boolean create(AuthenticationPolicy policy) { - return authenticationDao.create(policy); + return authenticationBean.create(policy); } @Override public boolean update(AuthenticationPolicy policy) { - return authenticationDao.update(policy); + return authenticationBean.update(policy); } @Override public int removePolicies(String... userIDs) { - return authenticationDao.removePolicies(userIDs); + return authenticationBean.removePolicies(userIDs); } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationFailure.java b/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationFailure.java index e86924f..98aaeff 100644 --- a/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationFailure.java +++ b/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationFailure.java @@ -16,6 +16,7 @@ import org.springframework.security.authentication.CredentialsExpiredException; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; +import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -27,6 +28,7 @@ import cokr.xit.foundation.data.StringMap; /**사용자 인증(로그인) 실패 핸들러 * @author mjkhan */ +@Component("authenticationFailure") public class AuthenticationFailure extends SimpleUrlAuthenticationFailureHandler { @Resource(name="objectMapper") private ObjectMapper objectMapper; diff --git a/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationSuccess.java b/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationSuccess.java index e1bfc98..de546d0 100644 --- a/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationSuccess.java +++ b/src/main/java/cokr/xit/base/security/authentication/web/AuthenticationSuccess.java @@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -22,6 +23,7 @@ import cokr.xit.foundation.data.DataObject; /**사용자 인증(로그인) 성공 핸들러 * @author mjkhan */ +@Component("authenticationSuccess") public class AuthenticationSuccess extends SavedRequestAwareAuthenticationSuccessHandler { @Resource(name="authenticationService") private AuthenticationService authenticationService; diff --git a/src/main/java/cokr/xit/base/security/authentication/web/LogoutSuccess.java b/src/main/java/cokr/xit/base/security/authentication/web/LogoutSuccess.java index 2867271..ff9475a 100644 --- a/src/main/java/cokr/xit/base/security/authentication/web/LogoutSuccess.java +++ b/src/main/java/cokr/xit/base/security/authentication/web/LogoutSuccess.java @@ -18,6 +18,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; import org.springframework.security.web.context.HttpSessionSecurityContextRepository; +import org.springframework.stereotype.Component; import org.springframework.web.context.WebApplicationContext; import cokr.xit.base.security.authentication.service.AuthenticationService; @@ -27,6 +28,7 @@ import cokr.xit.foundation.Log; /**로그아웃 성공 핸들러 * @author mjkhan */ +@Component("logoutSuccess") public class LogoutSuccess extends SimpleUrlLogoutSuccessHandler implements ApplicationContextAware, HttpSessionListener { private String successUrl; diff --git a/src/main/java/cokr/xit/base/security/authentication/web/PolicyController.java b/src/main/java/cokr/xit/base/security/authentication/web/PolicyController.java index d9595cf..aa089ca 100644 --- a/src/main/java/cokr/xit/base/security/authentication/web/PolicyController.java +++ b/src/main/java/cokr/xit/base/security/authentication/web/PolicyController.java @@ -4,11 +4,11 @@ import javax.annotation.Resource; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.security.authentication.AuthenticationPolicy; import cokr.xit.base.security.authentication.service.AuthenticationService; +import cokr.xit.foundation.component.QueryRequest; import cokr.xit.foundation.web.AbstractController; /**인증 정책 컨트롤러
@@ -44,11 +44,10 @@ public class PolicyController extends AbstractCo * } */ @RequestMapping(name="인증 정책 조회", value="/list.do") - public ModelAndView getPolicies(String by, String term, @RequestParam(required=false, defaultValue="1") Integer pageNum) { - int fetchSize = properties.getInt("pageSize"); + public ModelAndView getPolicies(QueryRequest req) { return setCollectionInfo( new ModelAndView("jsonView"), - authenticationService.getPolicyList(by, term, pageNum, fetchSize), + authenticationService.getPolicyList(setFetchSize(req)), "policy" ); } diff --git a/src/test/resources/spring/context-security.xml b/src/test/resources/spring/context-security.xml index 55541c0..92fd5a2 100644 --- a/src/test/resources/spring/context-security.xml +++ b/src/test/resources/spring/context-security.xml @@ -8,7 +8,7 @@ - + @@ -49,12 +49,7 @@ - - - - - @@ -67,6 +62,5 @@ - \ No newline at end of file diff --git a/src/test/resources/sql/mapper/base/authentication.xml b/src/test/resources/sql/mapper/base/policy-mapper.xml similarity index 87% rename from src/test/resources/sql/mapper/base/authentication.xml rename to src/test/resources/sql/mapper/base/policy-mapper.xml index e474fbd..ce59238 100644 --- a/src/test/resources/sql/mapper/base/authentication.xml +++ b/src/test/resources/sql/mapper/base/policy-mapper.xml @@ -1,6 +1,6 @@ - + @@ -13,7 +13,7 @@ -/* 로그인 정책 목록 조회(policyMapper.getPolicyList) */ SELECT A.USER_ID , USER_NM @@ -26,13 +26,13 @@ SELECT A.USER_ID WHERE A.${by} LIKE CONCAT('%', #{term}, '%') -/* 로그인 정책 가져오기(policyMapper.getPolicies) */ SELECT * FROM TBL_LOGIN_POLICY WHERE USER_ID IN (#{userID}) ORDER BY USER_ID -/* 로그인 정책 등록(authentication.insertPolicy) */ +/* 로그인 정책 등록(policyMapper.insertPolicy) */ INSERT INTO TBL_LOGIN_POLICY ( USER_ID , IP_ADRS @@ -53,7 +53,7 @@ INSERT INTO TBL_LOGIN_POLICY ( , CURRENT_TIMESTAMP() ) -/* 로그인 정책 수정(authentication.updatePolicy) */ +/* 로그인 정책 수정(policyMapper.updatePolicy) */ UPDATE TBL_LOGIN_POLICY SET IP_ADRS = #{policy.ipAddress} , DPLCT_YN = #{policy.duplicateYN} @@ -62,7 +62,7 @@ UPDATE TBL_LOGIN_POLICY SET , UPD_DT = CURRENT_TIMESTAMP() WHERE USER_ID = #{policy.userID} -/* 로그인 정책 삭제(authentication.removePolicy) */ +/* 로그인 정책 삭제(policyMapper.removePolicy) */ DELETE FROM TBL_LOGIN_POLICY WHERE USER_ID IN (#{userID})