Search in sources :

Example 6 with RegistrationObject

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

the class MetadataBLOBBasedTrustAnchorRepositoryTest method validate_test.

@Test
void validate_test() {
    MetadataBLOBBasedTrustAnchorRepository target = createWithBlob("src/test/resources/integration/component/blob.jwt");
    RegistrationObject registrationObject = TestDataUtil.createRegistrationObjectWithTPMAttestation();
    @SuppressWarnings("ConstantConditions") AAGUID aaguid = registrationObject.getAttestationObject().getAuthenticatorData().getAttestedCredentialData().getAaguid();
    assertThat(target.find(aaguid)).isNotEmpty();
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) AAGUID(com.webauthn4j.data.attestation.authenticator.AAGUID) Test(org.junit.jupiter.api.Test)

Example 7 with RegistrationObject

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

the class AndroidKeyAttestationStatementTest method equals_hashCode_test.

@Test
void equals_hashCode_test() {
    RegistrationObject registrationObjectA = TestDataUtil.createRegistrationObjectWithAndroidKeyAttestation();
    AndroidKeyAttestationStatement instanceA = (AndroidKeyAttestationStatement) registrationObjectA.getAttestationObject().getAttestationStatement();
    RegistrationObject registrationObjectB = TestDataUtil.createRegistrationObjectWithAndroidKeyAttestation();
    AndroidKeyAttestationStatement instanceB = (AndroidKeyAttestationStatement) 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)

Example 8 with RegistrationObject

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

the class AppleAnonymousAttestationStatementTest method equals_hashCode_test.

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

Example 9 with RegistrationObject

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

the class AppleAnonymousAttestationStatementTest method getter_test.

@Test
void getter_test() {
    RegistrationObject registrationObject = TestDataUtil.createRegistrationObjectWithAppleAttestation();
    AppleAnonymousAttestationStatement instance = (AppleAnonymousAttestationStatement) registrationObject.getAttestationObject().getAttestationStatement();
    assertThat(instance.getFormat()).isEqualTo(AppleAnonymousAttestationStatement.FORMAT);
    assertThat(instance.getX5c()).hasSize(2);
}
Also used : RegistrationObject(com.webauthn4j.validator.RegistrationObject) Test(org.junit.jupiter.api.Test)

Example 10 with RegistrationObject

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

the class AndroidSafetyNetAttestationStatementValidatorTest method validate_test.

@Test
void validate_test() {
    String rpId = "example.com";
    Challenge challenge = new DefaultChallenge();
    AuthenticatorSelectionCriteria authenticatorSelectionCriteria = new AuthenticatorSelectionCriteria(AuthenticatorAttachment.CROSS_PLATFORM, true, UserVerificationRequirement.REQUIRED);
    PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256);
    PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = new PublicKeyCredentialUserEntity(new byte[32], "username", "displayName");
    AuthenticationExtensionsClientInputs<RegistrationExtensionClientInput> extensions = new AuthenticationExtensionsClientInputs<>();
    PublicKeyCredentialCreationOptions credentialCreationOptions = new PublicKeyCredentialCreationOptions(new PublicKeyCredentialRpEntity(rpId, "example.com"), publicKeyCredentialUserEntity, challenge, Collections.singletonList(publicKeyCredentialParameters), null, Collections.emptyList(), authenticatorSelectionCriteria, AttestationConveyancePreference.DIRECT, extensions);
    PublicKeyCredential<AuthenticatorAttestationResponse, RegistrationExtensionClientOutput> publicKeyCredential = clientPlatform.create(credentialCreationOptions);
    RegistrationObject registrationObject = TestDataUtil.createRegistrationObject(publicKeyCredential);
    target.validate(registrationObject);
}
Also used : RegistrationExtensionClientOutput(com.webauthn4j.data.extension.client.RegistrationExtensionClientOutput) Challenge(com.webauthn4j.data.client.challenge.Challenge) DefaultChallenge(com.webauthn4j.data.client.challenge.DefaultChallenge) DefaultChallenge(com.webauthn4j.data.client.challenge.DefaultChallenge) AuthenticationExtensionsClientInputs(com.webauthn4j.data.extension.client.AuthenticationExtensionsClientInputs) RegistrationExtensionClientInput(com.webauthn4j.data.extension.client.RegistrationExtensionClientInput) 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