public class InMemoryIdentityKeyStore extends java.lang.Object implements IdentityKeyStore
IdentityKeyStore.Direction| Constructor and Description |
|---|
InMemoryIdentityKeyStore(IdentityKeyPair identityKeyPair,
int localRegistrationId) |
| Modifier and Type | Method and Description |
|---|---|
IdentityKey |
getIdentity(SignalProtocolAddress address)
Return the saved public identity key for a remote client
|
IdentityKeyPair |
getIdentityKeyPair()
Get the local client's identity key pair.
|
int |
getLocalRegistrationId()
Return the local client's registration ID.
|
boolean |
isTrustedIdentity(SignalProtocolAddress address,
IdentityKey identityKey,
IdentityKeyStore.Direction direction)
Verify a remote client's identity key.
|
boolean |
saveIdentity(SignalProtocolAddress address,
IdentityKey identityKey)
Save a remote client's identity key
|
public InMemoryIdentityKeyStore(IdentityKeyPair identityKeyPair, int localRegistrationId)
public IdentityKeyPair getIdentityKeyPair()
IdentityKeyStoregetIdentityKeyPair in interface IdentityKeyStorepublic int getLocalRegistrationId()
IdentityKeyStoreClients should maintain a registration ID, a random number between 1 and 16380 that's generated once at install time.
getLocalRegistrationId in interface IdentityKeyStorepublic boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey)
IdentityKeyStoreStore a remote client's identity key as trusted.
saveIdentity in interface IdentityKeyStoreaddress - The address of the remote client.identityKey - The remote client's identity key.public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, IdentityKeyStore.Direction direction)
IdentityKeyStoreDetermine whether a remote client's identity is trusted. Convention is that the Signal Protocol is 'trust on first use.' This means that an identity key is considered 'trusted' if there is no entry for the recipient in the local store, or if it matches the saved key for a recipient in the local store. Only if it mismatches an entry in the local store is it considered 'untrusted.' Clients may wish to make a distinction as to how keys are trusted based on the direction of travel. For instance, clients may wish to accept all 'incoming' identity key changes, while only blocking identity key changes when sending a message.
isTrustedIdentity in interface IdentityKeyStoreaddress - The address of the remote client.identityKey - The identity key to verify.direction - The direction (sending or receiving) this identity is being used for.public IdentityKey getIdentity(SignalProtocolAddress address)
IdentityKeyStoregetIdentity in interface IdentityKeyStoreaddress - The address of the remote client