Table of Contents

Class ApplicationSession

Namespace
Yubico.YubiKey
Assembly
Yubico.YubiKey.dll

Abstract base class for sessions with a YubiKey. This class is used to wrap the IYubiKeyConnection and provide a way of interacting with the connection that is more convenient for most users.

public abstract class ApplicationSession
Inheritance
object
ApplicationSession
Derived

Constructors

ApplicationSession(ILogger, IYubiKeyDevice, YubiKeyApplication, ScpKeyParameters?)

Initializes a new instance of the ApplicationSession class with logging, YubiKey device, application, and optional SCP key parameters.

protected ApplicationSession(ILogger logger, IYubiKeyDevice device, YubiKeyApplication application, ScpKeyParameters? keyParameters)

Parameters

logger ILogger

The logger instance used for logging information.

device IYubiKeyDevice

The YubiKey device to establish a session with.

application YubiKeyApplication

The specific YubiKey application to connect to.

keyParameters ScpKeyParameters

The optional parameters for an SCP connection.

Exceptions

ArgumentNullException

Thrown when the device is null.

InvalidOperationException

Thrown when the Yubikey does not support the requested SCP connection.

Properties

Application

The specific YubiKey application to connect to.

public YubiKeyApplication Application { get; }

Property Value

YubiKeyApplication

Connection

The object that represents the connection to the YubiKey. Most applications will ignore this, but it can be used to call Commands directly.

public IYubiKeyConnection Connection { get; protected set; }

Property Value

IYubiKeyConnection

KeyParameters

Gets the parameters used for establishing a Secure Channel Protocol (SCP) connection.

public ScpKeyParameters? KeyParameters { get; }

Property Value

ScpKeyParameters

Logger

The logger instance used for logging information.

protected ILogger Logger { get; }

Property Value

ILogger

YubiKey

The YubiKey device to establish a session with.

protected IYubiKeyDevice YubiKey { get; }

Property Value

IYubiKeyDevice

Methods

Dispose()

When the ApplicationSession object goes out of scope, this method is called. It will close the session. The most important function of closing a session is to "un-authenticate" the management key and "un-verify" the PIN.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

GetConnection(IYubiKeyDevice, YubiKeyApplication, ScpKeyParameters?)

protected IYubiKeyConnection GetConnection(IYubiKeyDevice yubiKey, YubiKeyApplication application, ScpKeyParameters? keyParameters)

Parameters

yubiKey IYubiKeyDevice
application YubiKeyApplication
keyParameters ScpKeyParameters

Returns

IYubiKeyConnection