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