Search in sources :

Example 1 with AppId

use of com.yubico.webauthn.extension.appid.AppId in project java-webauthn-server by Yubico.

the class RelyingPartyTest method itHasTheseBuilderMethods.

@Test(expected = NullPointerException.class)
public void itHasTheseBuilderMethods() throws InvalidAppIdException {
    final AttestationTrustSource attestationTrustSource = new AttestationTrustSource() {

        @Override
        public TrustRootsResult findTrustRoots(List<X509Certificate> attestationCertificateChain, Optional<ByteArray> aaguid) {
            return null;
        }
    };
    RelyingParty.builder().identity(null).credentialRepository(null).origins(Collections.emptySet()).appId(new AppId("https://example.com")).appId(Optional.of(new AppId("https://example.com"))).attestationConveyancePreference(AttestationConveyancePreference.DIRECT).attestationConveyancePreference(Optional.of(AttestationConveyancePreference.DIRECT)).attestationTrustSource(attestationTrustSource).attestationTrustSource(Optional.of(attestationTrustSource)).preferredPubkeyParams(Collections.emptyList()).allowUntrustedAttestation(true).validateSignatureCounter(true);
}
Also used : Optional(java.util.Optional) AppId(com.yubico.webauthn.extension.appid.AppId) AttestationTrustSource(com.yubico.webauthn.attestation.AttestationTrustSource) List(java.util.List) Test(org.junit.Test)

Example 2 with AppId

use of com.yubico.webauthn.extension.appid.AppId in project java-webauthn-server by Yubico.

the class Config method computeAppId.

private static Optional<AppId> computeAppId() throws InvalidAppIdException {
    final String appId = System.getenv("YUBICO_WEBAUTHN_U2F_APPID");
    logger.debug("YUBICO_WEBAUTHN_U2F_APPID: {}", appId);
    AppId result = appId == null ? new AppId("https://localhost:8443") : new AppId(appId);
    logger.debug("U2F AppId: {}", result.getId());
    return Optional.of(result);
}
Also used : AppId(com.yubico.webauthn.extension.appid.AppId)

Example 3 with AppId

use of com.yubico.webauthn.extension.appid.AppId 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

AppId (com.yubico.webauthn.extension.appid.AppId)3 AttestationTrustSource (com.yubico.webauthn.attestation.AttestationTrustSource)2 List (java.util.List)2 Optional (java.util.Optional)2 CollectionUtil (com.yubico.internal.util.CollectionUtil)1 OptionalUtil (com.yubico.internal.util.OptionalUtil)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