Class InMemoryIdentityKeyStore
- java.lang.Object
-
- org.signal.libsignal.protocol.state.impl.InMemoryIdentityKeyStore
-
- All Implemented Interfaces:
IdentityKeyStore
public class InMemoryIdentityKeyStore extends java.lang.Object implements IdentityKeyStore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.signal.libsignal.protocol.state.IdentityKeyStore
IdentityKeyStore.Direction
-
-
Constructor Summary
Constructors Constructor Description InMemoryIdentityKeyStore(IdentityKeyPair identityKeyPair, int localRegistrationId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IdentityKeygetIdentity(SignalProtocolAddress address)Return the saved public identity key for a remote clientIdentityKeyPairgetIdentityKeyPair()Get the local client's identity key pair.intgetLocalRegistrationId()Return the local client's registration ID.booleanisTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, IdentityKeyStore.Direction direction)Verify a remote client's identity key.booleansaveIdentity(SignalProtocolAddress address, IdentityKey identityKey)Save a remote client's identity key
-
-
-
Constructor Detail
-
InMemoryIdentityKeyStore
public InMemoryIdentityKeyStore(IdentityKeyPair identityKeyPair, int localRegistrationId)
-
-
Method Detail
-
getIdentityKeyPair
public IdentityKeyPair getIdentityKeyPair()
Description copied from interface:IdentityKeyStoreGet the local client's identity key pair.- Specified by:
getIdentityKeyPairin interfaceIdentityKeyStore- Returns:
- The local client's persistent identity key pair.
-
getLocalRegistrationId
public int getLocalRegistrationId()
Description copied from interface:IdentityKeyStoreReturn the local client's registration ID.Clients should maintain a registration ID, a random number between 1 and 16380 that's generated once at install time.
- Specified by:
getLocalRegistrationIdin interfaceIdentityKeyStore- Returns:
- the local client's registration ID.
-
saveIdentity
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey)
Description copied from interface:IdentityKeyStoreSave a remote client's identity keyStore a remote client's identity key as trusted.
- Specified by:
saveIdentityin interfaceIdentityKeyStore- Parameters:
address- The address of the remote client.identityKey- The remote client's identity key.- Returns:
- True if the identity key replaces a previous identity, false if not
-
isTrustedIdentity
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, IdentityKeyStore.Direction direction)
Description copied from interface:IdentityKeyStoreVerify a remote client's identity key.Determine 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.
- Specified by:
isTrustedIdentityin interfaceIdentityKeyStore- Parameters:
address- The address of the remote client.identityKey- The identity key to verify.direction- The direction (sending or receiving) this identity is being used for.- Returns:
- true if trusted, false if untrusted.
-
getIdentity
public IdentityKey getIdentity(SignalProtocolAddress address)
Description copied from interface:IdentityKeyStoreReturn the saved public identity key for a remote client- Specified by:
getIdentityin interfaceIdentityKeyStore- Parameters:
address- The address of the remote client- Returns:
- The public identity key, or null if absent
-
-