Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class JdbcUserCredentialRepository

  1. Object
  2. JdbcUserCredentialRepository

ImplementsUserCredentialRepository

Credentials kept in the server’s database, in the cn1_webauthn_credential table of SecuritySchema.

A row holds nothing secret: a public key verifies and cannot sign.

A credential’s id is the table’s key through its SHA-256, so that storing one whose id is taken is refused by the key itself, whichever user has it and however many requests try at once. The signature counter is moved by one statement that names the condition it moves under, so the database decides, and of two requests carrying the same assertion one changes no row.

Constructors

public JdbcUserCredentialRepository(DataSource dataSource)

Methods

public boolean save(CredentialRecord record)Stores a new credential.
public CredentialRecord findByCredentialId(byte[] credentialId)The credential with this id, or null.
public List<CredentialRecord> findByUserId(byte[] userEntityUserId)The credentials of the user with this handle, oldest first; empty when they have none.
public boolean advance(byte[] credentialId, long signatureCount, boolean uvInitialized, boolean backupState, long lastUsed)Records a sign-in: the counter the authenticator sent, the flags it sent, and when.
public boolean delete(byte[] credentialId)Removes a credential.

Inherited methods

Constructor details

JdbcUserCredentialRepository

public JdbcUserCredentialRepository(DataSource dataSource)

Method details

save

public boolean save(CredentialRecord record)
Stores a new credential.

Returns

false, and nothing stored, when a credential with this id is there already – this user’s or another’s

findByCredentialId

public CredentialRecord findByCredentialId(byte[] credentialId)
The credential with this id, or null.

findByUserId

public List<CredentialRecord> findByUserId(byte[] userEntityUserId)
The credentials of the user with this handle, oldest first; empty when they have none.

advance

public boolean advance(byte[] credentialId, long signatureCount, boolean uvInitialized, boolean backupState, long lastUsed)

Records a sign-in: the counter the authenticator sent, the flags it sent, and when.

The counter is taken only when it is greater than the one stored – or when both are zero, which is an authenticator that keeps no counter. One statement decides and stores, so of two requests with the same assertion one is refused.

Returns

false, and nothing changed, when the counter did not advance or the credential is gone

delete

public boolean delete(byte[] credentialId)
Removes a credential.

Returns

whether there was one