Search in sources :

Example 1 with AttestedCredentialData

use of com.webauthn4j.data.attestation.authenticator.AttestedCredentialData in project keycloak by keycloak.

the class WebAuthnCredentialProvider method getCredentialInputFromCredentialModel.

/**
 * Convert WebAuthnCredentialModel, which was usually retrieved from DB, to the CredentialInput, which contains data in the webauthn4j specific format
 */
private WebAuthnCredentialModelInput getCredentialInputFromCredentialModel(CredentialModel credential) {
    WebAuthnCredentialModel webAuthnCredential = getCredentialFromModel(credential);
    WebAuthnCredentialData credData = webAuthnCredential.getWebAuthnCredentialData();
    WebAuthnCredentialModelInput auth = new WebAuthnCredentialModelInput(getType());
    byte[] credentialId = null;
    try {
        credentialId = Base64.decode(credData.getCredentialId());
    } catch (IOException ioe) {
    // NOP
    }
    AAGUID aaguid = new AAGUID(credData.getAaguid());
    COSEKey pubKey = credentialPublicKeyConverter.convertToEntityAttribute(credData.getCredentialPublicKey());
    AttestedCredentialData attrCredData = new AttestedCredentialData(aaguid, credentialId, pubKey);
    auth.setAttestedCredentialData(attrCredData);
    long count = credData.getCounter();
    auth.setCount(count);
    auth.setCredentialDBId(credential.getId());
    auth.setAttestationStatementFormat(credData.getAttestationStatementFormat());
    return auth;
}
Also used : AttestedCredentialData(com.webauthn4j.data.attestation.authenticator.AttestedCredentialData) WebAuthnCredentialModel(org.keycloak.models.credential.WebAuthnCredentialModel) WebAuthnCredentialData(org.keycloak.models.credential.dto.WebAuthnCredentialData) COSEKey(com.webauthn4j.data.attestation.authenticator.COSEKey) AAGUID(com.webauthn4j.data.attestation.authenticator.AAGUID) IOException(java.io.IOException)

Example 2 with AttestedCredentialData

use of com.webauthn4j.data.attestation.authenticator.AttestedCredentialData in project keycloak by keycloak.

the class WebAuthnRegister method showInfoAfterWebAuthnApiCreate.

private void showInfoAfterWebAuthnApiCreate(RegistrationData response) {
    AttestedCredentialData attestedCredentialData = response.getAttestationObject().getAuthenticatorData().getAttestedCredentialData();
    AttestationStatement attestationStatement = response.getAttestationObject().getAttestationStatement();
    Set<AuthenticatorTransport> transports = response.getTransports();
    logger.debugv("createad key's algorithm = {0}", String.valueOf(attestedCredentialData.getCOSEKey().getAlgorithm().getValue()));
    logger.debugv("aaguid = {0}", attestedCredentialData.getAaguid().toString());
    logger.debugv("attestation format = {0}", attestationStatement.getFormat());
    if (CollectionUtil.isNotEmpty(transports)) {
        logger.debugv("transports = [{0}]", transports.stream().map(AuthenticatorTransport::getValue).collect(Collectors.joining(",")));
    }
}
Also used : AttestedCredentialData(com.webauthn4j.data.attestation.authenticator.AttestedCredentialData) AttestationStatement(com.webauthn4j.data.attestation.statement.AttestationStatement) AuthenticatorTransport(com.webauthn4j.data.AuthenticatorTransport)

Aggregations

AttestedCredentialData (com.webauthn4j.data.attestation.authenticator.AttestedCredentialData)2 AuthenticatorTransport (com.webauthn4j.data.AuthenticatorTransport)1 AAGUID (com.webauthn4j.data.attestation.authenticator.AAGUID)1 COSEKey (com.webauthn4j.data.attestation.authenticator.COSEKey)1 AttestationStatement (com.webauthn4j.data.attestation.statement.AttestationStatement)1 IOException (java.io.IOException)1 WebAuthnCredentialModel (org.keycloak.models.credential.WebAuthnCredentialModel)1 WebAuthnCredentialData (org.keycloak.models.credential.dto.WebAuthnCredentialData)1