mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Simplfiy OmemoKeyUtil generics
This commit is contained in:
parent
b0acf0bcc3
commit
4e5cf82795
9 changed files with 14 additions and 24 deletions
|
@ -55,8 +55,7 @@ public class SignalFileBasedOmemoStore
|
|||
}
|
||||
|
||||
@Override
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> keyUtil()
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil()
|
||||
{
|
||||
return new SignalOmemoKeyUtil();
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ import org.jivesoftware.smackx.omemo.util.OmemoKeyUtil;
|
|||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.SessionCipher;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.ecc.Curve;
|
||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||
import org.whispersystems.libsignal.state.PreKeyBundle;
|
||||
|
@ -49,7 +47,7 @@ import org.whispersystems.libsignal.util.KeyHelper;
|
|||
* @author Paul Schaub
|
||||
*/
|
||||
public class SignalOmemoKeyUtil extends OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
SessionRecord, ECPublicKey, PreKeyBundle>
|
||||
{
|
||||
@Override
|
||||
public IdentityKeyPair generateOmemoIdentityKeyPair() {
|
||||
|
|
|
@ -46,8 +46,7 @@ public abstract class SignalOmemoStore
|
|||
private final SignalOmemoKeyUtil signalKeyUtil = new SignalOmemoKeyUtil();
|
||||
|
||||
@Override
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> keyUtil() {
|
||||
public OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil() {
|
||||
return signalKeyUtil;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.whispersystems.libsignal.SessionCipher;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||
import org.whispersystems.libsignal.state.PreKeyBundle;
|
||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||
|
@ -46,10 +44,9 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
*/
|
||||
@RunWith(value = Parameterized.class)
|
||||
public class SignalOmemoKeyUtilTest
|
||||
extends OmemoKeyUtilTest<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> {
|
||||
extends OmemoKeyUtilTest<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> {
|
||||
|
||||
public SignalOmemoKeyUtilTest(OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> keyUtil) {
|
||||
public SignalOmemoKeyUtilTest(OmemoKeyUtil<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord, ECPublicKey, PreKeyBundle> keyUtil) {
|
||||
super(keyUtil);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
|
|||
|
||||
private final HashMap<OmemoDevice, KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess>> caches = new HashMap<>();
|
||||
private final OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> persistent;
|
||||
private final OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> keyUtil;
|
||||
private final OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> keyUtil;
|
||||
|
||||
public CachingOmemoStore(OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> keyUtil) {
|
||||
public CachingOmemoStore(OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> keyUtil) {
|
||||
if (keyUtil == null) {
|
||||
throw new IllegalArgumentException("KeyUtil MUST NOT be null!");
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
|
|||
}
|
||||
|
||||
@Override
|
||||
public OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
public OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle>
|
||||
keyUtil() {
|
||||
if (persistent != null) {
|
||||
return persistent.keyUtil();
|
||||
|
|
|
@ -166,8 +166,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
* @param omemoStore store.
|
||||
*/
|
||||
public void setOmemoStoreBackend(
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore)
|
||||
{
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore) {
|
||||
if (this.omemoStore != null) {
|
||||
throw new IllegalStateException("An OmemoStore backend has already been set.");
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
*
|
||||
* @return KeyUtil object
|
||||
*/
|
||||
public abstract OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> keyUtil();
|
||||
public abstract OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> keyUtil();
|
||||
|
||||
/**
|
||||
* Return our identityKeys fingerprint.
|
||||
|
|
|
@ -36,13 +36,11 @@ import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
|||
* @param <T_PreKey> PreKey class
|
||||
* @param <T_SigPreKey> SignedPreKey class
|
||||
* @param <T_Sess> Session class
|
||||
* @param <T_Addr> Address class
|
||||
* @param <T_ECPub> Elliptic Curve PublicKey class
|
||||
* @param <T_Bundle> Bundle class
|
||||
* @param <T_Ciph> Cipher class
|
||||
* @author Paul Schaub
|
||||
*/
|
||||
public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
|
||||
public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> {
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoKeyUtil.class.getName());
|
||||
|
||||
public final Bundle BUNDLE = new Bundle();
|
||||
|
|
|
@ -37,12 +37,12 @@ import org.jivesoftware.smackx.omemo.util.OmemoKeyUtil;
|
|||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public abstract class OmemoKeyUtilTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
public abstract class OmemoKeyUtilTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle>
|
||||
extends SmackTestSuite {
|
||||
|
||||
protected OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> keyUtil;
|
||||
protected OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> keyUtil;
|
||||
|
||||
public OmemoKeyUtilTest(OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> keyUtil) {
|
||||
public OmemoKeyUtilTest(OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_ECPub, T_Bundle> keyUtil) {
|
||||
this.keyUtil = keyUtil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue