Search in sources :

Example 6 with UvmEntries

use of com.webauthn4j.data.extension.UvmEntries in project webauthn4j by webauthn4j.

the class AuthenticationExtensionsClientOutputsTest method equals_hashCode_test.

@Test
void equals_hashCode_test() {
    UvmEntries uvm = new UvmEntries(Collections.singletonList(new UvmEntry(UserVerificationMethod.FINGERPRINT_INTERNAL, KeyProtectionType.SOFTWARE, MatcherProtectionType.ON_CHIP)));
    AuthenticationExtensionsClientOutputs.BuilderForAuthentication builder1 = new AuthenticationExtensionsClientOutputs.BuilderForAuthentication();
    builder1.setAppid(true);
    builder1.setUvm(uvm);
    builder1.setHMACGetSecret(new HMACGetSecretOutput(new byte[32], new byte[32]));
    AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> instance1 = builder1.build();
    AuthenticationExtensionsClientOutputs.BuilderForAuthentication builder2 = new AuthenticationExtensionsClientOutputs.BuilderForAuthentication();
    builder2.setAppid(true);
    builder2.setUvm(uvm);
    builder2.setHMACGetSecret(new HMACGetSecretOutput(new byte[32], new byte[32]));
    AuthenticationExtensionsClientOutputs<AuthenticationExtensionClientOutput> instance2 = builder2.build();
    assertThat(instance1).isEqualTo(instance2).hasSameHashCodeAs(instance2);
}
Also used : UvmEntry(com.webauthn4j.data.extension.UvmEntry) HMACGetSecretOutput(com.webauthn4j.data.extension.HMACGetSecretOutput) UvmEntries(com.webauthn4j.data.extension.UvmEntries) Test(org.junit.jupiter.api.Test)

Example 7 with UvmEntries

use of com.webauthn4j.data.extension.UvmEntries in project webauthn4j by webauthn4j.

the class AuthenticationExtensionsAuthenticatorOutputsTest method equals_hashCode_test.

@Test
void equals_hashCode_test() {
    UvmEntries uvm = new UvmEntries(Collections.singletonList(new UvmEntry(UserVerificationMethod.FINGERPRINT_INTERNAL, KeyProtectionType.SOFTWARE, MatcherProtectionType.ON_CHIP)));
    AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication builder1 = new AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication();
    builder1.setUvm(uvm);
    AuthenticationExtensionsAuthenticatorOutputs<AuthenticationExtensionAuthenticatorOutput> instance1 = builder1.build();
    AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication builder2 = new AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication();
    builder2.setUvm(uvm);
    AuthenticationExtensionsAuthenticatorOutputs<AuthenticationExtensionAuthenticatorOutput> instance2 = builder2.build();
    assertThat(instance1).isEqualTo(instance2).hasSameHashCodeAs(instance2);
}
Also used : UvmEntry(com.webauthn4j.data.extension.UvmEntry) UvmEntries(com.webauthn4j.data.extension.UvmEntries) Test(org.junit.jupiter.api.Test)

Example 8 with UvmEntries

use of com.webauthn4j.data.extension.UvmEntries in project webauthn4j by webauthn4j.

the class AuthenticationExtensionsAuthenticatorOutputsTest method authentication_variant_test.

@SuppressWarnings("java:S5961")
@Test
void authentication_variant_test() {
    UvmEntries uvm = new UvmEntries(Collections.singletonList(new UvmEntry(UserVerificationMethod.FINGERPRINT_INTERNAL, KeyProtectionType.SOFTWARE, MatcherProtectionType.ON_CHIP)));
    AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication builder = new AuthenticationExtensionsAuthenticatorOutputs.BuilderForAuthentication();
    builder.setUvm(uvm);
    builder.setHMACGetSecret(new byte[32]);
    builder.set("unknown", 1);
    AuthenticationExtensionsAuthenticatorOutputs<AuthenticationExtensionAuthenticatorOutput> target = builder.build();
    assertThat(target.getKeys()).containsExactlyInAnyOrder("uvm", "hmac-secret", "unknown");
    assertThat(target.getUvm()).isEqualTo(uvm);
    assertThat((byte[]) target.getHMACSecret()).isEqualTo(new byte[32]);
    assertThat(target.getHMACCreateSecret()).isNull();
    assertThat(target.getHMACGetSecret()).isEqualTo(new byte[32]);
    assertThat(target.getUnknownKeys()).containsExactly("unknown");
    assertThat(target.getValue("uvm")).isEqualTo(uvm);
    assertThat(target.getValue("hmac-secret")).isEqualTo(new byte[32]);
    // hmacCreateSecret and hmacGetSecret is not a key of HMACSecretAuthenticationExtensionAuthenticatorInput
    assertThat(target.getValue("hmacCreateSecret")).isNull();
    assertThat(target.getValue("hmacGetSecret")).isNull();
    assertThat(target.getValue("unknown")).isEqualTo(1);
    assertThat(target.getValue("invalid")).isNull();
    assertThat(target.getExtension(UserVerificationMethodExtensionAuthenticatorOutput.class)).isNotNull();
    assertThat(target.getExtension(UserVerificationMethodExtensionAuthenticatorOutput.class).getIdentifier()).isEqualTo("uvm");
    assertThat(target.getExtension(UserVerificationMethodExtensionAuthenticatorOutput.class).getUvm()).isEqualTo(uvm);
    assertThat(target.getExtension(HMACSecretAuthenticationExtensionAuthenticatorOutput.class)).isNotNull();
    assertThat(target.getExtension(HMACSecretAuthenticationExtensionAuthenticatorOutput.class).getIdentifier()).isEqualTo("hmac-secret");
    assertThat(target.getExtension(HMACSecretAuthenticationExtensionAuthenticatorOutput.class).getValue()).isEqualTo(new byte[32]);
}
Also used : UvmEntry(com.webauthn4j.data.extension.UvmEntry) UvmEntries(com.webauthn4j.data.extension.UvmEntries) Test(org.junit.jupiter.api.Test)

Aggregations

UvmEntries (com.webauthn4j.data.extension.UvmEntries)8 Test (org.junit.jupiter.api.Test)8 UvmEntry (com.webauthn4j.data.extension.UvmEntry)7 HMACGetSecretOutput (com.webauthn4j.data.extension.HMACGetSecretOutput)2 AuthenticatorData (com.webauthn4j.data.attestation.authenticator.AuthenticatorData)1 AuthenticationExtensionsAuthenticatorOutputs (com.webauthn4j.data.extension.authenticator.AuthenticationExtensionsAuthenticatorOutputs)1 RegistrationExtensionAuthenticatorOutput (com.webauthn4j.data.extension.authenticator.RegistrationExtensionAuthenticatorOutput)1