Package net.shibboleth.idp.plugin.authn.webauthn.storage

# Class CredentialRecord

java.lang.Object
net.shibboleth.idp.plugin.authn.webauthn.storage.CredentialRecord

@ThreadSafe @Immutable public final class CredentialRecord extends Object
A credential record used to hold a registered credential. Can be serialized in and out of storage.

Equality is determined by comparing the wrapped `credential`.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`CredentialRecord.Builder`
Builder.
`static interface`
`CredentialRecord.IBuildStage`
Optional builder stage.
`static interface`
`CredentialRecord.ICredentialStage`
Builder stage.
`static interface`
`CredentialRecord.IRegistrationTimeStage`
Builder stage.
`static interface`
`CredentialRecord.ITransportsStage`
Builder stage.
`static interface`
`CredentialRecord.IUserIdentityStage`
Builder stage.
`static interface`
`CredentialRecord.IUsernameStage`
Builder stage.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final byte[]`
`aaguid`
The AAGUID of the authenticator that created this credential.
`private final com.yubico.webauthn.RegisteredCredential`
`credential`
The credential to register.
`private final String`
`credentialNickname`
An optional nickname of the credential.
`private final Optional<Boolean>`
`discoverable`
Is the credential a discoverable type (passkey).
`private final Instant`
`lastUsedTime`
The time the credential was last used for authentication.
`private final Instant`
`registrationTime`
The time the registration took place.
`private final SortedSet<com.yubico.webauthn.data.AuthenticatorTransport>`
`transports`
The set of `transports` the authenticator can use to communicate with the client.
`private final com.yubico.webauthn.data.UserIdentity`
`userIdentity`
The users identity.
`private final String`
`username`
The username of the user to the IdP.
`private final boolean`
`userVerified`
Was the user verified during registration.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`CredentialRecord(CredentialRecord.Builder builder)`
Builder constructor.

## Method Summary

Modifier and Type
Method
Description
`static CredentialRecord.IUserIdentityStage`
`builder()`
Builder stage.
`boolean`
`equals(Object obj)`
`byte[]`
`getAaguid()`
Get the AAGUID of the authenticator that created this credential.
`com.yubico.webauthn.RegisteredCredential`
`getCredential()`
Get the registered credential.
`String`
`getCredentialIdBase64()`
Get the credential ID as a base64 encoded string.
`String`
`getCredentialIdBase64Url()`
Get the credential ID as a base64URL encoded string.
`String`
`getCredentialIdHex()`
Get the credential ID as a Hex encoded string.
`Instant`
`getLastUsedTime()`
Get the time the credential was last used for authentication.
`String`
`getNickname()`
Get the nickname of this credential.
`Instant`
`getRegistrationTime()`
Get the time the registration took place.
`SortedSet<com.yubico.webauthn.data.AuthenticatorTransport>`
`getTransports()`
Get the set of `transports` the authenticator can use to communicate with the client.
`com.yubico.webauthn.data.UserIdentity`
`getUserIdentity()`
Get the identity of the user this credential has been registered for.
`String`
`getUsername()`
Get the username of the user to the IdP.
`String`
`getWebAuthnUserName()`
Get the WebAuthn user.name of the user identity registered.
`int`
`hashCode()`
`Optional<Boolean>`
`isDiscoverable()`
Is the created credential discoverable?
`boolean`
`isUserVerified()`
Was user verification performed during registration?
`CredentialRecord.Builder`
`toBuilder()`
Get a builder based on this record which can be updated until it is finalised and built.
`com.yubico.webauthn.data.PublicKeyCredentialDescriptor`
`toPublicKeyCredentialDescriptor()`
Convert the credential registration into a `PublicKeyCredentialDescriptor`.
`CredentialRecord`
`withCredential(com.yubico.webauthn.RegisteredCredential newRegisteredCred)`
Deprecated, for removal: This API element is subject to removal in a future version.
use `toBuilder()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### userIdentity

@Nonnull private final com.yubico.webauthn.data.UserIdentity userIdentity
The users identity.

### username

@Nonnull private final String username
The username of the user to the IdP.

### credentialNickname

@Nullable private final String credentialNickname
An optional nickname of the credential.

### transports

@Nonnull @Unmodifiable @NonnullElements private final SortedSet<com.yubico.webauthn.data.AuthenticatorTransport> transports
The set of `transports` the authenticator can use to communicate with the client.

### registrationTime

@Nonnull private final Instant registrationTime
The time the registration took place.

### discoverable

@Nonnull private final Optional<Boolean> discoverable
Is the credential a discoverable type (passkey). Empty if not known.

### credential

@Nonnull @Unmodifiable @NonnullElements private final com.yubico.webauthn.RegisteredCredential credential
The credential to register.

### aaguid

@Nullable private final byte[] aaguid
The AAGUID of the authenticator that created this credential.

### userVerified

private final boolean userVerified
Was the user verified during registration.

### lastUsedTime

@Nullable private final Instant lastUsedTime
The time the credential was last used for authentication.

## Constructor Details

### CredentialRecord

private CredentialRecord(CredentialRecord.Builder builder)
Builder constructor.

Parameters:
  `builder` - the builder

## Method Details

### isUserVerified

public boolean isUserVerified()
Was user verification performed during registration?

Returns:
  true if user registration was performed, false otherwise

### isDiscoverable

@Nonnull public Optional<Boolean> isDiscoverable()
Is the created credential discoverable?

Returns:
  true if the credential is discoverable, false if it isn't, empty if unknown.

### getNickname

@Nullable public String getNickname()
Get the nickname of this credential.

Returns:
  the nickname

### getRegistrationTime

@Nonnull public Instant getRegistrationTime()
Get the time the registration took place.

Returns:
  the time of registration

### getUsername

@Nonnull public String getUsername()
Get the username of the user to the IdP.

Returns:
  the user's username

### getWebAuthnUserName

@Nonnull public String getWebAuthnUserName()
Get the WebAuthn user.name of the user identity registered.

Returns:
  the name of the user identity

### getUserIdentity

@Nonnull public com.yubico.webauthn.data.UserIdentity getUserIdentity()
Get the identity of the user this credential has been registered for.

Returns:
  the users identity

### getCredential

@Nonnull public com.yubico.webauthn.RegisteredCredential getCredential()
Get the registered credential.

Returns:
  the registered credential

### getTransports

@Nonnull @Unmodifiable @NonnullElements public SortedSet<com.yubico.webauthn.data.AuthenticatorTransport> getTransports()
Get the set of `transports` the authenticator can use to communicate with the client.

Returns:
  the set of transports the authenticator can use to communicate with the client

### getAaguid

@Nullable public byte[] getAaguid()
Get the AAGUID of the authenticator that created this credential. This is optional, for example if attestation is not requested.

Returns:
  the aaguid

### getLastUsedTime

@Nullable public Instant getLastUsedTime()
Get the time the credential was last used for authentication.

Returns:
  the last used time of the credential.
Since:
  1.1.0

### getCredentialIdBase64Url

public String getCredentialIdBase64Url()
Get the credential ID as a base64URL encoded string.

Returns:
  the credential ID base64URL encoded

### getCredentialIdBase64

@Nullable public String getCredentialIdBase64()
Get the credential ID as a base64 encoded string.

Returns:
  the credential ID base64URL encoded

### getCredentialIdHex

@Nullable public String getCredentialIdHex()
Get the credential ID as a Hex encoded string.

Returns:
  the credential ID Hex encoded

### toBuilder

public CredentialRecord.Builder toBuilder()
Get a builder based on this record which can be updated until it is finalised and built.

Returns:
  the builder

### toPublicKeyCredentialDescriptor

@Nullable public com.yubico.webauthn.data.PublicKeyCredentialDescriptor toPublicKeyCredentialDescriptor()
Convert the credential registration into a `PublicKeyCredentialDescriptor`.

Returns:
  the created `PublicKeyCredentialDescriptor`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### withCredential

@Deprecated(since="1.1.0", forRemoval=true) public CredentialRecord withCredential(@Nonnull com.yubico.webauthn.RegisteredCredential newRegisteredCred)
Deprecated, for removal: This API element is subject to removal in a future version.
use `toBuilder()`
Copy this instance into a new credential registration instance replacing he registered credential with that given.

Parameters:
  `newRegisteredCred` - the new credential
Returns:
  a new `CredentialRecord` instance

### builder

public static CredentialRecord.IUserIdentityStage builder()
Builder stage.

Returns:
  the next stage