@Test public void loadAuthentication_tokenIsNull_throwsException() { assertThatThrownBy(() -> cut.loadAuthentication(null)).isInstanceOf(InvalidTokenException.class); }
@Override public OAuth2Authentication loadAuthentication(@Nonnull String accessToken) throws AuthenticationException, InvalidTokenException { Token token = checkAndCreateToken(accessToken); ValidationResult validationResult = tokenValidator.validate(token); if (validationResult.isErroneous()) { throw new InvalidTokenException(validationResult.getErrorDescription()); } SecurityContext.setToken(token); String tokenClientId = token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID); if (LOGGER.isInfoEnabled() && tokenClientId != serviceConfiguration.getClientId()) { LOGGER.info("Creates OAuth2Authentication with token clientId {} which differs from oauth client id {}.", tokenClientId, serviceConfiguration.getClientId()); } return createOAuth2Authentication(tokenClientId, getScopes(token), token); }
SAPOfflineTokenServicesCloud implements ResourceServerTokenServices, InitializingBean { @Override public OAuth2Authentication loadAuthentication(@Nonnull String accessToken) throws AuthenticationException, InvalidTokenException { Token token = checkAndCreateToken(accessToken); ValidationResult validationResult = tokenValidator.validate(token); if (validationResult.isErroneous()) { throw new InvalidTokenException(validationResult.getErrorDescription()); } SecurityContext.setToken(token); String tokenClientId = token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID); if (LOGGER.isInfoEnabled() && tokenClientId != serviceConfiguration.getClientId()) { LOGGER.info("Creates OAuth2Authentication with token clientId {} which differs from oauth client id {}.", tokenClientId, serviceConfiguration.getClientId()); } return createOAuth2Authentication(tokenClientId, getScopes(token), token); } }
SAPOfflineTokenServicesCloud implements ResourceServerTokenServices, InitializingBean { @Override public OAuth2Authentication loadAuthentication(@Nonnull String accessToken) throws AuthenticationException, InvalidTokenException { Token token = checkAndCreateToken(accessToken); ValidationResult validationResult = tokenValidator.validate(token); if (validationResult.isErroneous()) { throw new InvalidTokenException(validationResult.getErrorDescription()); } SecurityContext.setToken(token); String tokenClientId = token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID); if (LOGGER.isInfoEnabled() && tokenClientId != serviceConfiguration.getClientId()) { LOGGER.info("Creates OAuth2Authentication with token clientId {} which differs from oauth client id {}.", tokenClientId, serviceConfiguration.getClientId()); } return createOAuth2Authentication(tokenClientId, getScopes(token), token); } SAPOfflineTokenServicesCloud();  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration);  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			RestOperations restOperations);   SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			JwtValidatorBuilder jwtValidatorBuilder); }
SAPOfflineTokenServicesCloud implements ResourceServerTokenServices, InitializingBean { @Override public OAuth2Authentication loadAuthentication(@Nonnull String accessToken) throws AuthenticationException, InvalidTokenException { Token token = checkAndCreateToken(accessToken); ValidationResult validationResult = tokenValidator.validate(token); if (validationResult.isErroneous()) { throw new InvalidTokenException(validationResult.getErrorDescription()); } SecurityContext.setToken(token); String tokenClientId = token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID); if (LOGGER.isInfoEnabled() && tokenClientId != serviceConfiguration.getClientId()) { LOGGER.info("Creates OAuth2Authentication with token clientId {} which differs from oauth client id {}.", tokenClientId, serviceConfiguration.getClientId()); } return createOAuth2Authentication(tokenClientId, getScopes(token), token); } SAPOfflineTokenServicesCloud();  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration);  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			RestOperations restOperations);   SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			JwtValidatorBuilder jwtValidatorBuilder); SAPOfflineTokenServicesCloud withAnotherServiceConfiguration(
			OAuth2ServiceConfiguration otherServiceConfiguration); @Override OAuth2Authentication loadAuthentication(@Nonnull String accessToken); @Override void afterPropertiesSet(); @Override OAuth2AccessToken readAccessToken(String accessToken); SAPOfflineTokenServicesCloud setLocalScopeAsAuthorities(boolean extractLocalScopesOnly); }
SAPOfflineTokenServicesCloud implements ResourceServerTokenServices, InitializingBean { @Override public OAuth2Authentication loadAuthentication(@Nonnull String accessToken) throws AuthenticationException, InvalidTokenException { Token token = checkAndCreateToken(accessToken); ValidationResult validationResult = tokenValidator.validate(token); if (validationResult.isErroneous()) { throw new InvalidTokenException(validationResult.getErrorDescription()); } SecurityContext.setToken(token); String tokenClientId = token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID); if (LOGGER.isInfoEnabled() && tokenClientId != serviceConfiguration.getClientId()) { LOGGER.info("Creates OAuth2Authentication with token clientId {} which differs from oauth client id {}.", tokenClientId, serviceConfiguration.getClientId()); } return createOAuth2Authentication(tokenClientId, getScopes(token), token); } SAPOfflineTokenServicesCloud();  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration);  SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			RestOperations restOperations);   SAPOfflineTokenServicesCloud(OAuth2ServiceConfiguration serviceConfiguration,
			JwtValidatorBuilder jwtValidatorBuilder); SAPOfflineTokenServicesCloud withAnotherServiceConfiguration(
			OAuth2ServiceConfiguration otherServiceConfiguration); @Override OAuth2Authentication loadAuthentication(@Nonnull String accessToken); @Override void afterPropertiesSet(); @Override OAuth2AccessToken readAccessToken(String accessToken); SAPOfflineTokenServicesCloud setLocalScopeAsAuthorities(boolean extractLocalScopesOnly);  }