JwtAuthenticationProvider extends TimeMeasuringAuthenticationProvider<AuthenticationResult> { @Override protected AuthenticationResult toFailedAuthenticationResult(final Throwable throwable, final DittoHeaders dittoHeaders) { LOGGER.withCorrelationId(dittoHeaders).debug("JWT Authentication failed.", throwable); return DefaultAuthenticationResult.failed(dittoHeaders, toDittoRuntimeException(throwable, dittoHeaders)); } private  JwtAuthenticationProvider(final JwtAuthenticationResultProvider jwtAuthenticationResultProvider,
            final JwtValidator jwtValidator); static JwtAuthenticationProvider newInstance(
            final JwtAuthenticationResultProvider jwtAuthenticationResultProvider, final JwtValidator jwtValidator); @Override boolean isApplicable(final RequestContext requestContext); @Override AuthorizationContextType getType(final RequestContext requestContext);  }
@Test public void toFailedAuthenticationResultExtractsDittoRuntimeExceptionFromCause() { final DittoRuntimeException dre = DittoRuntimeException.newBuilder("none", HttpStatusCode.INTERNAL_SERVER_ERROR).build(); final IllegalStateException illegalStateException = new IllegalStateException("notExpected", dre); final Throwable reasonOfFailure = underTest.toFailedAuthenticationResult(illegalStateException, knownDittoHeaders).getReasonOfFailure(); softly.assertThat(reasonOfFailure).isEqualTo(dre); }
@Test public void toFailedAuthenticationResult() { final DittoRuntimeException dre = DittoRuntimeException.newBuilder("none", HttpStatusCode.INTERNAL_SERVER_ERROR).build(); final AuthenticationResult authenticationResult = underTest.toFailedAuthenticationResult(dre, knownDittoHeaders); softly.assertThat(authenticationResult.getReasonOfFailure()).isEqualTo(dre); }