public class KeyRing extends Object implements IPublicKeySource
IndexedECPrivateKey
. This has a helper methods to return the latest active key of each type (signing or
derivation). That will return the active key with the largest index.Constructor and Description |
---|
KeyRing()
Default constructor.
|
KeyRing(ArrayList<IndexedECPrivateKey> derivationKeys,
ArrayList<IndexedECPrivateKey> signingKeys)
Create a key ring with the given derivation and signing keys.
|
KeyRing(UUID userId)
Create a key ring with the given user id.
|
KeyRing(UUID userId,
ArrayList<IndexedECPrivateKey> derivationKeys,
ArrayList<IndexedECPrivateKey> signingKeys)
Create a key ring with the give user id, derivation keys and signing keys.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
See if this object equals another
|
IndexedECPrivateKey |
findPrivateKeyByIndex(int index,
KeyType type)
Finds the private key with the matching index and type.
|
IndexedECPublicKey |
getByIndex(UUID userId,
KeyType type,
int index)
This gets the public key that match the user ID, type and inde.
|
ArrayList<IndexedECPrivateKey> |
getDerivationKeys()
Get the list of
IndexedECPrivateKey derivation keys for this KeyRing . |
IndexedECPublicKey |
getLatestActive(UUID userId,
KeyType type)
This gets the latest active public key that match the user ID and type.
|
ArrayList<IndexedECPrivateKey> |
getSigningKeys()
Get the list of
IndexedECPrivateKey signing keys for this KeyRing . |
UUID |
getUserId()
Get the user's id for this
KeyRing . |
int |
hashCode()
Get the unique hash code for this object.
|
IndexedECPrivateKey |
latestActiveDerivationKey()
Get the active
IndexedECPrivateKey derivation key with the largest index for this KeyRing . |
IndexedECPrivateKey |
latestActiveSigningKey()
Get the active
IndexedECPrivateKey signing key with the largest index for this KeyRing . |
void |
setUserId(UUID userId)
Set the user's id for this
KeyRing . |
public KeyRing(UUID userId, ArrayList<IndexedECPrivateKey> derivationKeys, ArrayList<IndexedECPrivateKey> signingKeys)
userId
- the UUID
of the userderivationKeys
- a list of derivation keys (see IndexedECPrivateKey
)signingKeys
- a list of signing keys (see IndexedECPrivateKey
)public KeyRing() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
This will create one random active signing and derivation key with an index of 0 and a null user ID.
NoSuchAlgorithmException
- thrown if the JCE does not support the algorithm of the keyInvalidAlgorithmParameterException
- thrown if the parameters of the algorithm are not supportedpublic KeyRing(UUID userId) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
userId
- the UUID
of the userNoSuchAlgorithmException
- thrown if the JCE does not support the algorithm of the keyInvalidAlgorithmParameterException
- thrown if the parameters of the algorithm are not supportedpublic KeyRing(ArrayList<IndexedECPrivateKey> derivationKeys, ArrayList<IndexedECPrivateKey> signingKeys)
derivationKeys
- a list of derivation keys (see IndexedECPrivateKey
)signingKeys
- a list of signing keys (see IndexedECPrivateKey
)public boolean equals(Object obj)
public IndexedECPrivateKey findPrivateKeyByIndex(int index, KeyType type)
index
- the index to findtype
- the key type to findpublic IndexedECPublicKey getByIndex(UUID userId, KeyType type, int index)
IPublicKeySource
getByIndex
in interface IPublicKeySource
userId
- the user id of the key ownertype
- the KeyType
of the keyindex
- the index of the keyIndexedECPublicKey
for the user of the specified KeyType
and indexpublic ArrayList<IndexedECPrivateKey> getDerivationKeys()
IndexedECPrivateKey
derivation keys for this KeyRing
.IndexedECPrivateKey
derivation keys for this KeyRing
public IndexedECPublicKey getLatestActive(UUID userId, KeyType type)
IPublicKeySource
NOTE: if there is not an active key null will be returned.
getLatestActive
in interface IPublicKeySource
userId
- the user's IDtype
- the KeyType
of public keyKeyType
public ArrayList<IndexedECPrivateKey> getSigningKeys()
IndexedECPrivateKey
signing keys for this KeyRing
.IndexedECPrivateKey
signing keys for this KeyRing
public UUID getUserId()
KeyRing
.KeyRing
public void setUserId(UUID userId)
KeyRing
.userId
- the user's id for this KeyRing
public int hashCode()
public IndexedECPrivateKey latestActiveDerivationKey()
IndexedECPrivateKey
derivation key with the largest index for this KeyRing
.IndexedECPrivateKey
derivation key with the largest index for this KeyRing
public IndexedECPrivateKey latestActiveSigningKey()
IndexedECPrivateKey
signing key with the largest index for this KeyRing
.IndexedECPrivateKey
signing key with the largest index for this KeyRing
Copyright © 2021. All rights reserved.