TokenInfoResourceServerTokenServices implements ResourceServerTokenServices { @Override public OAuth2Authentication loadAuthentication(final String accessToken) throws AuthenticationException, InvalidTokenException { if (!StringUtils.hasText(accessToken)) { throw new InvalidTokenException("'accessToken' should never be null or empty"); } final Map<String, Object> map = getMap(accessToken); if (map == null) { logger.warn("'null' is not the expected response by TokenInfoEndpoint"); return authWithoutScopes; } if (map.containsKey("error")) { String description = (String) map.get("error_description"); if (!StringUtils.hasText(description)) { description = (String) map.get("error"); } logger.warn("tokeninfo returned error: " + description); return authWithoutScopes; } return this.authenticationExtractor.extractAuthentication(map, clientId, userRolesProvider); } TokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl);  TokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl, final String clientId);  TokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl, final String clientId,
            final UserRolesProvider userRolesProvider);  TokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl,
            final AuthenticationExtractor authenticationExtractor);  TokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl, final String clientId,
            final AuthenticationExtractor authenticationExtractor, final UserRolesProvider userRolesProvider,
            final RestTemplate restTemplate);  TokenInfoResourceServerTokenServices(final TokenInfoRequestExecutor tokenInfoRequestExecutor);  TokenInfoResourceServerTokenServices(final String clientId,
            final AuthenticationExtractor authenticationExtractor, final UserRolesProvider userRolesProvider,
            final TokenInfoRequestExecutor tokenInfoRequestExecutor); @Override OAuth2Authentication loadAuthentication(final String accessToken); AuthenticationExtractor getAuthenticationExtractor(); @Override OAuth2AccessToken readAccessToken(final String accessToken);  }
@Test(expected = InvalidTokenException.class) public void emptyTokenIsInvalid() { final TokenInfoResourceServerTokenServices unit = new TokenInfoResourceServerTokenServices(TOKENINFO_URL); unit.loadAuthentication(""); }