From cfaf49154f20e9b79c4acda44babcda0380b0ff1 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Fri, 3 May 2024 09:31:31 +0900 Subject: [PATCH] =?UTF-8?q?instanceof=20=EA=B4=80=EB=A0=A8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cokr/xit/base/security/SecuredUserInfo.java | 2 +- .../security/authentication/web/AuthenticationSuccess.java | 3 +-- .../xit/base/security/authentication/web/LogoutSuccess.java | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/cokr/xit/base/security/SecuredUserInfo.java b/src/main/java/cokr/xit/base/security/SecuredUserInfo.java index 8696e2a..18b9491 100644 --- a/src/main/java/cokr/xit/base/security/SecuredUserInfo.java +++ b/src/main/java/cokr/xit/base/security/SecuredUserInfo.java @@ -38,7 +38,7 @@ public class SecuredUserInfo extends UserInfo implements UserDetails { private UserInfo get(Authentication authentication) { Object obj = authentication != null ? authentication.getPrincipal() : null; - return obj instanceof SecuredUserInfo ? (UserInfo)obj : SecuredUserInfo.unknown; + return obj instanceof SecuredUserInfo userInfo ? userInfo : SecuredUserInfo.unknown; } @Override 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 8e9d069..64b8bb8 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 @@ -67,8 +67,7 @@ public class AuthenticationSuccess extends SavedRequestAwareAuthenticationSucces */ protected DataObject onSuccess(HttpServletRequest hreq, HttpServletResponse hresp, Authentication authentication) { Object principal = authentication.getPrincipal(); - if (principal instanceof UserInfo) { - UserInfo user = (UserInfo)principal; + if (principal instanceof UserInfo user) { user.setInfo("loggedInAt", new Date()); remember(user, hreq, hresp); } 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 c66c0a7..a17b105 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 @@ -85,9 +85,8 @@ public class LogoutSuccess extends SimpleUrlLogoutSuccessHandler implements Appl @Override public void setApplicationContext(ApplicationContext actx) throws BeansException { - if (!(actx instanceof WebApplicationContext)) return; + if (!(actx instanceof WebApplicationContext wactx)) return; - WebApplicationContext wactx = (WebApplicationContext)actx; wactx.getServletContext().addListener(this); }