### Question:
SpringSecurityTokenStore implements AdapterTokenStore { @Override public boolean isCached(RequestAuthenticator authenticator) { logger.debug("Checking if {} is cached", authenticator); SecurityContext context = SecurityContextHolder.getContext(); KeycloakAuthenticationToken token; KeycloakSecurityContext keycloakSecurityContext; if (context == null || context.getAuthentication() == null) { return false; } if (!KeycloakAuthenticationToken.class.isAssignableFrom(context.getAuthentication().getClass())) { logger.warn("Expected a KeycloakAuthenticationToken, but found {}", context.getAuthentication()); return false; } logger.debug("Remote logged in already. Establishing state from security context."); token = (KeycloakAuthenticationToken) context.getAuthentication(); keycloakSecurityContext = token.getAccount().getKeycloakSecurityContext(); if (!deployment.getRealm().equals(keycloakSecurityContext.getRealm())) { logger.debug("Account from security context is from a different realm than for the request."); logout(); return false; } if (keycloakSecurityContext.getToken().isExpired()) { logger.warn("Security token expired ... not returning from cache"); return false; } request.setAttribute(KeycloakSecurityContext.class.getName(), keycloakSecurityContext); return true; } SpringSecurityTokenStore(KeycloakDeployment deployment, HttpServletRequest request); @Override void checkCurrentToken(); @Override boolean isCached(RequestAuthenticator authenticator); @Override void saveAccountInfo(OidcKeycloakAccount account); @Override void logout(); @Override void refreshCallback(RefreshableKeycloakSecurityContext securityContext); @Override void saveRequest(); @Override boolean restoreRequest();  }### Answer:
@Test public void testIsCached() throws Exception { Authentication authentication = new PreAuthenticatedAuthenticationToken("foo", "bar", Collections.singleton(new KeycloakRole("ROLE_FOO"))); SecurityContextHolder.getContext().setAuthentication(authentication); assertFalse(store.isCached(requestAuthenticator)); }