BoschIoTSuiteOAuthProviderAuthCode extends AbstractOAuthProvider { @Override public Authentication authenticate(HttpServletRequest request, String jwtToken) { return JwtToken.instance(jwtToken) .filter(token -> verify(request, token)) .map(this::createAuthentication) .orElse(null); } @Autowired  BoschIoTSuiteOAuthProviderAuthCode(
      @Value("${suite.oauth2.client.clientId}") String clientId,
      @Value("${oauth2.verification.hydra.publicKeyUri: #{null}}") String hydraPublicKeyUri,
      @Autowired BoschIoTSuiteOAuthProviderConfiguration suiteOAuthProviderConfiguration,
      @Autowired DefaultUserAccountService userAccountService,
      @Autowired UserNamespaceRoleService userNamespaceRoleService
  );  BoschIoTSuiteOAuthProviderAuthCode(
      String clientId,
      Supplier<Map<String, PublicKey>> publicKeySupplier,
      BoschIoTSuiteOAuthProviderConfiguration suiteOAuthProviderConfiguration,
      DefaultUserAccountService userAccountService,
      UserNamespaceRoleService userNamespaceRoleService
  ); @Override String getId(); @Override boolean canHandle(Authentication auth); @Override boolean canHandle(String jwtToken); @Override Authentication authenticate(HttpServletRequest request, String jwtToken); @Override boolean verify(HttpServletRequest httpRequest, JwtToken jwtToken); @SuppressWarnings("rawtypes") @Override OAuthUser createUser(Authentication authentication); @Override boolean supportsWebflow(); @Override Optional<IOAuthFlowConfiguration> getWebflowConfiguration(); @Override String getLabel(); static final String FAMILY_NAME; static final String GIVEN_NAME; static final String EMAIL; }
@Test public void authenticateUserNotFoundTest() { when(userAccountService.getUser(any())).thenReturn(null); assertNull(sut.authenticate(null, TOKEN)); }
@Test public void authenticateInvalidTokenTest() { Authentication authentication = sut.authenticate(null, "invalid-token"); assertNull(authentication); }
@Test public void authenticateSuccessTest() { when(userAccountService.getUser(any())).thenReturn(new User()); Authentication authentication = sut.authenticate(null, TOKEN); assertTrue(authentication.isAuthenticated()); }