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) {
Object obj = authentication != null ? authentication.getPrincipal() : null;
return obj instanceof SecuredUserInfo ? (UserInfo)obj : SecuredUserInfo.unknown;
return obj instanceof SecuredUserInfo userInfo ? userInfo : SecuredUserInfo.unknown;
}
@Override

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

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

Loading…
Cancel
Save