Class: IdentityStorage

IdentityStorage

new IdentityStorage()

IdentityStorage is a base class for the storage of identity, public keys and certificates. Private keys are stored in PrivateKeyStorage. This is an abstract base class. A subclass must implement the methods.
Source:

Methods

activateKey(keyName)

Activate a key. If a key is marked as inactive, its private part will not be used in packet signing.
Parameters:
Name Type Description
keyName Name name of the key
Source:

addCertificate(certificate)

Add a certificate to the identity storage.
Parameters:
Name Type Description
certificate IdentityCertificate The certificate to be added. This makes a copy of the certificate.
Source:
Throws:
  • SecurityException if the certificate is already installed.
  • Error If addCertificatePromise doesn't return a SyncPromise which is already fulfilled.

addCertificatePromise(certificate, useSync) → {Promise|SyncPromise}

Add a certificate to the identity storage. Also call addKey to ensure that the certificate key exists. If the certificate is already installed, don't replace it.
Parameters:
Name Type Description
certificate IdentityCertificate The certificate to be added. This makes a copy of the certificate.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when finished.
Type
Promise | SyncPromise

addIdentity(identityName)

Add a new identity. Do nothing if the identity already exists.
Parameters:
Name Type Description
identityName Name The identity name to be added.
Source:
Throws:
Error If addIdentityPromise doesn't return a SyncPromise which is already fulfilled.

addIdentityPromise(identityName, useSync) → {Promise|SyncPromise}

Add a new identity. Do nothing if the identity already exists.
Parameters:
Name Type Description
identityName Name The identity name to be added.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the identity is added.
Type
Promise | SyncPromise

addKey(keyName, keyType, publicKeyDer)

Add a public key to the identity storage. Also call addIdentity to ensure that the identityName for the key exists.
Parameters:
Name Type Description
keyName Name The name of the public key to be added.
keyType number Type of the public key to be added from KeyType, such as KeyType.RSA..
publicKeyDer Blob A blob of the public key DER to be added.
Source:
Throws:
  • SecurityException if a key with the keyName already exists.
  • Error If addKeyPromise doesn't return a SyncPromise which is already fulfilled.

addKeyPromise(keyName, keyType, publicKeyDer, useSync) → {Promise|SyncPromise}

Add a public key to the identity storage. Also call addIdentity to ensure that the identityName for the key exists. However, if the key already exists, do nothing.
Parameters:
Name Type Description
keyName Name The name of the public key to be added.
keyType number Type of the public key to be added from KeyType, such as KeyType.RSA..
publicKeyDer Blob A blob of the public key DER to be added.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when complete.
Type
Promise | SyncPromise

deactivateKey(keyName)

Deactivate a key. If a key is marked as inactive, its private part will not be used in packet signing.
Parameters:
Name Type Description
keyName Name name of the key
Source:

deleteCertificateInfo(certificateName)

Delete a certificate.
Parameters:
Name Type Description
certificateName Name The certificate name.
Source:
Throws:
Error If deleteCertificateInfoPromise doesn't return a SyncPromise which is already fulfilled.

deleteCertificateInfoPromise(certificateName, useSync) → {Promise|SyncPromise}

Delete a certificate.
Parameters:
Name Type Description
certificateName Name The certificate name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the certificate info is deleted.
Type
Promise | SyncPromise

deleteIdentityInfo(identityName)

Delete an identity and related public keys and certificates.
Parameters:
Name Type Description
identityName Name The identity name.
Source:
Throws:
Error If deleteIdentityInfoPromise doesn't return a SyncPromise which is already fulfilled.

deleteIdentityInfoPromise(identityName, useSync) → {Promise|SyncPromise}

Delete an identity and related public keys and certificates.
Parameters:
Name Type Description
identityName Name The identity name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the identity info is deleted.
Type
Promise | SyncPromise

deletePublicKeyInfo(keyName)

Delete a public key and related certificates.
Parameters:
Name Type Description
keyName Name The key name.
Source:
Throws:
Error If deletePublicKeyInfoPromise doesn't return a SyncPromise which is already fulfilled.

deletePublicKeyInfoPromise(keyName, useSync) → {Promise|SyncPromise}

Delete a public key and related certificates.
Parameters:
Name Type Description
keyName Name The key name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the public key info is deleted.
Type
Promise | SyncPromise

doesCertificateExist(certificateName) → {boolean}

Check if the specified certificate already exists.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
Source:
Throws:
Error If doesCertificateExistPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
true if the certificate exists, otherwise false.
Type
boolean

doesCertificateExistPromise(certificateName, useSync) → {Promise|SyncPromise}

Check if the specified certificate already exists.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns true if the certificate exists.
Type
Promise | SyncPromise

doesIdentityExist(identityName) → {boolean}

Check if the specified identity already exists.
Parameters:
Name Type Description
identityName Name The identity name.
Source:
Throws:
Error If doesIdentityExistPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
true if the identity exists, otherwise false.
Type
boolean

doesIdentityExistPromise(identityName, useSync) → {Promise|SyncPromise}

Check if the specified identity already exists.
Parameters:
Name Type Description
identityName Name The identity name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns true if the identity exists.
Type
Promise | SyncPromise

doesKeyExist(keyName) → {boolean}

Check if the specified key already exists.
Parameters:
Name Type Description
keyName Name The name of the key.
Source:
Throws:
Error If doesKeyExistPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
true if the key exists, otherwise false.
Type
boolean

doesKeyExistPromise(keyName, useSync) → {Promise|SyncPromise}

Check if the specified key already exists.
Parameters:
Name Type Description
keyName Name The name of the key.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns true if the key exists.
Type
Promise | SyncPromise

getAllCertificateNamesOfKeyPromise(keyName, nameList, isDefault, useSync) → {Promise}

Append all the certificate names of a particular key name to the nameList.
Parameters:
Name Type Description
keyName Name The key name to search for.
nameList Array.<Name> Append result names to nameList.
isDefault boolean If true, add only the default certificate name. If false, add only the non-default certificate names.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the names are added to nameList.
Type
Promise

getAllIdentitiesPromise(nameList, isDefault, useSync) → {Promise}

Append all the identity names to the nameList.
Parameters:
Name Type Description
nameList Array.<Name> Append result names to nameList.
isDefault boolean If true, add only the default identity name. If false, add only the non-default identity names.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the names are added to nameList.
Type
Promise

getAllKeyNamesOfIdentity(identityName, nameList, isDefault)

Append all the key names of a particular identity to the nameList.
Parameters:
Name Type Description
identityName Name The identity name to search for.
nameList Array.<Name> Append result names to nameList.
isDefault boolean If true, add only the default key name. If false, add only the non-default key names.
Source:
Throws:
Error If getAllKeyNamesOfIdentityPromise doesn't return a SyncPromise which is already fulfilled.

getAllKeyNamesOfIdentityPromise(identityName, nameList, isDefault, useSync) → {Promise|SyncPromise}

Append all the key names of a particular identity to the nameList.
Parameters:
Name Type Description
identityName Name The identity name to search for.
nameList Array.<Name> Append result names to nameList.
isDefault boolean If true, add only the default key name. If false, add only the non-default key names.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the names are added to nameList.
Type
Promise | SyncPromise

getCertificate(certificateName) → {IdentityCertificate}

Get a certificate from the identity storage.
Parameters:
Name Type Description
certificateName Name The name of the requested certificate.
Source:
Throws:
  • SecurityException if the certificate doesn't exist.
  • Error If getCertificatePromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The requested certificate.
Type
IdentityCertificate

getCertificatePromise(certificateName, useSync) → {Promise|SyncPromise}

Get a certificate from the identity storage.
Parameters:
Name Type Description
certificateName Name The name of the requested certificate.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the requested IdentityCertificate, or a promise rejected with SecurityException if the certificate doesn't exist.
Type
Promise | SyncPromise

getDefaultCertificate() → {IdentityCertificate}

Get the certificate of the default identity.
Source:
Throws:
Error If getDefaultCertificatePromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The requested certificate. If not found, return null.
Type
IdentityCertificate

getDefaultCertificateNameForIdentity(identityName) → {Name}

Get the default certificate name for the specified identity.
Parameters:
Name Type Description
identityName Name The identity name.
Source:
Throws:
  • SecurityException if the default key name for the identity is not set or the default certificate name for the key name is not set.
  • Error If getDefaultCertificateNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The default certificate name.
Type
Name

getDefaultCertificateNameForIdentityPromise(identityName, useSync) → {Promise|SyncPromise}

Get the default certificate name for the specified identity.
Parameters:
Name Type Description
identityName Name The identity name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the default certificate Name, or a promise rejected with SecurityException if the default key name for the identity is not set or the default certificate name for the key name is not set.
Type
Promise | SyncPromise

getDefaultCertificateNameForKey(keyName) → {Name}

Get the default certificate name for the specified key.
Parameters:
Name Type Description
keyName Name The key name.
Source:
Throws:
  • SecurityException if the default certificate name for the key name is not set.
  • Error If getDefaultCertificateNameForKeyPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The default certificate name.
Type
Name

getDefaultCertificateNameForKeyPromise(keyName, useSync) → {Promise|SyncPromise}

Get the default certificate name for the specified key.
Parameters:
Name Type Description
keyName Name The key name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the default certificate Name, or a promise rejected with SecurityException if the default certificate name for the key name is not set.
Type
Promise | SyncPromise

getDefaultCertificatePromise(useSync) → {Promise|SyncPromise}

Get the certificate of the default identity.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the requested IdentityCertificate or null if not found.
Type
Promise | SyncPromise

getDefaultIdentity() → {Name}

Get the default identity.
Source:
Throws:
  • SecurityException if the default identity is not set.
  • Error If getDefaultIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The name of default identity.
Type
Name

getDefaultIdentityPromise(useSync) → {Promise|SyncPromise}

Get the default identity.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the Name of default identity, or a promise rejected with SecurityException if the default identity is not set.
Type
Promise | SyncPromise

getDefaultKeyNameForIdentity(identityName) → {Name}

Get the default key name for the specified identity.
Parameters:
Name Type Description
identityName Name The identity name.
Source:
Throws:
  • SecurityException if the default key name for the identity is not set.
  • Error If getDefaultKeyNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The default key name.
Type
Name

getDefaultKeyNameForIdentityPromise(identityName, useSync) → {Promise|SyncPromise}

Get the default key name for the specified identity.
Parameters:
Name Type Description
identityName Name The identity name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the default key Name, or a promise rejected with SecurityException if the default key name for the identity is not set.
Type
Promise | SyncPromise

getKey(keyName) → {Blob}

Get the public key DER blob from the identity storage.
Parameters:
Name Type Description
keyName Name The name of the requested public key.
Source:
Throws:
  • SecurityException if the key doesn't exist.
  • Error If getKeyPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The DER Blob.
Type
Blob

getKeyPromise(keyName, useSync) → {Promise|SyncPromise}

Get the public key DER blob from the identity storage.
Parameters:
Name Type Description
keyName Name The name of the requested public key.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which returns the DER Blob, or a promise rejected with SecurityException if the key doesn't exist.
Type
Promise | SyncPromise

getNewKeyName(identityName, useKsk) → {Name}

Generate a name for a new key belonging to the identity.
Parameters:
Name Type Description
identityName Name The identity name.
useKsk boolean If true, generate a KSK name, otherwise a DSK name.
Source:
Throws:
Error If getNewKeyNamePromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The generated key name.
Type
Name

getNewKeyNamePromise(identityName, useKsk, useSync) → {Promise|SyncPromise}

Generate a name for a new key belonging to the identity.
Parameters:
Name Type Description
identityName Name The identity name.
useKsk boolean If true, generate a KSK name, otherwise a DSK name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise that returns the generated key Name.
Type
Promise | SyncPromise

revokeIdentity() → {boolean}

Revoke the identity.
Source:
Returns:
true if the identity was revoked, false if not.
Type
boolean

setDefaultCertificateNameForKey(keyName, certificateName)

Set the default key name for the specified identity.
Parameters:
Name Type Description
keyName Name The key name.
certificateName Name The certificate name.
Source:
Throws:
Error If setDefaultCertificateNameForKeyPromise doesn't return a SyncPromise which is already fulfilled.

setDefaultCertificateNameForKeyPromise(keyName, certificateName, useSync) → {Promise|SyncPromise}

Set the default key name for the specified identity.
Parameters:
Name Type Description
keyName Name The key name.
certificateName Name The certificate name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the default certificate name is set.
Type
Promise | SyncPromise

setDefaultIdentity(identityName)

Set the default identity. If the identityName does not exist, then clear the default identity so that getDefaultIdentity() throws an exception.
Parameters:
Name Type Description
identityName Name The default identity name.
Source:
Throws:
Error If setDefaultIdentityPromise doesn't return a SyncPromise which is already fulfilled.

setDefaultIdentityPromise(identityName, useSync) → {Promise|SyncPromise}

Set the default identity. If the identityName does not exist, then clear the default identity so that getDefaultIdentity() throws an exception.
Parameters:
Name Type Description
identityName Name The default identity name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the default identity is set.
Type
Promise | SyncPromise

setDefaultKeyNameForIdentity(keyName, identityNameCheck)

Set a key as the default key of an identity. The identity name is inferred from keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
identityNameCheck Name (optional) The identity name to check that the keyName contains the same identity name. If an empty name, it is ignored.
Source:
Throws:
Error If setDefaultKeyNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.

setDefaultKeyNameForIdentityPromise(keyName, identityNameCheck, useSync) → {Promise|SyncPromise}

Set a key as the default key of an identity. The identity name is inferred from keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
identityNameCheck Name (optional) The identity name to check that the keyName contains the same identity name. If an empty name, it is ignored.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise which fulfills when the default key name is set.
Type
Promise | SyncPromise