@Test(expected = IllegalArgumentException.class) public void authenticate_with_invalid_authenticationToken() { Authentication token = new UsernamePasswordAuthenticationToken("username", "password"); authenticationProvider.authenticate(token); }
@Override public Authentication authenticate(Authentication authentication) { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only WebAuthnAssertionAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } WebAuthnAssertionAuthenticationToken authenticationToken = (WebAuthnAssertionAuthenticationToken) authentication; WebAuthnAuthenticationRequest credentials = authenticationToken.getCredentials(); if (credentials == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } byte[] credentialId = credentials.getCredentialId(); WebAuthnAuthenticator webAuthnAuthenticator = retrieveAuthenticator(credentialId); doAuthenticate(authenticationToken, webAuthnAuthenticator); authenticatorService.updateCounter(credentialId, webAuthnAuthenticator.getCounter()); return createSuccessAuthentication(authenticationToken, webAuthnAuthenticator); }
WebAuthnAuthenticationProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only WebAuthnAssertionAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } WebAuthnAssertionAuthenticationToken authenticationToken = (WebAuthnAssertionAuthenticationToken) authentication; WebAuthnAuthenticationRequest credentials = authenticationToken.getCredentials(); if (credentials == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } byte[] credentialId = credentials.getCredentialId(); WebAuthnAuthenticator webAuthnAuthenticator = retrieveAuthenticator(credentialId); doAuthenticate(authenticationToken, webAuthnAuthenticator); authenticatorService.updateCounter(credentialId, webAuthnAuthenticator.getCounter()); return createSuccessAuthentication(authenticationToken, webAuthnAuthenticator); } }
WebAuthnAuthenticationProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only WebAuthnAssertionAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } WebAuthnAssertionAuthenticationToken authenticationToken = (WebAuthnAssertionAuthenticationToken) authentication; WebAuthnAuthenticationRequest credentials = authenticationToken.getCredentials(); if (credentials == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } byte[] credentialId = credentials.getCredentialId(); WebAuthnAuthenticator webAuthnAuthenticator = retrieveAuthenticator(credentialId); doAuthenticate(authenticationToken, webAuthnAuthenticator); authenticatorService.updateCounter(credentialId, webAuthnAuthenticator.getCounter()); return createSuccessAuthentication(authenticationToken, webAuthnAuthenticator); } WebAuthnAuthenticationProvider(
            WebAuthnAuthenticatorService authenticatorService,
            WebAuthnManager webAuthnManager); }
WebAuthnAuthenticationProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only WebAuthnAssertionAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } WebAuthnAssertionAuthenticationToken authenticationToken = (WebAuthnAssertionAuthenticationToken) authentication; WebAuthnAuthenticationRequest credentials = authenticationToken.getCredentials(); if (credentials == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } byte[] credentialId = credentials.getCredentialId(); WebAuthnAuthenticator webAuthnAuthenticator = retrieveAuthenticator(credentialId); doAuthenticate(authenticationToken, webAuthnAuthenticator); authenticatorService.updateCounter(credentialId, webAuthnAuthenticator.getCounter()); return createSuccessAuthentication(authenticationToken, 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 { @Override public Authentication authenticate(Authentication authentication) { if (!supports(authentication.getClass())) { throw new IllegalArgumentException("Only WebAuthnAssertionAuthenticationToken is supported, " + authentication.getClass() + " was attempted"); } WebAuthnAssertionAuthenticationToken authenticationToken = (WebAuthnAssertionAuthenticationToken) authentication; WebAuthnAuthenticationRequest credentials = authenticationToken.getCredentials(); if (credentials == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "WebAuthnAuthenticationProvider.badCredentials", "Bad credentials")); } byte[] credentialId = credentials.getCredentialId(); WebAuthnAuthenticator webAuthnAuthenticator = retrieveAuthenticator(credentialId); doAuthenticate(authenticationToken, webAuthnAuthenticator); authenticatorService.updateCounter(credentialId, webAuthnAuthenticator.getCounter()); return createSuccessAuthentication(authenticationToken, webAuthnAuthenticator); } WebAuthnAuthenticationProvider(
            WebAuthnAuthenticatorService authenticatorService,
            WebAuthnManager webAuthnManager); @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication); boolean isHideCredentialIdNotFoundExceptions(); void setHideCredentialIdNotFoundExceptions(boolean hideCredentialIdNotFoundExceptions);  }