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); }