@Override protected void completeOAuthAuthentication( final KeycloakPrincipal<RefreshableKeycloakSecurityContext> skp) { principal = skp; final RefreshableKeycloakSecurityContext securityContext = skp.getKeycloakSecurityContext(); final Set<String> roles = AdapterUtils.getRolesFromSecurityContext(securityContext); OidcKeycloakAccount account = new OidcKeycloakAccount() { @Override public Principal getPrincipal() { return skp; } @Override public Set<String> getRoles() { return roles; } @Override public KeycloakSecurityContext getKeycloakSecurityContext() { return securityContext; } }; request.setAttribute(KeycloakSecurityContext.class.getName(), securityContext); this.tokenStore.saveAccountInfo(account); }
@Override protected void completeBearerAuthentication( KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal, String method) { this.principal = principal; RefreshableKeycloakSecurityContext securityContext = principal.getKeycloakSecurityContext(); Set<String> roles = AdapterUtils.getRolesFromSecurityContext(securityContext); if (log.isDebugEnabled()) { log.debug("Completing bearer authentication. Bearer roles: " + roles); } request.setAttribute(KeycloakSecurityContext.class.getName(), securityContext); }