@Override
    protected AuthenticationHandlerExecutionResult doAuthentication(
        final Credential credential, final Service service) throws PreventedException {
        try {
            val tokenCredential = (BasicIdentifiableCredential) credential;
            val registeredService = getServicesManager().findServiceBy(service);
            val profile = TokenAuthenticationSecurity.forRegisteredService(registeredService).validateToken(tokenCredential.getId());
            Assert.notNull(profile, "Authentication attempt failed to produce an authenticated profile");
            val attributes = CollectionUtils.toMultiValuedMap(profile.getAttributes());
            val principal = principalFactory.createPrincipal(profile.getId(), attributes);
            tokenCredential.setId(principal.getId());
            return createHandlerResult(tokenCredential, principal, new ArrayList<>());
        } catch (final Throwable e) {
            throw new AuthenticationException(e);
        }
    }
This is {@link TokenAuthenticationHandler} that authenticates instances of {@link TokenCredential}.
There is no need for a separate {@link PrincipalResolver} component
as this handler will auto-populate the principal attributes itself.

@author Misagh Moayyed
@since 4.2.0
support/cas-server-support-token-authentication/src/main/java/org/apereo/cas/token/authentication/TokenAuthenticationHandler.java