Search in sources :

Example 1 with NotImplementedException

use of com.webauthn4j.util.exception.NotImplementedException in project webauthn4j by webauthn4j.

the class TPMTPublicDeserializer method extractTPMUPublicId.

@NonNull
private TPMUPublicId extractTPMUPublicId(@NonNull TPMIAlgPublic type, @NonNull ByteBuffer buffer) {
    if (type == TPMIAlgPublic.TPM_ALG_RSA) {
        int nSize = UnsignedNumberUtil.getUnsignedShort(buffer);
        byte[] n = new byte[nSize];
        buffer.get(n);
        return new RSAUnique(n);
    } else if (type == TPMIAlgPublic.TPM_ALG_ECDSA) {
        int xSize = UnsignedNumberUtil.getUnsignedShort(buffer);
        byte[] x = new byte[xSize];
        buffer.get(x);
        int ySize = UnsignedNumberUtil.getUnsignedShort(buffer);
        byte[] y = new byte[ySize];
        buffer.get(y);
        return new ECCUnique(x, y);
    } else {
        throw new NotImplementedException();
    }
}
Also used : NotImplementedException(com.webauthn4j.util.exception.NotImplementedException) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Example 2 with NotImplementedException

use of com.webauthn4j.util.exception.NotImplementedException in project webauthn4j by webauthn4j.

the class ClientPlatform method create.

public PublicKeyCredential<AuthenticatorAttestationResponse, RegistrationExtensionClientOutput> create(PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions, RegistrationEmulationOption registrationEmulationOption, AttestationOption attestationOption) {
    CollectedClientData collectedClientData;
    if (registrationEmulationOption.isCollectedClientDataOverrideEnabled()) {
        collectedClientData = registrationEmulationOption.getCollectedClientData();
    } else {
        collectedClientData = createCollectedClientData(ClientDataType.WEBAUTHN_CREATE, publicKeyCredentialCreationOptions.getChallenge());
    }
    if (authenticatorAdaptor == null) {
        throw new NoAuthenticatorSuccessException();
    }
    CredentialCreationResponse credentialCreationResponse = authenticatorAdaptor.register(publicKeyCredentialCreationOptions, collectedClientData, registrationEmulationOption, attestationOption);
    AttestationObject attestationObject = credentialCreationResponse.getAttestationObject();
    AttestationStatement attestationStatement = credentialCreationResponse.getAttestationObject().getAttestationStatement();
    AttestationConveyancePreference attestationConveyancePreference = publicKeyCredentialCreationOptions.getAttestation();
    if (attestationConveyancePreference == null) {
        attestationConveyancePreference = AttestationConveyancePreference.NONE;
    }
    if (AttestationConveyancePreference.DIRECT.equals(attestationConveyancePreference)) {
    // nop
    } else if (AttestationConveyancePreference.INDIRECT.equals(attestationConveyancePreference)) {
        throw new NotImplementedException();
    } else if (AttestationConveyancePreference.NONE.equals(attestationConveyancePreference)) {
        attestationStatement = new NoneAttestationStatement();
    } else {
        throw new NotImplementedException();
    }
    attestationObject = new AttestationObject(attestationObject.getAuthenticatorData(), attestationStatement);
    byte[] attestationObjectBytes = attestationObjectConverter.convertToBytes(attestationObject);
    byte[] credentialId = credentialCreationResponse.getAttestationObject().getAuthenticatorData().getAttestedCredentialData().getCredentialId();
    byte[] collectedClientDataBytes = collectedClientDataConverter.convertToBytes(collectedClientData);
    AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput> clientExtensions = processRegistrationExtensions(publicKeyCredentialCreationOptions.getExtensions());
    return new PublicKeyCredential<>(credentialId, new AuthenticatorAttestationResponse(collectedClientDataBytes, attestationObjectBytes), clientExtensions);
}
Also used : NotImplementedException(com.webauthn4j.util.exception.NotImplementedException) AttestationObject(com.webauthn4j.data.attestation.AttestationObject) NoneAttestationStatement(com.webauthn4j.data.attestation.statement.NoneAttestationStatement) NoneAttestationStatement(com.webauthn4j.data.attestation.statement.NoneAttestationStatement) AttestationStatement(com.webauthn4j.data.attestation.statement.AttestationStatement) CredentialCreationResponse(com.webauthn4j.test.authenticator.CredentialCreationResponse)

Aggregations

NotImplementedException (com.webauthn4j.util.exception.NotImplementedException)2 AttestationObject (com.webauthn4j.data.attestation.AttestationObject)1 AttestationStatement (com.webauthn4j.data.attestation.statement.AttestationStatement)1 NoneAttestationStatement (com.webauthn4j.data.attestation.statement.NoneAttestationStatement)1 CredentialCreationResponse (com.webauthn4j.test.authenticator.CredentialCreationResponse)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1