mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-27 00:45:23 -04:00
Use Persistable interface for local db data
This commit is contained in:
parent
8792666f78
commit
6a25e1c56c
71 changed files with 216 additions and 196 deletions
|
@ -1,6 +0,0 @@
|
|||
package io.bitsquare.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface Payload extends Serializable {
|
||||
}
|
|
@ -20,11 +20,11 @@ package io.bitsquare.common.crypto;
|
|||
import java.io.Serializable;
|
||||
import java.security.PublicKey;
|
||||
|
||||
public final class DecryptedPayloadWithPubKey implements Serializable {
|
||||
public final class DecryptedDataTuple {
|
||||
public final Serializable payload;
|
||||
public final PublicKey sigPublicKey;
|
||||
|
||||
public DecryptedPayloadWithPubKey(Serializable payload, PublicKey sigPublicKey) {
|
||||
public DecryptedDataTuple(Serializable payload, PublicKey sigPublicKey) {
|
||||
this.payload = payload;
|
||||
this.sigPublicKey = sigPublicKey;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ public final class DecryptedPayloadWithPubKey implements Serializable {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DecryptedPayloadWithPubKey)) return false;
|
||||
if (!(o instanceof DecryptedDataTuple)) return false;
|
||||
|
||||
DecryptedPayloadWithPubKey that = (DecryptedPayloadWithPubKey) o;
|
||||
DecryptedDataTuple that = (DecryptedDataTuple) o;
|
||||
|
||||
if (payload != null ? !payload.equals(that.payload) : that.payload != null) return false;
|
||||
return !(sigPublicKey != null ? !sigPublicKey.equals(that.sigPublicKey) : that.sigPublicKey != null);
|
|
@ -233,7 +233,7 @@ public class Encryption {
|
|||
* @return A DecryptedPayloadWithPubKey object.
|
||||
* @throws CryptoException
|
||||
*/
|
||||
public static DecryptedPayloadWithPubKey decryptHybridWithSignature(SealedAndSigned sealedAndSigned, PrivateKey privateKey) throws CryptoException {
|
||||
public static DecryptedDataTuple decryptHybridWithSignature(SealedAndSigned sealedAndSigned, PrivateKey privateKey) throws CryptoException {
|
||||
SecretKey secretKey = getSecretKeyFromBytes(decrypt(sealedAndSigned.encryptedSecretKey, privateKey));
|
||||
boolean isValid = Sig.verify(sealedAndSigned.sigPublicKey,
|
||||
Hash.getHash(sealedAndSigned.encryptedPayloadWithHmac),
|
||||
|
@ -242,7 +242,7 @@ public class Encryption {
|
|||
throw new CryptoException("Signature verification failed.");
|
||||
|
||||
Serializable decryptedPayload = Utilities.deserialize(decryptPayloadWithHmac(sealedAndSigned.encryptedPayloadWithHmac, secretKey));
|
||||
return new DecryptedPayloadWithPubKey(decryptedPayload, sealedAndSigned.sigPublicKey);
|
||||
return new DecryptedDataTuple(decryptedPayload, sealedAndSigned.sigPublicKey);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
package io.bitsquare.common.crypto;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
|
@ -35,7 +35,7 @@ import java.security.spec.X509EncodedKeySpec;
|
|||
* Same as KeyRing but with public keys only.
|
||||
* Used to send public keys over the wire to other peer.
|
||||
*/
|
||||
public final class PubKeyRing implements Serializable {
|
||||
public final class PubKeyRing implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
package io.bitsquare.common.crypto;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.PublicKey;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class SealedAndSigned implements Serializable {
|
||||
public final class SealedAndSigned implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package io.bitsquare.common.persistance;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Marker interface for data which is used for local data persistence
|
||||
*/
|
||||
public interface Persistable extends Serializable {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package io.bitsquare.common.wire;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Marker interface for data which is sent over the wire
|
||||
*/
|
||||
public interface Payload extends Serializable {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue