All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v123.webauthn.WebAuthn Maven / Gradle / Ivy

Go to download

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

There is a newer version: 4.21.0
Show newest version
package org.openqa.selenium.devtools.v123.webauthn;

import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;

/**
 * This domain allows configuring virtual authenticators to test the WebAuthn
 * API.
 */
@Beta()
public class WebAuthn {

    /**
     * Enable the WebAuthn domain and start intercepting credential storage and
     * retrieval with a virtual authenticator.
     */
    public static Command enable(java.util.Optional enableUI) {
        LinkedHashMap params = new LinkedHashMap<>();
        enableUI.ifPresent(p -> params.put("enableUI", p));
        return new Command<>("WebAuthn.enable", Map.copyOf(params));
    }

    /**
     * Disable the WebAuthn domain.
     */
    public static Command disable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("WebAuthn.disable", Map.copyOf(params));
    }

    /**
     * Creates and adds a virtual authenticator.
     */
    public static Command addVirtualAuthenticator(org.openqa.selenium.devtools.v123.webauthn.model.VirtualAuthenticatorOptions options) {
        java.util.Objects.requireNonNull(options, "options is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("options", options);
        return new Command<>("WebAuthn.addVirtualAuthenticator", Map.copyOf(params), ConverterFunctions.map("authenticatorId", org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId.class));
    }

    /**
     * Resets parameters isBogusSignature, isBadUV, isBadUP to false if they are not present.
     */
    public static Command setResponseOverrideBits(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.util.Optional isBogusSignature, java.util.Optional isBadUV, java.util.Optional isBadUP) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        isBogusSignature.ifPresent(p -> params.put("isBogusSignature", p));
        isBadUV.ifPresent(p -> params.put("isBadUV", p));
        isBadUP.ifPresent(p -> params.put("isBadUP", p));
        return new Command<>("WebAuthn.setResponseOverrideBits", Map.copyOf(params));
    }

    /**
     * Removes the given authenticator.
     */
    public static Command removeVirtualAuthenticator(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        return new Command<>("WebAuthn.removeVirtualAuthenticator", Map.copyOf(params));
    }

    /**
     * Adds the credential to the specified authenticator.
     */
    public static Command addCredential(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, org.openqa.selenium.devtools.v123.webauthn.model.Credential credential) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(credential, "credential is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("credential", credential);
        return new Command<>("WebAuthn.addCredential", Map.copyOf(params));
    }

    /**
     * Returns a single credential stored in the given virtual authenticator that
     * matches the credential ID.
     */
    public static Command getCredential(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.lang.String credentialId) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(credentialId, "credentialId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("credentialId", credentialId);
        return new Command<>("WebAuthn.getCredential", Map.copyOf(params), ConverterFunctions.map("credential", org.openqa.selenium.devtools.v123.webauthn.model.Credential.class));
    }

    /**
     * Returns all the credentials stored in the given virtual authenticator.
     */
    public static Command> getCredentials(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        return new Command<>("WebAuthn.getCredentials", Map.copyOf(params), ConverterFunctions.map("credentials", input -> input.readArray(org.openqa.selenium.devtools.v123.webauthn.model.Credential.class)));
    }

    /**
     * Removes a credential from the authenticator.
     */
    public static Command removeCredential(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.lang.String credentialId) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(credentialId, "credentialId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("credentialId", credentialId);
        return new Command<>("WebAuthn.removeCredential", Map.copyOf(params));
    }

    /**
     * Clears all the credentials from the specified device.
     */
    public static Command clearCredentials(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        return new Command<>("WebAuthn.clearCredentials", Map.copyOf(params));
    }

    /**
     * Sets whether User Verification succeeds or fails for an authenticator.
     * The default is true.
     */
    public static Command setUserVerified(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.lang.Boolean isUserVerified) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(isUserVerified, "isUserVerified is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("isUserVerified", isUserVerified);
        return new Command<>("WebAuthn.setUserVerified", Map.copyOf(params));
    }

    /**
     * Sets whether tests of user presence will succeed immediately (if true) or fail to resolve (if false) for an authenticator.
     * The default is true.
     */
    public static Command setAutomaticPresenceSimulation(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.lang.Boolean enabled) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(enabled, "enabled is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("enabled", enabled);
        return new Command<>("WebAuthn.setAutomaticPresenceSimulation", Map.copyOf(params));
    }

    /**
     * Allows setting credential properties.
     * https://w3c.github.io/webauthn/#sctn-automation-set-credential-properties
     */
    public static Command setCredentialProperties(org.openqa.selenium.devtools.v123.webauthn.model.AuthenticatorId authenticatorId, java.lang.String credentialId, java.util.Optional backupEligibility, java.util.Optional backupState) {
        java.util.Objects.requireNonNull(authenticatorId, "authenticatorId is required");
        java.util.Objects.requireNonNull(credentialId, "credentialId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("authenticatorId", authenticatorId);
        params.put("credentialId", credentialId);
        backupEligibility.ifPresent(p -> params.put("backupEligibility", p));
        backupState.ifPresent(p -> params.put("backupState", p));
        return new Command<>("WebAuthn.setCredentialProperties", Map.copyOf(params));
    }

    public static Event credentialAdded() {
        return new Event<>("WebAuthn.credentialAdded", input -> input.read(org.openqa.selenium.devtools.v123.webauthn.model.CredentialAdded.class));
    }

    public static Event credentialAsserted() {
        return new Event<>("WebAuthn.credentialAsserted", input -> input.read(org.openqa.selenium.devtools.v123.webauthn.model.CredentialAsserted.class));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy