@Test public void retrieveAuthenticator_test() { byte[] credentialId = new byte[0]; WebAuthnAuthenticator expectedAuthenticator = mock(WebAuthnAuthenticator.class); when(authenticatorService.loadAuthenticatorByCredentialId(credentialId)).thenReturn(expectedAuthenticator); WebAuthnAuthenticator webAuthnAuthenticator = authenticationProvider.retrieveAuthenticator(credentialId); assertThat(webAuthnAuthenticator).isEqualTo(expectedAuthenticator); }
WebAuthnAuthenticator retrieveAuthenticator(byte[] credentialId) { WebAuthnAuthenticator webAuthnAuthenticator; try { webAuthnAuthenticator = authenticatorService.loadAuthenticatorByCredentialId(credentialId); } catch (CredentialIdNotFoundException notFound) { if (hideCredentialIdNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (Exception repositoryProblem) { throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (webAuthnAuthenticator == null) { throw new InternalAuthenticationServiceException( "WebAuthnAuthenticatorService returned null, which is an interface contract violation"); } return webAuthnAuthenticator; }
WebAuthnAuthenticationProvider implements AuthenticationProvider { WebAuthnAuthenticator retrieveAuthenticator(byte[] credentialId) { WebAuthnAuthenticator webAuthnAuthenticator; try { webAuthnAuthenticator = authenticatorService.loadAuthenticatorByCredentialId(credentialId); } catch (CredentialIdNotFoundException notFound) { if (hideCredentialIdNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (Exception repositoryProblem) { throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (webAuthnAuthenticator == null) { throw new InternalAuthenticationServiceException( "WebAuthnAuthenticatorService returned null, which is an interface contract violation"); } return webAuthnAuthenticator; } }
WebAuthnAuthenticationProvider implements AuthenticationProvider { WebAuthnAuthenticator retrieveAuthenticator(byte[] credentialId) { WebAuthnAuthenticator webAuthnAuthenticator; try { webAuthnAuthenticator = authenticatorService.loadAuthenticatorByCredentialId(credentialId); } catch (CredentialIdNotFoundException notFound) { if (hideCredentialIdNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (Exception repositoryProblem) { throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (webAuthnAuthenticator == null) { throw new InternalAuthenticationServiceException( "WebAuthnAuthenticatorService returned null, which is an interface contract violation"); } return webAuthnAuthenticator; } WebAuthnAuthenticationProvider(
            WebAuthnAuthenticatorService authenticatorService,
            WebAuthnManager webAuthnManager); }
WebAuthnAuthenticationProvider implements AuthenticationProvider { WebAuthnAuthenticator retrieveAuthenticator(byte[] credentialId) { WebAuthnAuthenticator webAuthnAuthenticator; try { webAuthnAuthenticator = authenticatorService.loadAuthenticatorByCredentialId(credentialId); } catch (CredentialIdNotFoundException notFound) { if (hideCredentialIdNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (Exception repositoryProblem) { throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (webAuthnAuthenticator == null) { throw new InternalAuthenticationServiceException( "WebAuthnAuthenticatorService returned null, which is an interface contract violation"); } return webAuthnAuthenticator; } WebAuthnAuthenticationProvider(
            WebAuthnAuthenticatorService authenticatorService,
            WebAuthnManager webAuthnManager); @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication); boolean isHideCredentialIdNotFoundExceptions(); void setHideCredentialIdNotFoundExceptions(boolean hideCredentialIdNotFoundExceptions); }
WebAuthnAuthenticationProvider implements AuthenticationProvider { WebAuthnAuthenticator retrieveAuthenticator(byte[] credentialId) { WebAuthnAuthenticator webAuthnAuthenticator; try { webAuthnAuthenticator = authenticatorService.loadAuthenticatorByCredentialId(credentialId); } catch (CredentialIdNotFoundException notFound) { if (hideCredentialIdNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (Exception repositoryProblem) { throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (webAuthnAuthenticator == null) { throw new InternalAuthenticationServiceException( "WebAuthnAuthenticatorService returned null, which is an interface contract violation"); } return webAuthnAuthenticator; } WebAuthnAuthenticationProvider(
            WebAuthnAuthenticatorService authenticatorService,
            WebAuthnManager webAuthnManager); @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication); boolean isHideCredentialIdNotFoundExceptions(); void setHideCredentialIdNotFoundExceptions(boolean hideCredentialIdNotFoundExceptions);  }