Package com.yubico.yubikit.fido.ctap
Class Ctap2Session
java.lang.Object
com.yubico.yubikit.core.application.ApplicationSession<Ctap2Session>
com.yubico.yubikit.fido.ctap.Ctap2Session
- All Implemented Interfaces:
Closeable,AutoCloseable
public class Ctap2Session
extends com.yubico.yubikit.core.application.ApplicationSession<Ctap2Session>
Implements CTAP 2.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData class holding the result of getAssertion.static classData class holding the result of makeCredential.static classData object containing the information readable form a YubiKey using the getInfo command. -
Constructor Summary
ConstructorsConstructorDescriptionCtap2Session(com.yubico.yubikit.core.fido.FidoConnection connection) Ctap2Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) Ctap2Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection, com.yubico.yubikit.core.Version version) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()config(byte subCommand, Map<?, ?> subCommandParams, Integer pinUvAuthProtocol, byte[] pinUvAuthParam) This command is used to configure various authenticator features through the use of its subcommands.static voidcreate(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<Ctap2Session, Exception>> callback) Construct a new Ctap2Session for a given YubiKey.getAssertions(String rpId, byte[] clientDataHash, List<Map<String, ?>> allowList, Map<String, ?> extensions, Map<String, ?> options, byte[] pinUvAuthParam, Integer pinUvAuthProtocol, com.yubico.yubikit.core.application.CommandState state) This method is used by a host to request cryptographic proof of user authentication as well as user consent to a given transaction, using a previously generated credential that is bound to the authenticator and relying party identifier.getInfo()Using this method, platforms can request that the authenticator report a list of its supported protocol versions and extensions, its AAGUID, and other aspects of its overall capabilities.com.yubico.yubikit.core.VersionmakeCredential(byte[] clientDataHash, Map<String, ?> rp, Map<String, ?> user, List<Map<String, ?>> pubKeyCredParams, List<Map<String, ?>> excludeList, Map<String, ?> extensions, Map<String, ?> options, byte[] pinUvAuthParam, Integer pinUvAuthProtocol, Integer enterpriseAttestation, com.yubico.yubikit.core.application.CommandState state) This method is invoked by the host to request generation of a new credential in the authenticator.voidreset(com.yubico.yubikit.core.application.CommandState state) Issues a CTAP2 reset, which will delete/invalidate all FIDO credentials.voidselection(com.yubico.yubikit.core.application.CommandState state) This command allows the platform to let a user select a certain authenticator by asking for user presence.Methods inherited from class com.yubico.yubikit.core.application.ApplicationSession
require, supports
-
Constructor Details
-
Ctap2Session
public Ctap2Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) throws IOException, com.yubico.yubikit.core.application.CommandException - Throws:
IOExceptioncom.yubico.yubikit.core.application.CommandException
-
Ctap2Session
public Ctap2Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection, com.yubico.yubikit.core.Version version) throws IOException, com.yubico.yubikit.core.application.CommandException - Throws:
IOExceptioncom.yubico.yubikit.core.application.CommandException
-
Ctap2Session
public Ctap2Session(com.yubico.yubikit.core.fido.FidoConnection connection) throws IOException, com.yubico.yubikit.core.application.CommandException - Throws:
IOExceptioncom.yubico.yubikit.core.application.CommandException
-
-
Method Details
-
create
public static void create(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<Ctap2Session, Exception>> callback) Construct a new Ctap2Session for a given YubiKey.- Parameters:
device- a YubiKeyDevice over NFC or USBcallback- a callback to invoke with the session
-
makeCredential
public Ctap2Session.CredentialData makeCredential(byte[] clientDataHash, Map<String, ?> rp, Map<String, throws IOException, com.yubico.yubikit.core.application.CommandException?> user, List<Map<String, ?>> pubKeyCredParams, @Nullable List<Map<String, ?>> excludeList, @Nullable Map<String, ?> extensions, @Nullable Map<String, ?> options, @Nullable byte[] pinUvAuthParam, @Nullable Integer pinUvAuthProtocol, @Nullable Integer enterpriseAttestation, @Nullable com.yubico.yubikit.core.application.CommandState state) This method is invoked by the host to request generation of a new credential in the authenticator.- Parameters:
clientDataHash- a SHA-256 hash of the clientDataJsonrp- a Map containing the RpEntity datauser- a Map containing the UserEntity datapubKeyCredParams- a List of Maps containing the supported credential algorithmsexcludeList- a List of Maps of already registered credentialsextensions- a Map of CTAP extension inputsoptions- a Map of CTAP optionspinUvAuthParam- a byte array derived from a pinTokenpinUvAuthProtocol- the PIN protocol version used for the pinUvAuthParamenterpriseAttestation- an enterprise attestation requeststate- an optional state object to cancel a request and handle keepalive signals- Returns:
- a new credential
- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
getAssertions
public List<Ctap2Session.AssertionData> getAssertions(String rpId, byte[] clientDataHash, @Nullable List<Map<String, ?>> allowList, @Nullable Map<String, throws IOException, com.yubico.yubikit.core.application.CommandException?> extensions, @Nullable Map<String, ?> options, @Nullable byte[] pinUvAuthParam, @Nullable Integer pinUvAuthProtocol, @Nullable com.yubico.yubikit.core.application.CommandState state) This method is used by a host to request cryptographic proof of user authentication as well as user consent to a given transaction, using a previously generated credential that is bound to the authenticator and relying party identifier.- Parameters:
rpId- the RP ID for the requestclientDataHash- a SHA-256 hash of the clientDataJsonallowList- a List of Maps of already registered credentialsextensions- a Map of CTAP extension inputsoptions- a Map of CTAP optionspinUvAuthParam- a byte array derived from a pinTokenpinUvAuthProtocol- the PIN protocol version used for the pinUvAuthParamstate- used to cancel a request and handle keepalive signals- Returns:
- a List of available assertions
- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
getInfo
public Ctap2Session.InfoData getInfo() throws IOException, com.yubico.yubikit.core.application.CommandExceptionUsing this method, platforms can request that the authenticator report a list of its supported protocol versions and extensions, its AAGUID, and other aspects of its overall capabilities. Platforms should use this information to tailor their command parameters choices.- Returns:
- an InfoData object with information about the YubiKey
- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
reset
public void reset(@Nullable com.yubico.yubikit.core.application.CommandState state) throws IOException, com.yubico.yubikit.core.application.CommandException Issues a CTAP2 reset, which will delete/invalidate all FIDO credentials.NOTE: Over USB this command must be sent within a few seconds of plugging the YubiKey in, and it requires touch confirmation.
- Parameters:
state- if needed, the state to provide control over the ongoing operation- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
selection
public void selection(@Nullable com.yubico.yubikit.core.application.CommandState state) throws IOException, com.yubico.yubikit.core.application.CommandException This command allows the platform to let a user select a certain authenticator by asking for user presence.- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
config
public Map<Integer,?> config(byte subCommand, @Nullable Map<?, ?> subCommandParams, @Nullable Integer pinUvAuthProtocol, @Nullable byte[] pinUvAuthParam) throws IOException, com.yubico.yubikit.core.application.CommandExceptionThis command is used to configure various authenticator features through the use of its subcommands.Note: Platforms MUST NOT invoke this command unless the authnrCfg option ID is present and true in the response to an authenticatorGetInfo command.
- Parameters:
subCommand- the subCommand currently being requestedsubCommandParams- a map of subCommands parameterspinUvAuthProtocol- PIN/UV protocol version chosen by the platformpinUvAuthParam- first 16 bytes of HMAC-SHA-256 of contents using pinUvAuthToken- Throws:
IOException- A communication error in the transport layer.com.yubico.yubikit.core.application.CommandException- A communication in the protocol layer.- See Also:
-
close
- Throws:
IOException
-
getVersion
public com.yubico.yubikit.core.Version getVersion()- Specified by:
getVersionin classcom.yubico.yubikit.core.application.ApplicationSession<Ctap2Session>
-
getCachedInfo
-