SignalCachingOmemoStore.java

  1. /**
  2.  *
  3.  * Copyright 2017 Paul Schaub
  4.  *
  5.  * This file is part of smack-omemo-signal.
  6.  *
  7.  * smack-omemo-signal is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program; if not, write to the Free Software Foundation,
  19.  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  20.  */
  21. package org.jivesoftware.smackx.omemo.signal;

  22. import org.jivesoftware.smackx.omemo.CachingOmemoStore;
  23. import org.jivesoftware.smackx.omemo.OmemoStore;

  24. import org.whispersystems.libsignal.IdentityKey;
  25. import org.whispersystems.libsignal.IdentityKeyPair;
  26. import org.whispersystems.libsignal.SessionCipher;
  27. import org.whispersystems.libsignal.SignalProtocolAddress;
  28. import org.whispersystems.libsignal.ecc.ECPublicKey;
  29. import org.whispersystems.libsignal.state.PreKeyBundle;
  30. import org.whispersystems.libsignal.state.PreKeyRecord;
  31. import org.whispersystems.libsignal.state.SessionRecord;
  32. import org.whispersystems.libsignal.state.SignedPreKeyRecord;

  33. /**
  34.  * Implementation of the CachingOmemoStore for smack-omemo-signal.
  35.  * This Store implementation can either be used as a proxy wrapping a persistent SignalOmemoStore in order to prevent
  36.  * excessive storage access, or it can be used standalone as an ephemeral store, which doesn't persist its contents.
  37.  */
  38. public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord,
  39.         SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {

  40.     /**
  41.      * Create a new SignalCachingOmemoStore as a caching layer around a persisting OmemoStore
  42.      * (eg. a SignalFileBasedOmemoStore).
  43.      *
  44.      * @param wrappedStore other store implementation that gets wrapped
  45.      */
  46.     public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
  47.             SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> wrappedStore) {
  48.         super(wrappedStore);
  49.     }

  50.     /**
  51.      * Create a new SignalCachingOmemoStore as an ephemeral standalone OmemoStore.
  52.      */
  53.     public SignalCachingOmemoStore() {
  54.         super(new SignalOmemoKeyUtil());
  55.     }
  56. }