android-components / mozilla.components.service.sync.logins / AsyncLoginsStorageAdapter / add

add

open fun add(login: ServerPassword): Deferred<String> (source)

Overrides AsyncLoginsStorage.add

Inserts the provided login into the database, returning it's id.

This function ignores values in metadata fields (timesUsed, timeCreated, timeLastUsed, and timePasswordChanged).

If login has an empty id field, then a GUID will be generated automatically. The format of generated guids are left up to the implementation of LoginsStorage (in practice the DatabaseLoginsStorage generates 12-character base64url (RFC 4648) encoded strings, and MemoryLoginsStorage generates strings using java.util.UUID.toString)

This will return an error result if a GUID is provided but collides with an existing record, or if the provided record is invalid (missing password, hostname, or doesn't have exactly one of formSubmitURL and httpRealm).

Exceptions

IdCollisionException - if a nonempty id is provided, and

InvalidRecordException - if the record is invalid.