class ServiceAuthenticationServiceImpl implements ServiceAuthenticationService {

    @Override
    @CacheEvict(value = CACHE_BY_AUTHENTICATION, condition = "#result != null && #result.isExpired()")
    @Cacheable(CACHE_BY_AUTHENTICATION)
    public AuthenticationCommand getAuthenticationCommand(Authentication authentication, String jwtToken) {
        final AbstractAuthenticationScheme scheme = authenticationSchemeFactory.getSchema(authentication.getScheme());
        if (jwtToken == null) return scheme.createCommand(authentication, () -> null);
        return scheme.createCommand(authentication, () -> authenticationService.parseJwtToken(jwtToken));
    }

}