WebAuthnAssertionAuthenticationToken extends AbstractAuthenticationToken { @Override public void setAuthenticated(boolean isAuthenticated) { if (isAuthenticated) { throw new IllegalArgumentException( "Cannot set this authenticator to trusted"); } super.setAuthenticated(false); } WebAuthnAssertionAuthenticationToken(
            WebAuthnAuthenticationRequest credentials,
            WebAuthnAuthenticationParameters parameters,
            Collection<? extends GrantedAuthority> authorities
    ); @Override Object getPrincipal(); @Override WebAuthnAuthenticationRequest getCredentials(); WebAuthnAuthenticationParameters getParameters(); @Override void setAuthenticated(boolean isAuthenticated); @Override void eraseCredentials(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test(expected = IllegalArgumentException.class) public void setAuthenticated_with_true_test() { WebAuthnAuthenticationRequest request = mock(WebAuthnAuthenticationRequest.class); WebAuthnAuthenticationParameters parameters = mock(WebAuthnAuthenticationParameters.class); WebAuthnAssertionAuthenticationToken token = new WebAuthnAssertionAuthenticationToken(request, parameters, null); token.setAuthenticated(true); assertThat(token.isAuthenticated()).isTrue(); }
@Test public void setAuthenticated_with_false_test() { WebAuthnAuthenticationRequest request = mock(WebAuthnAuthenticationRequest.class); WebAuthnAuthenticationParameters parameters = mock(WebAuthnAuthenticationParameters.class); WebAuthnAssertionAuthenticationToken token = new WebAuthnAssertionAuthenticationToken(request, parameters, null); token.setAuthenticated(false); assertThat(token.isAuthenticated()).isFalse(); }