Removed the usage of the collection of digital signers
parent
5398d5adc3
commit
f3ec49acc7
|
@ -18,7 +18,8 @@ public class BulletinBoardUtils {
|
||||||
* signed by all given DigitalSignatures
|
* signed by all given DigitalSignatures
|
||||||
*
|
*
|
||||||
* @param unsignedMessage BasicMessage
|
* @param unsignedMessage BasicMessage
|
||||||
* @param signer DigitalSignature which will sign the UnsignedBulletinBoardMessage message
|
* @param signer collection of DigitalSignature which will sign the
|
||||||
|
* UnsignedBulletinBoardMessage message
|
||||||
* @return BulletinBoardMessage
|
* @return BulletinBoardMessage
|
||||||
*/
|
*/
|
||||||
public static BulletinBoardMessage signBulletinBoardMessage(UnsignedBulletinBoardMessage unsignedMessage,
|
public static BulletinBoardMessage signBulletinBoardMessage(UnsignedBulletinBoardMessage unsignedMessage,
|
||||||
|
@ -28,7 +29,6 @@ public class BulletinBoardUtils {
|
||||||
signer.updateContent(unsignedMessage);
|
signer.updateContent(unsignedMessage);
|
||||||
Crypto.Signature signature = signer.sign();
|
Crypto.Signature signature = signer.sign();
|
||||||
bulletinBoardMessage.addSig(signature);
|
bulletinBoardMessage.addSig(signature);
|
||||||
|
|
||||||
return bulletinBoardMessage.build();
|
return bulletinBoardMessage.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import meerkat.util.BulletinBoardUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static meerkat.util.BulletinBoardUtils.signBulletinBoardMessage;
|
import static meerkat.util.BulletinBoardUtils.signBulletinBoardMessage;
|
||||||
|
@ -31,16 +30,15 @@ import static meerkat.util.BulletinBoardUtils.signBulletinBoardMessage;
|
||||||
*/
|
*/
|
||||||
public class AsyncRegistry implements VoterRegistry{
|
public class AsyncRegistry implements VoterRegistry{
|
||||||
|
|
||||||
protected Collection<DigitalSignature> signers;
|
protected DigitalSignature signer;
|
||||||
protected AsyncBulletinBoardClient bulletinBoardClient ;
|
protected AsyncBulletinBoardClient bulletinBoardClient ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Collection<DigitalSignature> signers, AsyncBulletinBoardClient communicator) {
|
public void init(DigitalSignature signer, AsyncBulletinBoardClient communicator) {
|
||||||
this.signers = signers;
|
this.signer = signer;
|
||||||
this.bulletinBoardClient = communicator;
|
this.bulletinBoardClient = communicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addVoter(VoterInfo voterInfo, FutureCallback<Boolean> callback) throws SignatureException {
|
public void addVoter(VoterInfo voterInfo, FutureCallback<Boolean> callback) throws SignatureException {
|
||||||
UnsignedBulletinBoardMessage basicMessage =
|
UnsignedBulletinBoardMessage basicMessage =
|
||||||
|
@ -51,7 +49,8 @@ public class AsyncRegistry implements VoterRegistry{
|
||||||
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto())
|
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage, signers), callback);
|
|
||||||
|
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage, signer), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,7 +62,7 @@ public class AsyncRegistry implements VoterRegistry{
|
||||||
.setData(voterRegistryMessage.toByteString())
|
.setData(voterRegistryMessage.toByteString())
|
||||||
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto());
|
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto());
|
||||||
|
|
||||||
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage.build(), signers), callback);
|
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage.build(), signer), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,7 +74,7 @@ public class AsyncRegistry implements VoterRegistry{
|
||||||
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto())
|
.setTimestamp(BulletinBoardUtils.getCurrentTimestampProto())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage, signers), callback);
|
bulletinBoardClient.postMessage(signBulletinBoardMessage(basicMessage, signer), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,7 +9,6 @@ import meerkat.protobuf.VoterRegistry.VoterRegistryMessage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,10 +19,10 @@ public interface VoterRegistry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the voter registry
|
* Initialize the voter registry
|
||||||
* @param signers collection of singers every object will sign every output message
|
* @param signer object which sign the outputed message
|
||||||
* @param communicator the object which communicates with the BulletinBoardServer
|
* @param communicator the object which communicates with the BulletinBoardServer
|
||||||
*/
|
*/
|
||||||
void init(Collection<DigitalSignature> signers, AsyncBulletinBoardClient communicator);
|
void init(DigitalSignature signer, AsyncBulletinBoardClient communicator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new voter to the bulletin-board
|
* Adds new voter to the bulletin-board
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.security.KeyStore;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ import static meerkat.util.BulletinBoardUtils.getLatestMessage;
|
||||||
*/
|
*/
|
||||||
public class SimpleRegistryTest {
|
public class SimpleRegistryTest {
|
||||||
|
|
||||||
private Collection<DigitalSignature> signers;
|
private DigitalSignature signer;
|
||||||
private AsyncBulletinBoardClient bulletinBoardClient;
|
private AsyncBulletinBoardClient bulletinBoardClient;
|
||||||
private InputStream certStream;
|
private InputStream certStream;
|
||||||
private SecureRandom random = new SecureRandom();
|
private SecureRandom random = new SecureRandom();
|
||||||
|
@ -105,7 +104,6 @@ public class SimpleRegistryTest {
|
||||||
|
|
||||||
private void SetSigner(){
|
private void SetSigner(){
|
||||||
try {
|
try {
|
||||||
signers = new ArrayList<>();
|
|
||||||
ECDSASignature signer = new ECDSASignature();
|
ECDSASignature signer = new ECDSASignature();
|
||||||
InputStream keyStream = getClass().getResourceAsStream(KEYFILE_EXAMPLE);
|
InputStream keyStream = getClass().getResourceAsStream(KEYFILE_EXAMPLE);
|
||||||
char[] password = KEYFILE_PASSWORD.toCharArray();
|
char[] password = KEYFILE_PASSWORD.toCharArray();
|
||||||
|
@ -115,8 +113,7 @@ public class SimpleRegistryTest {
|
||||||
signer.loadVerificationCertificates(getClass().getResourceAsStream(CERT1_PEM_EXAMPLE));
|
signer.loadVerificationCertificates(getClass().getResourceAsStream(CERT1_PEM_EXAMPLE));
|
||||||
|
|
||||||
keyStream.close();
|
keyStream.close();
|
||||||
signers.add(signer);
|
this.signer = signer;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
assert false : "The signers creation failed ";
|
assert false : "The signers creation failed ";
|
||||||
|
@ -136,7 +133,7 @@ public class SimpleRegistryTest {
|
||||||
private AsyncRegistry GetRegistry()
|
private AsyncRegistry GetRegistry()
|
||||||
{
|
{
|
||||||
AsyncRegistry registry = new AsyncRegistry();
|
AsyncRegistry registry = new AsyncRegistry();
|
||||||
registry.init(signers, bulletinBoardClient);
|
registry.init(signer, bulletinBoardClient);
|
||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue