diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-03-04 18:49:20 -0800 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-03-04 18:49:20 -0800 |
commit | 7262e6970b86fe0a23ee48afca7bba37bcad1cdf (patch) | |
tree | e216b2b2895647bf02a1e39b365c8daa6a44ae37 /tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java | |
parent | af48198d9c683bed0545eb9bf8469a6dccf2cdd3 (diff) |
Move in memory data structures into project.
Diffstat (limited to 'tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java')
-rw-r--r-- | tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java b/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java deleted file mode 100644 index 9f452d6d..00000000 --- a/tests/src/test/java/org/whispersystems/libaxolotl/InMemorySignedPreKeyStore.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.whispersystems.libaxolotl; - -import org.whispersystems.libaxolotl.state.SignedPreKeyRecord; -import org.whispersystems.libaxolotl.state.SignedPreKeyStore; - -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class InMemorySignedPreKeyStore implements SignedPreKeyStore { - - private final Map<Integer, byte[]> store = new HashMap<>(); - - @Override - public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { - try { - if (!store.containsKey(signedPreKeyId)) { - throw new InvalidKeyIdException("No such signedprekeyrecord! " + signedPreKeyId); - } - - return new SignedPreKeyRecord(store.get(signedPreKeyId)); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public List<SignedPreKeyRecord> loadSignedPreKeys() { - try { - List<SignedPreKeyRecord> results = new LinkedList<>(); - - for (byte[] serialized : store.values()) { - results.add(new SignedPreKeyRecord(serialized)); - } - - return results; - } catch (IOException e) { - throw new AssertionError(e); - } - } - - @Override - public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record) { - store.put(signedPreKeyId, record.serialize()); - } - - @Override - public boolean containsSignedPreKey(int signedPreKeyId) { - return store.containsKey(signedPreKeyId); - } - - @Override - public void removeSignedPreKey(int signedPreKeyId) { - store.remove(signedPreKeyId); - } -} |