Version 1.0.1-SNAPSHOT - fixed issue with requesting pubkey, and problem where your keys are overwritten if you try to import a contact again or worse, your identity as a contact
This commit is contained in:
parent
3103ae6edd
commit
5f4dbfc985
@ -5,7 +5,7 @@ subprojects {
|
|||||||
|
|
||||||
sourceCompatibility = 1.7
|
sourceCompatibility = 1.7
|
||||||
group = 'ch.dissem.jabit'
|
group = 'ch.dissem.jabit'
|
||||||
version = '1.0.0'
|
version = '1.0.1-SNAPSHOT'
|
||||||
|
|
||||||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ subprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signing {
|
signing {
|
||||||
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
|
required { isReleaseVersion }
|
||||||
sign configurations.archives
|
sign configurations.archives
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +200,7 @@ public class BitmessageContext {
|
|||||||
LOG.info("Public key is missing from recipient. Requesting.");
|
LOG.info("Public key is missing from recipient. Requesting.");
|
||||||
requestPubkey(msg.getFrom(), to);
|
requestPubkey(msg.getFrom(), to);
|
||||||
msg.setStatus(PUBKEY_REQUESTED);
|
msg.setStatus(PUBKEY_REQUESTED);
|
||||||
|
msg.addLabels(ctx.getMessageRepository().getLabels(Label.Type.OUTBOX));
|
||||||
ctx.getMessageRepository().save(msg);
|
ctx.getMessageRepository().save(msg);
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Sending message.");
|
LOG.info("Sending message.");
|
||||||
@ -224,7 +225,7 @@ public class BitmessageContext {
|
|||||||
requestingIdentity,
|
requestingIdentity,
|
||||||
address,
|
address,
|
||||||
new GetPubkey(address),
|
new GetPubkey(address),
|
||||||
+28 * DAY
|
+2 * DAY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import ch.dissem.bitmessage.entity.BitmessageAddress;
|
|||||||
import ch.dissem.bitmessage.entity.ObjectMessage;
|
import ch.dissem.bitmessage.entity.ObjectMessage;
|
||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.PlaintextHolder;
|
import ch.dissem.bitmessage.entity.PlaintextHolder;
|
||||||
|
import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||||
import ch.dissem.bitmessage.ports.MessageRepository;
|
import ch.dissem.bitmessage.ports.MessageRepository;
|
||||||
import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
|
import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
|
||||||
import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
|
import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
|
||||||
@ -42,10 +43,10 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doProofOfWork(BitmessageAddress recipient, ObjectMessage object) {
|
public void doProofOfWork(BitmessageAddress recipient, ObjectMessage object) {
|
||||||
long nonceTrialsPerByte = recipient == null ?
|
Pubkey pubkey = recipient == null ? null : recipient.getPubkey();
|
||||||
ctx.getNetworkNonceTrialsPerByte() : recipient.getPubkey().getNonceTrialsPerByte();
|
|
||||||
long extraBytes = recipient == null ?
|
long nonceTrialsPerByte = pubkey == null ? ctx.getNetworkNonceTrialsPerByte() : pubkey.getNonceTrialsPerByte();
|
||||||
ctx.getNetworkExtraBytes() : recipient.getPubkey().getExtraBytes();
|
long extraBytes = pubkey == null ? ctx.getNetworkExtraBytes() : pubkey.getExtraBytes();
|
||||||
|
|
||||||
powRepo.putObject(object, nonceTrialsPerByte, extraBytes);
|
powRepo.putObject(object, nonceTrialsPerByte, extraBytes);
|
||||||
if (object.getPayload() instanceof PlaintextHolder) {
|
if (object.getPayload() instanceof PlaintextHolder) {
|
||||||
|
@ -79,6 +79,7 @@ public class Label implements Serializable {
|
|||||||
INBOX,
|
INBOX,
|
||||||
BROADCAST,
|
BROADCAST,
|
||||||
DRAFT,
|
DRAFT,
|
||||||
|
OUTBOX,
|
||||||
SENT,
|
SENT,
|
||||||
UNREAD,
|
UNREAD,
|
||||||
TRASH
|
TRASH
|
||||||
|
@ -152,13 +152,25 @@ public class JdbcAddressRepository extends JdbcHelper implements AddressReposito
|
|||||||
|
|
||||||
private void update(BitmessageAddress address) throws IOException, SQLException {
|
private void update(BitmessageAddress address) throws IOException, SQLException {
|
||||||
try (Connection connection = config.getConnection()) {
|
try (Connection connection = config.getConnection()) {
|
||||||
PreparedStatement ps = connection.prepareStatement(
|
StringBuilder statement = new StringBuilder("UPDATE Address SET alias=?");
|
||||||
"UPDATE Address SET alias=?, public_key=?, private_key=?, subscribed=? WHERE address=?");
|
if (address.getPubkey() != null) {
|
||||||
ps.setString(1, address.getAlias());
|
statement.append(", public_key=?");
|
||||||
writePubkey(ps, 2, address.getPubkey());
|
}
|
||||||
writeBlob(ps, 3, address.getPrivateKey());
|
if (address.getPrivateKey() != null) {
|
||||||
ps.setBoolean(4, address.isSubscribed());
|
statement.append(", private_key=?");
|
||||||
ps.setString(5, address.getAddress());
|
}
|
||||||
|
statement.append(", subscribed=? WHERE address=?");
|
||||||
|
PreparedStatement ps = connection.prepareStatement(statement.toString());
|
||||||
|
int i = 0;
|
||||||
|
ps.setString(++i, address.getAlias());
|
||||||
|
if (address.getPubkey() != null) {
|
||||||
|
writePubkey(ps, ++i, address.getPubkey());
|
||||||
|
}
|
||||||
|
if (address.getPrivateKey() != null) {
|
||||||
|
writeBlob(ps, ++i, address.getPrivateKey());
|
||||||
|
}
|
||||||
|
ps.setBoolean(++i, address.isSubscribed());
|
||||||
|
ps.setString(++i, address.getAddress());
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,17 @@ public class JdbcAddressRepositoryTest extends TestBase {
|
|||||||
assertEquals("Test-Alias", address.getAlias());
|
assertEquals("Test-Alias", address.getAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ensureExistingKeysAreNotDeleted() {
|
||||||
|
BitmessageAddress address = new BitmessageAddress(IDENTITY_A);
|
||||||
|
address.setAlias("Test");
|
||||||
|
repo.save(address);
|
||||||
|
BitmessageAddress identityA = repo.getAddress(IDENTITY_A);
|
||||||
|
assertNotNull(identityA.getPubkey());
|
||||||
|
assertNotNull(identityA.getPrivateKey());
|
||||||
|
assertEquals("Test", identityA.getAlias());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() throws Exception {
|
public void testRemove() throws Exception {
|
||||||
BitmessageAddress address = repo.getAddress(IDENTITY_A);
|
BitmessageAddress address = repo.getAddress(IDENTITY_A);
|
||||||
|
Loading…
Reference in New Issue
Block a user