@Override public boolean isCached(RequestAuthenticator authenticator) { if (request.getSession(false) == null || request.getSession().getAttribute(KeycloakSecurityContext.class.getName()) == null) return false; log.debug("remote logged in already. Establish state from session"); RefreshableKeycloakSecurityContext securityContext = (RefreshableKeycloakSecurityContext) request.getSession().getAttribute(KeycloakSecurityContext.class.getName()); if (!deployment.getRealm().equals(securityContext.getRealm())) { log.debug("Account from cookie is from a different realm than for the request."); return false; } securityContext.setCurrentRequestInfo(deployment, this); request.setAttribute(KeycloakSecurityContext.class.getName(), securityContext); JettyRequestAuthenticator jettyAuthenticator = (JettyRequestAuthenticator) authenticator; KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = AdapterUtils.createPrincipal(deployment, securityContext); jettyAuthenticator.principal = principal; restoreRequest(); return true; }
@Override public boolean isCached(RequestAuthenticator authenticator) { if (request.getSession(false) == null || request.getSession().getAttribute(KeycloakSecurityContext.class.getName()) == null) return false; log.debug("remote logged in already. Establish state from session"); RefreshableKeycloakSecurityContext securityContext = (RefreshableKeycloakSecurityContext) request.getSession().getAttribute(KeycloakSecurityContext.class.getName()); if (!deployment.getRealm().equals(securityContext.getRealm())) { log.debug("Account from cookie is from a different realm than for the request."); return false; } securityContext.setCurrentRequestInfo(deployment, this); request.setAttribute(KeycloakSecurityContext.class.getName(), securityContext); JettyRequestAuthenticator jettyAuthenticator = (JettyRequestAuthenticator) authenticator; KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = AdapterUtils.createPrincipal(deployment, securityContext); jettyAuthenticator.principal = principal; restoreRequest(); return true; }