test_class.declarator: VALID_AUTHORIZATION_HEADER =
              HttpHeader.parse("authorization", "Bearer " + VALID_JWT_TOKEN)
test_class.modifier: private static final
test_class.original_string: private static final HttpHeader VALID_AUTHORIZATION_HEADER =
              HttpHeader.parse("authorization", "Bearer " + VALID_JWT_TOKEN);
test_class.type: HttpHeader
test_class.var_name: VALID_AUTHORIZATION_HEADER
test_class.declarator: INVALID_AUTHORIZATION_HEADER =
              HttpHeader.parse("authorization", "Basic " + VALID_JWT_TOKEN)
test_class.modifier: private static final
test_class.original_string: private static final HttpHeader INVALID_AUTHORIZATION_HEADER =
              HttpHeader.parse("authorization", "Basic " + VALID_JWT_TOKEN);
test_class.type: HttpHeader
test_class.var_name: INVALID_AUTHORIZATION_HEADER
test_class.declarator: testName = new TestName()
test_class.modifier: @Rule public final
test_class.original_string: @Rule public final TestName testName = new TestName();
test_class.type: TestName
test_class.var_name: testName
test_class.declarator: softly = new JUnitSoftAssertions()
test_class.modifier: @Rule public final
test_class.original_string: @Rule public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
test_class.type: JUnitSoftAssertions
test_class.var_name: softly
test_class.declarator: authenticationContextProvider
test_class.modifier: @Mock private
test_class.original_string: @Mock private JwtAuthenticationResultProvider authenticationContextProvider;
test_class.type: JwtAuthenticationResultProvider
test_class.var_name: authenticationContextProvider
test_class.declarator: jwtValidator
test_class.modifier: @Mock private
test_class.original_string: @Mock private JwtValidator jwtValidator;
test_class.type: JwtValidator
test_class.var_name: jwtValidator
test_class.declarator: knownDittoHeaders
test_class.modifier: private
test_class.original_string: private DittoHeaders knownDittoHeaders;
test_class.type: DittoHeaders
test_class.var_name: knownDittoHeaders
test_class.declarator: underTest
test_class.modifier: private
test_class.original_string: private JwtAuthenticationProvider underTest;
test_class.type: JwtAuthenticationProvider
test_class.var_name: underTest
test_class.file: services/gateway/security/src/test/java/org/eclipse/ditto/services/gateway/security/authentication/jwt/JwtAuthenticationProviderTest.java
test_class.identifier: JwtAuthenticationProviderTest
test_case.body: @Test
      public void doExtractAuthenticationWhenAuthorizationContextProviderErrors() {
          when(jwtValidator.validate(any(JsonWebToken.class)))
                  .thenReturn(CompletableFuture.completedFuture(BinaryValidationResult.valid()));
          when(authenticationContextProvider.getAuthenticationResult(any(JsonWebToken.class), any(DittoHeaders.class)))
                  .thenThrow(new RuntimeException("Something happened"));
          final RequestContext requestContext = mockRequestContext(VALID_AUTHORIZATION_HEADER);
  
          final AuthenticationResult authenticationResult = underTest.authenticate(requestContext, knownDittoHeaders);
  
          verify(authenticationContextProvider).getAuthenticationResult(any(JsonWebToken.class), any(DittoHeaders.class));
          softly.assertThat(authenticationResult.isSuccess()).isFalse();
          softly.assertThat(authenticationResult.getReasonOfFailure())
                  .isExactlyInstanceOf(GatewayAuthenticationFailedException.class);
  
          final GatewayAuthenticationFailedException reasonOfFailure =
                  (GatewayAuthenticationFailedException) authenticationResult.getReasonOfFailure();
  
          softly.assertThat(reasonOfFailure).hasMessage("The JWT could not be verified.");
          softly.assertThat(reasonOfFailure.getDescription()).contains("Something happened");
          softly.assertThat(reasonOfFailure.getDittoHeaders().getCorrelationId())
                  .isEqualTo(knownDittoHeaders.getCorrelationId());
      }
test_case.class_method_signature: JwtAuthenticationProviderTest.doExtractAuthenticationWhenAuthorizationContextProviderErrors()
test_case.full_signature: @Test public void doExtractAuthenticationWhenAuthorizationContextProviderErrors()
test_case.identifier: doExtractAuthenticationWhenAuthorizationContextProviderErrors
test_case.invocations: thenReturn when validate any completedFuture valid thenThrow when getAuthenticationResult any any mockRequestContext authenticate getAuthenticationResult verify any any isFalse assertThat isSuccess isExactlyInstanceOf assertThat getReasonOfFailure getReasonOfFailure hasMessage assertThat contains assertThat getDescription isEqualTo assertThat getCorrelationId getDittoHeaders getCorrelationId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void doExtractAuthenticationWhenAuthorizationContextProviderErrors()
focal_class.declarator: AUTHORIZATION_JWT = "Bearer"
focal_class.modifier: private static final
focal_class.original_string: private static final String AUTHORIZATION_JWT = "Bearer";
focal_class.type: String
focal_class.var_name: AUTHORIZATION_JWT
focal_class.declarator: LOGGER = DittoLoggerFactory.getLogger(JwtAuthenticationProvider.class)
focal_class.modifier: private static final
focal_class.original_string: private static final DittoLogger LOGGER = DittoLoggerFactory.getLogger(JwtAuthenticationProvider.class);
focal_class.type: DittoLogger
focal_class.var_name: LOGGER
focal_class.declarator: jwtAuthResultProvider
focal_class.modifier: private final
focal_class.original_string: private final JwtAuthenticationResultProvider jwtAuthResultProvider;
focal_class.type: JwtAuthenticationResultProvider
focal_class.var_name: jwtAuthResultProvider
focal_class.declarator: jwtValidator
focal_class.modifier: private final
focal_class.original_string: private final JwtValidator jwtValidator;
focal_class.type: JwtValidator
focal_class.var_name: jwtValidator
focal_class.file: services/gateway/security/src/main/java/org/eclipse/ditto/services/gateway/security/authentication/jwt/JwtAuthenticationProvider.java
focal_class.identifier: JwtAuthenticationProvider
focal_class.class_method_signature: JwtAuthenticationProvider.JwtAuthenticationProvider(final JwtAuthenticationResultProvider jwtAuthenticationResultProvider,
              final JwtValidator jwtValidator)
focal_class.full_signature: private  JwtAuthenticationProvider(final JwtAuthenticationResultProvider jwtAuthenticationResultProvider,
              final JwtValidator jwtValidator)
focal_class.identifier: JwtAuthenticationProvider
focal_class.modifiers: private
focal_class.parameters: (final JwtAuthenticationResultProvider jwtAuthenticationResultProvider,
              final JwtValidator jwtValidator)
focal_class.signature:  JwtAuthenticationProvider(final JwtAuthenticationResultProvider jwtAuthenticationResultProvider,
              final JwtValidator jwtValidator)
focal_class.class_method_signature: JwtAuthenticationProvider.newInstance(
              final JwtAuthenticationResultProvider jwtAuthenticationResultProvider, final JwtValidator jwtValidator)
focal_class.full_signature: public static JwtAuthenticationProvider newInstance(
              final JwtAuthenticationResultProvider jwtAuthenticationResultProvider, final JwtValidator jwtValidator)
focal_class.identifier: newInstance
focal_class.modifiers: public static
focal_class.parameters: (
              final JwtAuthenticationResultProvider jwtAuthenticationResultProvider, final JwtValidator jwtValidator)
focal_class.return: JwtAuthenticationProvider
focal_class.signature: JwtAuthenticationProvider newInstance(
              final JwtAuthenticationResultProvider jwtAuthenticationResultProvider, final JwtValidator jwtValidator)
focal_class.class_method_signature: JwtAuthenticationProvider.isApplicable(final RequestContext requestContext)
focal_class.full_signature: @Override public boolean isApplicable(final RequestContext requestContext)
focal_class.identifier: isApplicable
focal_class.modifiers: @Override public
focal_class.parameters: (final RequestContext requestContext)
focal_class.return: boolean
focal_class.signature: boolean isApplicable(final RequestContext requestContext)
focal_class.class_method_signature: JwtAuthenticationProvider.tryToAuthenticate(final RequestContext requestContext,
              final DittoHeaders dittoHeaders)
focal_class.full_signature: @Override protected AuthenticationResult tryToAuthenticate(final RequestContext requestContext,
              final DittoHeaders dittoHeaders)
focal_class.identifier: tryToAuthenticate
focal_class.modifiers: @Override protected
focal_class.parameters: (final RequestContext requestContext,
              final DittoHeaders dittoHeaders)
focal_class.return: AuthenticationResult
focal_class.signature: AuthenticationResult tryToAuthenticate(final RequestContext requestContext,
              final DittoHeaders dittoHeaders)
focal_class.class_method_signature: JwtAuthenticationProvider.extractJwtFromRequest(final RequestContext requestContext)
focal_class.full_signature: private static Optional<JsonWebToken> extractJwtFromRequest(final RequestContext requestContext)
focal_class.identifier: extractJwtFromRequest
focal_class.modifiers: private static
focal_class.parameters: (final RequestContext requestContext)
focal_class.return: Optional<JsonWebToken>
focal_class.signature: Optional<JsonWebToken> extractJwtFromRequest(final RequestContext requestContext)
focal_class.class_method_signature: JwtAuthenticationProvider.buildMissingJwtException(final DittoHeaders dittoHeaders)
focal_class.full_signature: private static DittoRuntimeException buildMissingJwtException(final DittoHeaders dittoHeaders)
focal_class.identifier: buildMissingJwtException
focal_class.modifiers: private static
focal_class.parameters: (final DittoHeaders dittoHeaders)
focal_class.return: DittoRuntimeException
focal_class.signature: DittoRuntimeException buildMissingJwtException(final DittoHeaders dittoHeaders)
focal_class.class_method_signature: JwtAuthenticationProvider.getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_class.full_signature: @SuppressWarnings("ConstantConditions") private CompletableFuture<AuthenticationResult> getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_class.identifier: getAuthenticationResult
focal_class.modifiers: @SuppressWarnings("ConstantConditions") private
focal_class.parameters: (final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_class.return: CompletableFuture<AuthenticationResult>
focal_class.signature: CompletableFuture<AuthenticationResult> getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_class.class_method_signature: JwtAuthenticationProvider.buildJwtUnauthorizedException(final DittoHeaders dittoHeaders,
              final Throwable cause)
focal_class.full_signature: private static DittoRuntimeException buildJwtUnauthorizedException(final DittoHeaders dittoHeaders,
              final Throwable cause)
focal_class.identifier: buildJwtUnauthorizedException
focal_class.modifiers: private static
focal_class.parameters: (final DittoHeaders dittoHeaders,
              final Throwable cause)
focal_class.return: DittoRuntimeException
focal_class.signature: DittoRuntimeException buildJwtUnauthorizedException(final DittoHeaders dittoHeaders,
              final Throwable cause)
focal_class.class_method_signature: JwtAuthenticationProvider.tryToGetAuthenticationResult(final JsonWebToken jwt, final DittoHeaders dittoHeaders)
focal_class.full_signature: private AuthenticationResult tryToGetAuthenticationResult(final JsonWebToken jwt, final DittoHeaders dittoHeaders)
focal_class.identifier: tryToGetAuthenticationResult
focal_class.modifiers: private
focal_class.parameters: (final JsonWebToken jwt, final DittoHeaders dittoHeaders)
focal_class.return: AuthenticationResult
focal_class.signature: AuthenticationResult tryToGetAuthenticationResult(final JsonWebToken jwt, final DittoHeaders dittoHeaders)
focal_class.class_method_signature: JwtAuthenticationProvider.toFailedAuthenticationResult(final Throwable throwable,
              final DittoHeaders dittoHeaders)
focal_class.full_signature: @Override protected AuthenticationResult toFailedAuthenticationResult(final Throwable throwable,
              final DittoHeaders dittoHeaders)
focal_class.identifier: toFailedAuthenticationResult
focal_class.modifiers: @Override protected
focal_class.parameters: (final Throwable throwable,
              final DittoHeaders dittoHeaders)
focal_class.return: AuthenticationResult
focal_class.signature: AuthenticationResult toFailedAuthenticationResult(final Throwable throwable,
              final DittoHeaders dittoHeaders)
focal_class.class_method_signature: JwtAuthenticationProvider.getType(final RequestContext requestContext)
focal_class.full_signature: @Override public AuthorizationContextType getType(final RequestContext requestContext)
focal_class.identifier: getType
focal_class.modifiers: @Override public
focal_class.parameters: (final RequestContext requestContext)
focal_class.return: AuthorizationContextType
focal_class.signature: AuthorizationContextType getType(final RequestContext requestContext)
focal_class.superclass: extends TimeMeasuringAuthenticationProvider<AuthenticationResult>
focal_method.body: @SuppressWarnings("ConstantConditions")
      private CompletableFuture<AuthenticationResult> getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders) {
  
          return jwtValidator.validate(jwt)
                  .thenApply(validationResult -> {
                      if (!validationResult.isValid()) {
                          final Throwable reasonForInvalidity = validationResult.getReasonForInvalidity();
                          LOGGER.withCorrelationId(dittoHeaders).debug("The JWT is invalid.", reasonForInvalidity);
                          throw buildJwtUnauthorizedException(dittoHeaders, reasonForInvalidity);
                      }
  
                      final AuthenticationResult authenticationResult = tryToGetAuthenticationResult(jwt, dittoHeaders);
                      LOGGER.withCorrelationId(dittoHeaders).info("Completed JWT authentication successfully.");
                      return authenticationResult;
                  });
      }
focal_method.class_method_signature: JwtAuthenticationProvider.getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_method.full_signature: @SuppressWarnings("ConstantConditions") private CompletableFuture<AuthenticationResult> getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_method.identifier: getAuthenticationResult
focal_method.invocations: thenApply validate isValid getReasonForInvalidity debug withCorrelationId buildJwtUnauthorizedException tryToGetAuthenticationResult info withCorrelationId
focal_method.modifiers: @SuppressWarnings("ConstantConditions") private
focal_method.parameters: (final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)
focal_method.return: CompletableFuture<AuthenticationResult>
focal_method.signature: CompletableFuture<AuthenticationResult> getAuthenticationResult(final JsonWebToken jwt,
              final DittoHeaders dittoHeaders)