Overview
The VirtualAuthenticatorOptions class provides a fluent builder for configuring the properties of a virtual WebAuthn authenticator, including protocol version, transport mechanism, and user verification behavior.
Description
VirtualAuthenticatorOptions encapsulates the configuration parameters for creating a virtual authenticator as defined by the W3C WebAuthn automation specification. It supports two protocol versions (CTAP2 and U2F), four transport types (BLE, Internal, NFC, USB), and various boolean flags controlling resident key support, user verification capability, user consent, and user verified state. The class uses a fluent setter pattern, allowing method chaining for concise configuration. It serializes to a Map<String, Object> for wire protocol transmission.
Usage
Use VirtualAuthenticatorOptions to configure a virtual authenticator before adding it to a driver via HasVirtualAuthenticator.addVirtualAuthenticator(). Set the protocol, transport, and verification options to match the authenticator scenario being tested.
Code Reference
Source Location
Signature
public class VirtualAuthenticatorOptions {
public enum Protocol {
CTAP2("ctap2"),
U2F("ctap1/u2f");
}
public enum Transport {
BLE("ble"),
INTERNAL("internal"),
NFC("nfc"),
USB("usb");
}
public VirtualAuthenticatorOptions();
public VirtualAuthenticatorOptions setProtocol(Protocol protocol);
public VirtualAuthenticatorOptions setTransport(Transport transport);
public VirtualAuthenticatorOptions setHasResidentKey(boolean hasResidentKey);
public VirtualAuthenticatorOptions setHasUserVerification(boolean hasUserVerification);
public VirtualAuthenticatorOptions setIsUserConsenting(boolean isUserConsenting);
public VirtualAuthenticatorOptions setIsUserVerified(boolean isUserVerified);
public Map<String, Object> toMap();
}
Import
import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions;
I/O Contract
Enums
Protocol
| Enum Value |
Wire ID |
Description
|
CTAP2 |
"ctap2" |
CTAP2 protocol (FIDO2)
|
U2F |
"ctap1/u2f" |
CTAP1/U2F protocol (legacy FIDO)
|
Transport
| Enum Value |
Wire ID |
Description
|
BLE |
"ble" |
Bluetooth Low Energy transport
|
INTERNAL |
"internal" |
Platform/internal authenticator
|
NFC |
"nfc" |
Near Field Communication transport
|
USB |
"usb" |
USB transport
|
Setter Methods (Fluent)
| Method |
Parameter |
Default |
Description
|
setProtocol |
Protocol protocol |
Protocol.CTAP2 |
Sets the authenticator protocol version
|
setTransport |
Transport transport |
Transport.USB |
Sets the authenticator transport mechanism
|
setHasResidentKey |
boolean hasResidentKey |
false |
Whether the authenticator supports resident keys (discoverable credentials)
|
setHasUserVerification |
boolean hasUserVerification |
false |
Whether the authenticator supports user verification
|
setIsUserConsenting |
boolean isUserConsenting |
true |
Whether the user will consent to operations by default
|
setIsUserVerified |
boolean isUserVerified |
false |
Whether the user is pre-verified
|
Serialization (toMap)
| Map Key |
Type |
Description
|
protocol |
String |
Protocol wire ID (e.g., "ctap2")
|
transport |
String |
Transport wire ID (e.g., "usb")
|
hasResidentKey |
boolean |
Resident key support flag
|
hasUserVerification |
boolean |
User verification support flag
|
isUserConsenting |
boolean |
User consent flag
|
isUserVerified |
boolean |
User verified flag
|
Usage Examples
// Create a CTAP2 USB authenticator with resident key and user verification
VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions()
.setProtocol(VirtualAuthenticatorOptions.Protocol.CTAP2)
.setTransport(VirtualAuthenticatorOptions.Transport.USB)
.setHasResidentKey(true)
.setHasUserVerification(true)
.setIsUserVerified(true);
// Create a U2F authenticator (no resident keys)
VirtualAuthenticatorOptions u2fOptions = new VirtualAuthenticatorOptions()
.setProtocol(VirtualAuthenticatorOptions.Protocol.U2F)
.setTransport(VirtualAuthenticatorOptions.Transport.USB);
// Create an internal/platform authenticator
VirtualAuthenticatorOptions platformOptions = new VirtualAuthenticatorOptions()
.setTransport(VirtualAuthenticatorOptions.Transport.INTERNAL)
.setHasResidentKey(true)
.setHasUserVerification(true)
.setIsUserVerified(true);
// Add to driver
VirtualAuthenticator authenticator = ((HasVirtualAuthenticator) driver)
.addVirtualAuthenticator(options);
// Serialize to map for wire protocol
Map<String, Object> wireMap = options.toMap();
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.