use of org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount in project keycloak by keycloak.
the class SpringSecurityCookieTokenStore method checkCurrentToken.
@Override
public void checkCurrentToken() {
final KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = checkPrincipalFromCookie();
if (principal != null) {
final RefreshableKeycloakSecurityContext securityContext = principal.getKeycloakSecurityContext();
KeycloakSecurityContext current = ((OIDCHttpFacade) facade).getSecurityContext();
if (current != null) {
securityContext.setAuthorizationContext(current.getAuthorizationContext());
}
final Set<String> roles = AdapterUtils.getRolesFromSecurityContext(securityContext);
final OidcKeycloakAccount account = new SimpleKeycloakAccount(principal, roles, securityContext);
SecurityContextHolder.getContext().setAuthentication(new KeycloakAuthenticationToken(account, false));
} else {
super.checkCurrentToken();
}
cookieChecked = true;
}
use of org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount in project keycloak by keycloak.
the class SpringSecurityTokenStoreTest method testSaveAccountInfo.
@Test
public void testSaveAccountInfo() throws Exception {
OidcKeycloakAccount account = new SimpleKeycloakAccount(principal, Collections.singleton("FOO"), keycloakSecurityContext);
Authentication authentication;
store.saveAccountInfo(account);
authentication = SecurityContextHolder.getContext().getAuthentication();
assertNotNull(authentication);
assertTrue(authentication instanceof KeycloakAuthenticationToken);
}
Aggregations