Search in sources :

Example 1 with PublicKeyCredentialRequestOptionsBuilder

use of com.yubico.webauthn.data.PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder in project java-webauthn-server by Yubico.

the class RelyingParty method startAssertion.

public AssertionRequest startAssertion(StartAssertionOptions startAssertionOptions) {
    PublicKeyCredentialRequestOptionsBuilder pkcro = PublicKeyCredentialRequestOptions.builder().challenge(generateChallenge()).rpId(identity.getId()).allowCredentials(OptionalUtil.orElseOptional(startAssertionOptions.getUsername(), () -> startAssertionOptions.getUserHandle().flatMap(credentialRepository::getUsernameForUserHandle)).map(un -> new ArrayList<>(credentialRepository.getCredentialIdsForUsername(un)))).extensions(startAssertionOptions.getExtensions().merge(startAssertionOptions.getExtensions().toBuilder().appid(appId).build())).timeout(startAssertionOptions.getTimeout());
    startAssertionOptions.getUserVerification().ifPresent(pkcro::userVerification);
    return AssertionRequest.builder().publicKeyCredentialRequestOptions(pkcro.build()).username(startAssertionOptions.getUsername()).build();
}
Also used : AppId(com.yubico.webauthn.extension.appid.AppId) Arrays(java.util.Arrays) AuthenticatorAssertionResponse(com.yubico.webauthn.data.AuthenticatorAssertionResponse) AuthenticatorData(com.yubico.webauthn.data.AuthenticatorData) URL(java.net.URL) ClientAssertionExtensionOutputs(com.yubico.webauthn.data.ClientAssertionExtensionOutputs) CollectionUtil(com.yubico.internal.util.CollectionUtil) ClientRegistrationExtensionOutputs(com.yubico.webauthn.data.ClientRegistrationExtensionOutputs) ArrayList(java.util.ArrayList) Value(lombok.Value) AssertionFailedException(com.yubico.webauthn.exception.AssertionFailedException) SecureRandom(java.security.SecureRandom) PublicKeyCredentialCreationOptions(com.yubico.webauthn.data.PublicKeyCredentialCreationOptions) InvalidSignatureCountException(com.yubico.webauthn.exception.InvalidSignatureCountException) OptionalUtil(com.yubico.internal.util.OptionalUtil) RelyingPartyIdentity(com.yubico.webauthn.data.RelyingPartyIdentity) AttestationTrustSource(com.yubico.webauthn.attestation.AttestationTrustSource) CollectedClientData(com.yubico.webauthn.data.CollectedClientData) RegistrationFailedException(com.yubico.webauthn.exception.RegistrationFailedException) MalformedURLException(java.net.MalformedURLException) RegistrationExtensionInputs(com.yubico.webauthn.data.RegistrationExtensionInputs) NonNull(lombok.NonNull) Signature(java.security.Signature) Set(java.util.Set) PublicKeyCredentialRequestOptionsBuilder(com.yubico.webauthn.data.PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder) PublicKeyCredential(com.yubico.webauthn.data.PublicKeyCredential) AuthenticatorAttestationResponse(com.yubico.webauthn.data.AuthenticatorAttestationResponse) Collectors(java.util.stream.Collectors) KeyFactory(java.security.KeyFactory) PublicKeyCredentialCreationOptionsBuilder(com.yubico.webauthn.data.PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Builder(lombok.Builder) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Clock(java.time.Clock) Optional(java.util.Optional) AssertionExtensionInputs(com.yubico.webauthn.data.AssertionExtensionInputs) AttestationConveyancePreference(com.yubico.webauthn.data.AttestationConveyancePreference) ByteArray(com.yubico.webauthn.data.ByteArray) Collections(java.util.Collections) PublicKeyCredentialRequestOptions(com.yubico.webauthn.data.PublicKeyCredentialRequestOptions) PublicKeyCredentialParameters(com.yubico.webauthn.data.PublicKeyCredentialParameters) PublicKeyCredentialRequestOptionsBuilder(com.yubico.webauthn.data.PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder) ArrayList(java.util.ArrayList)

Aggregations

CollectionUtil (com.yubico.internal.util.CollectionUtil)1 OptionalUtil (com.yubico.internal.util.OptionalUtil)1 AttestationTrustSource (com.yubico.webauthn.attestation.AttestationTrustSource)1 AssertionExtensionInputs (com.yubico.webauthn.data.AssertionExtensionInputs)1 AttestationConveyancePreference (com.yubico.webauthn.data.AttestationConveyancePreference)1 AuthenticatorAssertionResponse (com.yubico.webauthn.data.AuthenticatorAssertionResponse)1 AuthenticatorAttestationResponse (com.yubico.webauthn.data.AuthenticatorAttestationResponse)1 AuthenticatorData (com.yubico.webauthn.data.AuthenticatorData)1 ByteArray (com.yubico.webauthn.data.ByteArray)1 ClientAssertionExtensionOutputs (com.yubico.webauthn.data.ClientAssertionExtensionOutputs)1 ClientRegistrationExtensionOutputs (com.yubico.webauthn.data.ClientRegistrationExtensionOutputs)1 CollectedClientData (com.yubico.webauthn.data.CollectedClientData)1 PublicKeyCredential (com.yubico.webauthn.data.PublicKeyCredential)1 PublicKeyCredentialCreationOptions (com.yubico.webauthn.data.PublicKeyCredentialCreationOptions)1 PublicKeyCredentialCreationOptionsBuilder (com.yubico.webauthn.data.PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder)1 PublicKeyCredentialParameters (com.yubico.webauthn.data.PublicKeyCredentialParameters)1 PublicKeyCredentialRequestOptions (com.yubico.webauthn.data.PublicKeyCredentialRequestOptions)1 PublicKeyCredentialRequestOptionsBuilder (com.yubico.webauthn.data.PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder)1 RegistrationExtensionInputs (com.yubico.webauthn.data.RegistrationExtensionInputs)1 RelyingPartyIdentity (com.yubico.webauthn.data.RelyingPartyIdentity)1