instanceof 관련 수정

master
mjkhan21 7 months ago
parent 6f039d2ee1
commit cfaf49154f

@ -38,7 +38,7 @@ public class SecuredUserInfo extends UserInfo implements UserDetails {
private UserInfo get(Authentication authentication) { private UserInfo get(Authentication authentication) {
Object obj = authentication != null ? authentication.getPrincipal() : null; Object obj = authentication != null ? authentication.getPrincipal() : null;
return obj instanceof SecuredUserInfo ? (UserInfo)obj : SecuredUserInfo.unknown; return obj instanceof SecuredUserInfo userInfo ? userInfo : SecuredUserInfo.unknown;
} }
@Override @Override

@ -67,8 +67,7 @@ public class AuthenticationSuccess extends SavedRequestAwareAuthenticationSucces
*/ */
protected DataObject onSuccess(HttpServletRequest hreq, HttpServletResponse hresp, Authentication authentication) { protected DataObject onSuccess(HttpServletRequest hreq, HttpServletResponse hresp, Authentication authentication) {
Object principal = authentication.getPrincipal(); Object principal = authentication.getPrincipal();
if (principal instanceof UserInfo) { if (principal instanceof UserInfo user) {
UserInfo user = (UserInfo)principal;
user.setInfo("loggedInAt", new Date()); user.setInfo("loggedInAt", new Date());
remember(user, hreq, hresp); remember(user, hreq, hresp);
} }

@ -85,9 +85,8 @@ public class LogoutSuccess extends SimpleUrlLogoutSuccessHandler implements Appl
@Override @Override
public void setApplicationContext(ApplicationContext actx) throws BeansException { 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); wactx.getServletContext().addListener(this);
} }

Loading…
Cancel
Save