OathCredential

@Serializable
data class OathCredential(val id: String = UUID.randomUUID().toString(), val userId: String? = null, val resourceId: String? = null, val issuer: String, val displayIssuer: String = issuer, val accountName: String, val displayAccountName: String = accountName, val oathType: OathType, val secret: String, val oathAlgorithm: OathAlgorithm = OathAlgorithm.SHA1, val digits: Int = 6, val period: Int = 30, val counter: Long = 0, val createdAt: Date = Date(), val imageURL: String? = null, val backgroundColor: String? = null, val policies: String? = null, var lockingPolicy: String? = null, var isLocked: Boolean = false)

Represents an OATH (TOTP/HOTP) credential. This model holds all necessary information to generate OTP codes and identify the credential.

Constructors

Link copied to clipboard
constructor(id: String = UUID.randomUUID().toString(), userId: String? = null, resourceId: String? = null, issuer: String, displayIssuer: String = issuer, accountName: String, displayAccountName: String = accountName, oathType: OathType, secret: String, oathAlgorithm: OathAlgorithm = OathAlgorithm.SHA1, digits: Int = 6, period: Int = 30, counter: Long = 0, createdAt: Date = Date(), imageURL: String? = null, backgroundColor: String? = null, policies: String? = null, lockingPolicy: String? = null, isLocked: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The account name (username) associated with this credential.

Link copied to clipboard
@Transient
val algorithm: String

The HMAC algorithm used as String.

Link copied to clipboard
val backgroundColor: String? = null

Optional background color for the credential.

Link copied to clipboard
val counter: Long = 0

For HOTP, the counter value used to generate the next code.

Link copied to clipboard
@Serializable(with = DateSerializer::class)
val createdAt: Date

The timestamp when this credential was created.

Link copied to clipboard
val digits: Int = 6

The number of digits in the generated codes.

Link copied to clipboard

The account name (username) associated with this credential, editable by the user.

Link copied to clipboard

The name of the issuer for this credential, editable by the user.

Link copied to clipboard
val id: String

Unique identifier for the credential (local ID).

Link copied to clipboard
val imageURL: String? = null

Optional URL for the issuer's logo or image.

Link copied to clipboard
@EncodeDefault
var isLocked: Boolean

Indicates whether the credential is locked.

Link copied to clipboard

The name of the issuer for this credential.

Link copied to clipboard

Optional lName of the Policy locking the credential.

Link copied to clipboard

The HMAC algorithm used (SHA1, SHA256, SHA512).

Link copied to clipboard
@Serializable(with = OathTypeSerializer::class)
val oathType: OathType

The type of credential (TOTP or HOTP).

Link copied to clipboard
val period: Int = 30

For TOTP, the time period in seconds for which a code is valid.

Link copied to clipboard
val policies: String? = null

Optional Authenticator Policies in a JSON String format for the credential.

Link copied to clipboard
val resourceId: String? = null

Server-side device identifier.

Link copied to clipboard

The shared secret key used to generate OTP codes.

Link copied to clipboard
@Transient
val type: String

The type of credential (TOTP or HOTP) as String.

Link copied to clipboard
val userId: String? = null

User identifier on the server.

Functions

Link copied to clipboard
fun lockCredential(policyName: String)

Lock this credential due to policy violations.

Link copied to clipboard
fun toJson(): String

Converts this credential to a JSON string representation.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of this credential.

Link copied to clipboard
suspend fun toUri(): String

Convert this credential to a URI string.

Link copied to clipboard

Unlock this credential. Clears any locking policy information.