class AuthenticationService {

    @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null")
    public TokenAuthentication validateJwtToken(String jwtToken) {
        QueryResponse queryResponse = parseJwtToken(jwtToken);

        switch (queryResponse.getSource()) {
            case ZOWE:
                validateAndParseLocalJwtToken(jwtToken);
                break;
            case ZOSMF:
                zosmfService.validate(JWT, jwtToken);
                break;
            default:
                throw new TokenNotValidException("Unknown token type.");
        }

        TokenAuthentication tokenAuthentication = new TokenAuthentication(queryResponse.getUserId(), jwtToken);
        // without a proxy cache aspect is not working, thus it is necessary get bean from application context
        final boolean authenticated = !meAsProxy.isInvalidated(jwtToken);
        tokenAuthentication.setAuthenticated(authenticated);

        return tokenAuthentication;
    }

}