new PibKey(impl)
A PibKey provides access to a key at the second level in the PIB's
Identity-Key-Certificate hierarchy. A PibKey object has a Name (identity +
"KEY" + keyId), and contains one or more CertificateV2 objects, one of which
is set as the default certificate of this key. A certificate can be directly
accessed by getting a CertificateV2 object.
Create a PibKey which uses the impl backend implementation. This constructor
should only be called by PibKeyContainer.
Parameters:
Name | Type | Description |
---|---|---|
impl |
PibKeyImpl | An object of a subclass of PibKeyImpl. |
- Source:
Methods
(static) constructKeyName(identityName, keyId) → {Name}
Construct a key name based on the appropriate naming conventions.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The name of the identity. |
keyId |
Name.Component | The key ID name component. |
- Source:
Returns:
The constructed name as a new Name.
- Type
- Name
(static) extractIdentityFromKeyName(keyName) → {Name}
Extract the identity namespace from keyName.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
- Source:
Returns:
The identity name as a new Name.
- Type
- Name
(static) isValidKeyName(keyName) → {boolean}
Check if keyName follows the naming conventions for a key name.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
- Source:
Returns:
True if keyName follows the naming conventions, otherwise
false.
- Type
- boolean
addCertificatePromise_(certificate, useSync) → {Promise|SyncPromise}
Add the certificate. If a certificate with the same name (without implicit
digest) already exists, then overwrite the certificate. If no default
certificate for the key has been set, then set the added certificate as
default for the key. This should only be called by KeyChain.
Parameters:
Name | Type | Description |
---|---|---|
certificate |
CertificateV2 | The certificate to add. This copies the object. |
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, or a
promise rejected with Error if the name of the certificate does not match the
key name.
- Type
- Promise | SyncPromise
getCertificate(certificateName, onComplete, onError) → {CertificateV2}
Get the certificate with name certificateName.
Parameters:
Name | Type | Description |
---|---|---|
certificateName |
Name | The name of the certificate. |
onComplete |
function | (optional) This calls onComplete(certificate) with a copy of the CertificateV2. If omitted, the return value is described below. (Some database libraries only use a callback, so onComplete is required to use these.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions. |
onError |
function | (optional) If defined, then onComplete must be defined and if there is an exception, then this calls onError(exception) with the exception. If onComplete is defined but onError is undefined, then this will log any thrown exception. (Some database libraries only use a callback, so onError is required to be notified of an exception.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions. |
- Source:
Throws:
Error if certificateName does not match the key name (or if the
backend implementation instance is invalid), or Pib.Error if the certificate
does not exist. However, if onComplete and onError are defined, then if there
is an exception return undefined and call onError(exception).
Returns:
If onComplete is omitted, return a copy of the
CertificateV2. Otherwise, if onComplete is supplied then return undefined and
use onComplete as described above.
- Type
- CertificateV2
getCertificatePromise(certificateName, useSync) → {Promise|SyncPromise}
Get the certificate with name certificateName.
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 a copy of the
CertificateV2, or a promise rejected with Error if certificateName does not
match the key name (or if the backend implementation instance is invalid), or
a promise rejected with Pib.Error if the certificate does not exist.
- Type
- Promise | SyncPromise
getCertificates_() → {PibCertificateContainer}
Get the PibCertificateContainer in the PibKeyImpl. This should only be called
by KeyChain.
- Source:
Returns:
The PibCertificateContainer.
getDefaultCertificate(onComplete, onError) → {CertificateV2}
Get the default certificate for this Key.
Parameters:
Name | Type | Description |
---|---|---|
onComplete |
function | (optional) This calls onComplete(certificate) with the default CertificateV2. If omitted, the return value is described below. (Some database libraries only use a callback, so onComplete is required to use these.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions. |
onError |
function | (optional) If defined, then onComplete must be defined and if there is an exception, then this calls onError(exception) with the exception. If onComplete is defined but onError is undefined, then this will log any thrown exception. (Some database libraries only use a callback, so onError is required to be notified of an exception.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions. |
- Source:
Throws:
Error if the backend implementation instance is invalid, Pib.Error if
the default certificate does not exist. However, if onComplete and onError
are defined, then if there is an exception return undefined and call
onError(exception).
Returns:
If onComplete is omitted, return the default
CertificateV2. Otherwise, if onComplete is supplied then return undefined and
use onComplete as described above.
- Type
- CertificateV2
getDefaultCertificatePromise(useSync) → {Promise|SyncPromise}
Get the default certificate for this Key.
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 default
CertificateV2, or a promise rejected with Error if the backend implementation
instance is invalid, or a promise rejected with Pib.Error if the default
certificate does not exist.
- Type
- Promise | SyncPromise
getIdentityName() → {Name}
Get the name of the identity this key belongs to.
- Source:
Throws:
Error if the backend implementation instance is invalid.
Returns:
The name of the identity. You must not modify the Key object.
If you need to modify it, make a copy.
- Type
- Name
getKeyType() → {number}
Get the key type.
- Source:
Throws:
Error if the backend implementation instance is invalid.
Returns:
The key type as an int from the KeyType enum.
- Type
- number
getName() → {Name}
Get the key name.
- Source:
Throws:
Error if the backend implementation instance is invalid.
Returns:
The key name. You must not modify the Name object. If you need
to modify it, make a copy.
- Type
- Name
getPublicKey() → {Blob}
Get the public key encoding.
- Source:
Throws:
Error if the backend implementation instance is invalid.
Returns:
The public key encoding.
- Type
- Blob
lock_() → {PibKeyImpl}
Check the validity of the impl_ instance.
- Source:
Throws:
Error if the backend implementation instance is invalid.
Returns:
The PibKeyImpl when the instance is valid.
- Type
- PibKeyImpl
removeCertificatePromise_(certificateName, useSync) → {Promise|SyncPromise}
Remove the certificate with name certificateName. If the certificate does not
exist, do nothing. This should only be called by KeyChain.
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 fulfills when finished, or a
promise rejected with Error if certificateName does not match the key name.
- Type
- Promise | SyncPromise
setDefaultCertificatePromise_(certificateName, useSync) → {Promise|SyncPromise}
Set the existing certificate with name certificateName as the default
certificate. This should only be called by KeyChain.
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 the default
CertificateV2, or a promise rejected with Error if certificateName does not
match the key name, or a promise rejected with Pib.Error if
certificateOrCertificateName is the certificate Name and the certificate does
not exist.
- Type
- Promise | SyncPromise