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:
  • if the certificate is already installed.
    Type
    SecurityException
  • If addCertificatePromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error

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

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.
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 is added, or a promise rejected with SecurityException if the certificate is already installed.
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:
If addIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
  • if a key with the keyName already exists.
    Type
    SecurityException
  • If addKeyPromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error

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.
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 the key is added, or a promise rejected with SecurityException if a key with the keyName already exists.
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:
If deleteCertificateInfoPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
If deleteIdentityInfoPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
If deletePublicKeyInfoPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
If doesCertificateExistPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
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:
If doesIdentityExistPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
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:
If doesKeyExistPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
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

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:
If getAllKeyNamesOfIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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, allowAny) → {IdentityCertificate}

Get a certificate from the identity storage.
Parameters:
Name Type Description
certificateName Name The name of the requested certificate.
allowAny boolean If false, only a valid certificate will be returned, otherwise validity is disregarded.
Source:
Throws:
If getCertificatePromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
Returns:
The requested certificate. If not found, return null.
Type
IdentityCertificate

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

Get a certificate from the identity storage.
Parameters:
Name Type Description
certificateName Name The name of the requested certificate.
allowAny boolean If false, only a valid certificate will be returned, otherwise validity is disregarded.
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

getDefaultCertificate() → {IdentityCertificate}

Get the certificate of the default identity.
Source:
Throws:
If getDefaultCertificatePromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
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.
  • If getDefaultCertificateNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error
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.
  • If getDefaultCertificateNameForKeyPromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error
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.
  • If getDefaultIdentityPromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error
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.
  • If getDefaultKeyNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.
    Type
    Error
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:
If getKeyPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
Returns:
The DER Blob. If not found, return a Blob with a null pointer.
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 Blob with a null pointer if not found.
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:
If getNewKeyNamePromise doesn't return a SyncPromise which is already fulfilled.
Type
Error
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:
If setDefaultCertificateNameForKeyPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
If setDefaultIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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:
If setDefaultKeyNameForIdentityPromise doesn't return a SyncPromise which is already fulfilled.
Type
Error

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