Java Code Examples for com.webauthn4j.data.attestation.authenticator.AAGUID#ZERO

The following examples show how to use com.webauthn4j.data.attestation.authenticator.AAGUID#ZERO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonFileResourceMetadataStatementsProvider.java    From webauthn4j-spring-security with Apache License 2.0 5 votes vote down vote up
AAGUID extractAAGUID(MetadataStatement metadataStatement) {
    switch (metadataStatement.getProtocolFamily()) {
        case "fido2":
            return metadataStatement.getAaguid();
        case "u2f":
            return AAGUID.ZERO;
        case "uaf":
        default:
            return AAGUID.NULL;
    }
}
 
Example 2
Source File: WebAuthnModelAuthenticator.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
public WebAuthnModelAuthenticator() {
    this(
            AAGUID.ZERO,
            new KeyPair(
                    TestAttestationUtil.load3tierTestAuthenticatorAttestationPublicKey(),
                    TestAttestationUtil.load3tierTestAuthenticatorAttestationPrivateKey()),
            TestAttestationUtil.load3tierTestCACertificatePath(),
            TestAttestationUtil.load3tierTestIntermediateCAPrivateKey(),
            0,
            true,
            new ObjectConverter()
    );
}
 
Example 3
Source File: FIDOU2FAuthenticatorAdaptor.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
@Override
public CredentialCreationResponse register(
        PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions,
        CollectedClientData collectedClientData,
        RegistrationEmulationOption registrationEmulationOption,
        AttestationOption attestationOption
) {
    String rpId = publicKeyCredentialCreationOptions.getRp().getId();
    byte[] rpIdHash = MessageDigestUtil.createSHA256().digest(rpId.getBytes(StandardCharsets.UTF_8));

    byte[] challengeParameter = MessageDigestUtil.createSHA256().digest(collectedClientDataConverter.convertToBytes(collectedClientData));
    //noinspection UnnecessaryLocalVariable
    byte[] applicationParameter = rpIdHash;
    RegistrationRequest registrationRequest = new RegistrationRequest(challengeParameter, applicationParameter);
    RegistrationResponse registrationResponse = fidoU2FAuthenticator.register(registrationRequest, registrationEmulationOption);

    AttestationStatement attestationStatement = new FIDOU2FAttestationStatement(
            new AttestationCertificatePath(Collections.singletonList(registrationResponse.getAttestationCertificate())),
            registrationResponse.getSignature()
    );

    EC2COSEKey ec2CredentialPublicKey = EC2COSEKey.createFromUncompressedECCKey(registrationResponse.getUserPublicKey());

    AAGUID aaguid = AAGUID.ZERO; // zero-filled 16bytes(128bits) array
    AttestedCredentialData attestedCredentialData =
            new AttestedCredentialData(aaguid, registrationResponse.getKeyHandle(), ec2CredentialPublicKey);

    byte flag = BIT_AT | BIT_UP;
    AuthenticatorData<RegistrationExtensionAuthenticatorOutput<?>> authenticatorData = new AuthenticatorData<>(rpIdHash, flag, 0, attestedCredentialData);

    AttestationObject attestationObject = new AttestationObject(authenticatorData, attestationStatement);

    return new CredentialCreationResponse(attestationObject);
}
 
Example 4
Source File: JsonFileMetadataStatementsProvider.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
private AAGUID extractAAGUID(MetadataStatement metadataStatement) {
    switch (metadataStatement.getProtocolFamily()) {
        case "fido2":
            return metadataStatement.getAaguid();
        case "u2f":
            return AAGUID.ZERO;
        case "uaf":
        default:
            return AAGUID.NULL;
    }
}