diff --git a/cryptography/src/main/java/com/salesforce/apollo/cryptography/Verifier.java b/cryptography/src/main/java/com/salesforce/apollo/cryptography/Verifier.java index 5802c0f5d..a76da3bef 100644 --- a/cryptography/src/main/java/com/salesforce/apollo/cryptography/Verifier.java +++ b/cryptography/src/main/java/com/salesforce/apollo/cryptography/Verifier.java @@ -165,107 +165,4 @@ public boolean verify(SigningThreshold threshold, JohnHancock signature, InputSt record Filtered(boolean verified, int validating, JohnHancock filtered) { } - - class DelegatedVerifier implements Verifier { - private volatile Verifier delegate; - - public DelegatedVerifier(Verifier delegate) { - this.delegate = delegate; - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, byte[]... message) { - return getDelegate().filtered(threshold, signature, message); - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, ByteBuffer... message) { - return getDelegate().filtered(threshold, signature, message); - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, ByteString... message) { - return getDelegate().filtered(threshold, signature, message); - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, InputStream message) { - return getDelegate().filtered(threshold, signature, message); - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, List forSigning) { - return getDelegate().filtered(threshold, signature, forSigning); - } - - @Override - public Filtered filtered(SigningThreshold threshold, JohnHancock signature, String message) { - return getDelegate().filtered(threshold, signature, message); - } - - @Override - public boolean verify(JohnHancock signature, byte[]... message) { - return getDelegate().verify(signature, message); - } - - @Override - public boolean verify(JohnHancock signature, ByteBuffer... message) { - return getDelegate().verify(signature, message); - } - - @Override - public boolean verify(JohnHancock signature, ByteString... message) { - return getDelegate().verify(signature, message); - } - - @Override - public boolean verify(JohnHancock signature, InputStream message) { - return getDelegate().verify(signature, message); - } - - @Override - public boolean verify(JohnHancock signature, List forSigning) { - return getDelegate().verify(signature, forSigning); - } - - @Override - public boolean verify(JohnHancock signature, String message) { - return getDelegate().verify(signature, message); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, byte[]... message) { - return getDelegate().verify(threshold, signature, message); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, ByteBuffer... message) { - return getDelegate().verify(threshold, signature, message); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, ByteString... message) { - return getDelegate().verify(threshold, signature, message); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, InputStream message) { - return getDelegate().verify(threshold, signature, message); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, List forSigning) { - return getDelegate().verify(threshold, signature, forSigning); - } - - @Override - public boolean verify(SigningThreshold threshold, JohnHancock signature, String message) { - return getDelegate().verify(threshold, signature, message); - } - - private Verifier getDelegate() { - final var current = delegate; - return current; - } - } } diff --git a/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java b/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java index be3222eed..40e1e83fb 100644 --- a/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java +++ b/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java @@ -108,8 +108,8 @@ public class View { private final ReadWriteLock viewChange = new ReentrantReadWriteLock( true); private final ViewManagement viewManagement; - private final EventValidation validation; - private final Verifiers verifiers; + private final EventValidation.DelegatedEventValidation validation; + private final Verifiers.DelegatedVerifiers verifiers; private volatile ScheduledFuture futureGossip; public View(Context context, ControlledIdentifierMember member, InetSocketAddress endpoint, @@ -138,8 +138,8 @@ public View(Context context, ControlledIdentifierMember member, Ine r -> new EntranceServer(gateway.getClientIdentityProvider(), r, metrics), EntranceClient.getCreate(metrics), Entrance.getLocalLoopback(node, service)); gossiper = new RingCommunications<>(context, node, comm); - this.validation = validation; - this.verifiers = verifiers; + this.validation = new EventValidation.DelegatedEventValidation(validation); + this.verifiers = new Verifiers.DelegatedVerifiers(verifiers); } /** diff --git a/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/EventValidation.java b/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/EventValidation.java index a35f2d969..d40187f77 100644 --- a/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/EventValidation.java +++ b/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/EventValidation.java @@ -78,6 +78,10 @@ public KeyState keyState(Identifier id, ULong sequenceNumber) { return delegate().keyState(id, sequenceNumber); } + public void setDelegate(EventValidation delegate) { + this.delegate = delegate; + } + @Override public boolean validate(EventCoordinates coordinates) { return delegate().validate(coordinates); diff --git a/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/Verifiers.java b/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/Verifiers.java index 1ef792b82..370302e3e 100644 --- a/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/Verifiers.java +++ b/stereotomy/src/main/java/com/salesforce/apollo/stereotomy/Verifiers.java @@ -89,6 +89,33 @@ static Verifiers fromKeyState_(List states) { Optional verifierFor(Identifier identifier); + class DelegatedVerifiers implements Verifiers { + private volatile Verifiers delegate; + + public DelegatedVerifiers(Verifiers delegate) { + this.delegate = delegate; + } + + public void setDelegate(Verifiers delegate) { + this.delegate = delegate; + } + + @Override + public Optional verifierFor(Identifier identifier) { + return delegate().verifierFor(identifier); + } + + @Override + public Optional verifierFor(EventCoordinates coordinates) { + return delegate().verifierFor(coordinates); + } + + private Verifiers delegate() { + final var current = delegate; + return current; + } + } + class FixedVerifiers implements Verifiers { private final Map verifiersByCoordinates; private final Map verifiersByIdentifer;