From 7e1c3dd72ab93c1617510e46bd8cc01672351c16 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Fri, 6 Oct 2023 10:42:46 +0900 Subject: [PATCH] =?UTF-8?q?UserDetailLoader=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ++++++ .../cokr/xit/base/security/UserDetailLoader.java | 5 +++++ .../service/bean/AuthenticationServiceBean.java | 14 ++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/main/java/cokr/xit/base/security/UserDetailLoader.java diff --git a/pom.xml b/pom.xml index 5f9242c..9bf00b9 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,12 @@ 23.04.01-SNAPSHOT + + org.egovframe.rte + org.egovframe.rte.fdl.crypto + ${org.egovframe.rte.version} + + diff --git a/src/main/java/cokr/xit/base/security/UserDetailLoader.java b/src/main/java/cokr/xit/base/security/UserDetailLoader.java new file mode 100644 index 0000000..7066e66 --- /dev/null +++ b/src/main/java/cokr/xit/base/security/UserDetailLoader.java @@ -0,0 +1,5 @@ +package cokr.xit.base.security; + +public interface UserDetailLoader { + void setInfo(SecuredUserInfo userInfo); +} 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 4eb862a..7938224 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 @@ -6,6 +6,7 @@ import java.util.Map; import javax.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationServiceException; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -17,6 +18,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import cokr.xit.base.security.AccessContext; import cokr.xit.base.security.Authority; import cokr.xit.base.security.SecuredUserInfo; +import cokr.xit.base.security.UserDetailLoader; import cokr.xit.base.security.access.dao.AuthorityMapper; import cokr.xit.base.security.authentication.AuthenticationPolicy; import cokr.xit.base.security.authentication.service.AuthenticationService; @@ -45,6 +47,8 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme /** 접근 권한 DAO */ @Resource(name="authorityMapper") private AuthorityMapper authorityMapper; + @Autowired(required = false) + private UserDetailLoader userDetailLoader; /**새 AuthenticationServiceBean를 생성한다. */ @@ -69,7 +73,7 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme SecuredUserInfo userInfo = new SecuredUserInfo(); userInfo.setUser(user); setAuthorities(userInfo); - loadDetails(userInfo); + setDetails(userInfo); return userInfo; } @@ -121,8 +125,7 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme SecuredUserInfo userInfo = new SecuredUserInfo(); userInfo.setUser(user); setAuthorities(userInfo); - loadDetails(userInfo); - + setDetails(userInfo); return userInfo; } @@ -141,7 +144,10 @@ public class AuthenticationServiceBean extends DaoAuthenticationProvider impleme /**사용자 정보에 추가 정보를 설정한다. * @param user 사용자 정보 */ - protected void loadDetails(UserInfo user) {} + protected void setDetails(SecuredUserInfo userInfo) { + if (userDetailLoader != null) + userDetailLoader.setInfo(userInfo); + } /**지정한 아이디의 권한을 가져온다. * @param authIDs 권한 아이디