Search in sources :

Example 36 with RegistrationObject

use of com.webauthn4j.validator.RegistrationObject in project webauthn4j by webauthn4j.

the class TPMAttestationStatementValidatorTest method validate_non_TPMAttestation_test.

@Test
void validate_non_TPMAttestation_test() {
    RegistrationObject registrationObject = TestDataUtil.createRegistrationObjectWithAndroidKeyAttestation();
    assertThrows(IllegalArgumentException.class, () -> target.validate(registrationObject));
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) Test(org.junit.jupiter.api.Test)

Example 37 with RegistrationObject

use of com.webauthn4j.validator.RegistrationObject in project webauthn4j by webauthn4j.

the class FIDOU2FAttestationStatementValidatorTest method validate_invalid_attestation_statement_test.

@Test
void validate_invalid_attestation_statement_test() {
    RegistrationObject registrationObject = mock(RegistrationObject.class);
    AttestationObject attestationObject = mock(AttestationObject.class);
    when(registrationObject.getAttestationObject()).thenReturn(attestationObject);
    when(attestationObject.getAttestationStatement()).thenReturn(new NoneAttestationStatement());
    assertThrows(IllegalArgumentException.class, () -> target.validate(registrationObject));
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) AttestationObject(com.webauthn4j.data.attestation.AttestationObject) NoneAttestationStatement(com.webauthn4j.data.attestation.statement.NoneAttestationStatement) Test(org.junit.jupiter.api.Test)

Example 38 with RegistrationObject

use of com.webauthn4j.validator.RegistrationObject in project webauthn4j by webauthn4j.

the class TPMAttestationStatementTest method constructor_test.

@Test
void constructor_test() {
    RegistrationObject registrationObjectA = TestDataUtil.createRegistrationObjectWithTPMAttestation();
    TPMAttestationStatement source = (TPMAttestationStatement) registrationObjectA.getAttestationObject().getAttestationStatement();
    TPMAttestationStatement tpmAttestationStatement = new TPMAttestationStatement(source.getAlg(), source.getX5c(), source.getSig(), source.getCertInfo(), source.getPubArea());
    assertAll(() -> assertThat(tpmAttestationStatement.getAlg()).isEqualTo(source.getAlg()), () -> assertThat(tpmAttestationStatement.getX5c()).isEqualTo(source.getX5c()), () -> assertThat(tpmAttestationStatement.getSig()).isEqualTo(source.getSig()), () -> assertThat(tpmAttestationStatement.getCertInfo()).isEqualTo(source.getCertInfo()), () -> assertThat(tpmAttestationStatement.getPubArea()).isEqualTo(source.getPubArea()));
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) Test(org.junit.jupiter.api.Test)

Example 39 with RegistrationObject

use of com.webauthn4j.validator.RegistrationObject in project webauthn4j by webauthn4j.

the class TPMAttestationStatementTest method validate_test.

@Test
void validate_test() {
    RegistrationObject registrationObjectA = TestDataUtil.createRegistrationObjectWithTPMAttestation();
    TPMAttestationStatement source = (TPMAttestationStatement) registrationObjectA.getAttestationObject().getAttestationStatement();
    TPMAttestationStatement tpmAttestationStatement = new TPMAttestationStatement(source.getAlg(), new AttestationCertificatePath(), source.getSig(), source.getCertInfo(), source.getPubArea());
    assertThrows(ConstraintViolationException.class, tpmAttestationStatement::validate);
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) Test(org.junit.jupiter.api.Test)

Example 40 with RegistrationObject

use of com.webauthn4j.validator.RegistrationObject in project webauthn4j by webauthn4j.

the class TPMAttestationStatementTest method equals_hashCode_test.

@Test
void equals_hashCode_test() {
    RegistrationObject registrationObjectA = TestDataUtil.createRegistrationObjectWithTPMAttestation();
    TPMAttestationStatement instanceA = (TPMAttestationStatement) registrationObjectA.getAttestationObject().getAttestationStatement();
    RegistrationObject registrationObjectB = TestDataUtil.createRegistrationObjectWithTPMAttestation();
    TPMAttestationStatement instanceB = (TPMAttestationStatement) registrationObjectB.getAttestationObject().getAttestationStatement();
    assertAll(() -> assertThat(instanceA).isEqualTo(instanceB), () -> assertThat(instanceA).hasSameHashCodeAs(instanceB));
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) Test(org.junit.jupiter.api.Test)

Aggregations

RegistrationObject (com.webauthn4j.validator.RegistrationObject)40 Test (org.junit.jupiter.api.Test)31 RegistrationExtensionClientOutput (com.webauthn4j.data.extension.client.RegistrationExtensionClientOutput)9 CoreRegistrationObject (com.webauthn4j.validator.CoreRegistrationObject)9 DCRegistrationObject (com.webauthn4j.appattest.validator.DCRegistrationObject)8 AttestationObject (com.webauthn4j.data.attestation.AttestationObject)8 CollectedClientData (com.webauthn4j.data.client.CollectedClientData)8 AuthenticationExtensionsClientOutputs (com.webauthn4j.data.extension.client.AuthenticationExtensionsClientOutputs)7 AAGUID (com.webauthn4j.data.attestation.authenticator.AAGUID)2 Origin (com.webauthn4j.data.client.Origin)2 Challenge (com.webauthn4j.data.client.challenge.Challenge)2 DefaultChallenge (com.webauthn4j.data.client.challenge.DefaultChallenge)2 ServerProperty (com.webauthn4j.server.ServerProperty)2 DCServerProperty (com.webauthn4j.appattest.server.DCServerProperty)1 AttestationObjectConverter (com.webauthn4j.converter.AttestationObjectConverter)1 CollectedClientDataConverter (com.webauthn4j.converter.CollectedClientDataConverter)1 ObjectConverter (com.webauthn4j.converter.util.ObjectConverter)1 AuthenticatorAttestationType (com.webauthn4j.data.AuthenticatorAttestationType)1 AuthenticatorTransport (com.webauthn4j.data.AuthenticatorTransport)1 AndroidKeyAttestationStatement (com.webauthn4j.data.attestation.statement.AndroidKeyAttestationStatement)1