YubiKeyResponse Class
Namespace: Yubico.YubiKey Assembly: Yubico.YubiKey.dllBase class for all YubiKey responses.
public class YubiKeyResponse : Object, IYubiKeyResponse
Implements
Remarks
This base class is primarily responsible for mapping YubiKey specific status words to more generic constructs like ResponseStatus and exceptions.
This class can also be overridden to customize error handling if a certain application or command requires special casing.
If the subtype needs to change the mappings associated with an existing status code, it should override StatusCodeMap. For example:
public class MyResponse : YubiKeyResponse
{
// MyResponse has custom definitions for what certain StatusWord
// values mean. It only has to override this map, providing
// the new values. It calls the base method so that any unknown
// values are passed through, potentially being "understood"
// by types MyResponse inherited from.
protected override ResponseStatusPair StatusCodeMap =>
StatusWord switch
{
// Add new maps or override existing ones here
_ => base.StatusCodeMap,
};
public MyResponse(ResponseApdu responseApdu) : base(responseApdu)
{
}
}
StatusCodeMap can also be overridden if the subtype introduces
a new status code. This typically happens when the
ResponseApdu.Data
is actually an encoded message which
contains its own status code.
Constructors
Name | Description |
---|---|
YubiKeyResponse(ResponseApdu) | Initializes a new instance of the YubiKeyResponse class. |
Properties
Name | Description |
---|---|
ResponseApdu | The APDU returned by the YubiKey. |
Status | An application independent status. |
StatusCodeMap | Retrieves the details describing the processing state. |
StatusMessage | A short textual description of the status. |
StatusWord | The application specific status word. |
Methods
Name | Description |
---|---|
ToString() |