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.
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 |
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. |
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. |
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. |
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. |
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. |
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. |
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 |
deleteCertificateInfo(certificateName)
Delete a certificate.
Parameters:
Name | Type | Description |
---|---|---|
certificateName |
Name | The certificate name. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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.
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. |
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. |
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. |
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. |
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. |
Returns:
A promise which returns the requested
IdentityCertificate or null if not found.
- Type
- Promise | SyncPromise
getDefaultIdentity() → {Name}
Get the default identity.
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. |
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. |
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. |
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. |
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. |
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. |
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. |
Returns:
A promise that returns the generated key Name.
- Type
- Promise | SyncPromise
getTpmLocator() → {string}
Get the TPM locator associated with this storage.
Throws:
-
SecurityException if the TPM locator doesn't exist.
-
Error If getTpmLocatorPromise doesn't return a SyncPromise which is already fulfilled.
Returns:
The TPM locator.
- Type
- string
getTpmLocatorPromise(useSync) → {Promise|SyncPromise}
Get the TPM locator associated with this storage.
Parameters:
Name | Type | Description |
---|---|---|
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the TPM locator, or a
promise rejected with SecurityException if the TPM locator doesn't exist.
- Type
- Promise | SyncPromise
getTpmLocatorPromise(useSync) → {Promise|SyncPromise}
Get the TPM locator associated with this storage.
Parameters:
Name | Type | Description |
---|---|---|
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the TPM locator, or a
promise rejected with SecurityException if the TPM locator doesn't exist.
- Type
- Promise | SyncPromise
revokeIdentity() → {boolean}
Revoke the identity.
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. |
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. |
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. |
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. |
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. |
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. |
Returns:
A promise which fulfills when the default key
name is set.
- Type
- Promise | SyncPromise