DirectAccessGrantUserDetailsAuthenticationProvider extends DirectAccessGrantAuthenticationProvider { protected String resolveUsername(KeycloakAuthenticationToken token) { Assert.notNull(token, "KeycloakAuthenticationToken required"); Assert.notNull(token.getAccount(), "KeycloakAuthenticationToken.getAccount() cannot be return null"); OidcKeycloakAccount account = token.getAccount(); Principal principal = account.getPrincipal(); return principal.getName(); }  @Override Authentication authenticate(Authentication authentication); @Required void setUserDetailsService(UserDetailsService userDetailsService);  }
@Ignore @Test public void testResolveUsername() throws Exception { KeycloakAuthenticationToken authentication = (KeycloakAuthenticationToken) provider.authenticate(token); assertEquals(AppConfig.KNOWN_EMAIL, provider.resolveUsername(authentication)); }