PreAuthenticatedAuthenticationProvider extends TimeMeasuringAuthenticationProvider<AuthenticationResult> { @Override protected AuthenticationResult toFailedAuthenticationResult(final Throwable throwable, final DittoHeaders dittoHeaders) { return DefaultAuthenticationResult.failed(dittoHeaders, toDittoRuntimeException(throwable, dittoHeaders)); } private  PreAuthenticatedAuthenticationProvider(); static PreAuthenticatedAuthenticationProvider getInstance(); @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(); assertThat(reasonOfFailure).isEqualTo(dre); }
@Test public void toFailedAuthenticationResult() { final DittoRuntimeException dre = DittoRuntimeException.newBuilder("none", HttpStatusCode.INTERNAL_SERVER_ERROR).build(); final Throwable reasonOfFailure = underTest.toFailedAuthenticationResult(dre, knownDittoHeaders).getReasonOfFailure(); assertThat(reasonOfFailure).isEqualTo(dre); }