@Override public void submitRequest(WaveletName waveletName, ProtocolWaveletDelta delta, final SubmitRequestListener listener) { Preconditions.checkState(initialized, "Wave server not yet initialized"); if (delta.getOperationCount() == 0) { listener.onFailure("Empty delta at version " + delta.getHashedVersion().getVersion()); return; } // The serialised version of this delta happens now. This should be the only place, ever! ProtocolSignedDelta signedDelta = certificateManager.signDelta(ByteStringMessage.serializeMessage(delta)); submitDelta(waveletName, delta, signedDelta, new SubmitResultListener() { @Override public void onFailure(FederationError errorMessage) { listener.onFailure(errorMessage.getErrorMessage()); } @Override public void onSuccess(int operationsApplied, ProtocolHashedVersion hashedVersionAfterApplication, long applicationTimestamp) { listener.onSuccess(operationsApplied, CoreWaveletOperationSerializer.deserialize(hashedVersionAfterApplication), applicationTimestamp); } }); }
public void testSignature() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@example.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); manager.storeSignerInfo(getSignerInfo().toProtoBuf()); ByteStringMessage<ProtocolWaveletDelta> compare = manager.verifyDelta(signedDelta); assertEquals(canonicalDelta, compare); }
public void testSignature() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@example.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); manager.storeSignerInfo(getSignerInfo().toProtoBuf()); ByteStringMessage<ProtocolWaveletDelta> compare = manager.verifyDelta(signedDelta); assertEquals(canonicalDelta, compare); }
public void testSignature_authorNotMatching() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@someotherdomain.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); manager.storeSignerInfo(getSignerInfo().toProtoBuf()); try { manager.verifyDelta(signedDelta); fail("expected exception, but didn't get it"); } catch (SignatureException e) { // expected } }
public void testSignature_authorNotMatching() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@someotherdomain.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); manager.storeSignerInfo(getSignerInfo().toProtoBuf()); try { manager.verifyDelta(signedDelta); fail("expected exception, but didn't get it"); } catch (SignatureException e) { // expected } }
public void testSignature_missingSignerInfo() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@example.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); manager = new CertificateManagerImpl(config, getSigner(), getVerifier(store, false), store); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); try { manager.verifyDelta(signedDelta); fail("expected UnknownSignerException, but didn't get it"); } catch (UnknownSignerException e) { // expected } catch (Exception e) { fail("expected UnknownSignerExeception, but got " + e); } }
public void testSignature_missingSignerInfo() throws Exception { ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder() .setHashedVersion(getProtocolHashedVersion()) .setAuthor("bob@example.com") .build(); ByteStringMessage<ProtocolWaveletDelta> canonicalDelta = ByteStringMessage.serializeMessage(delta); manager = new CertificateManagerImpl(config, getSigner(), getVerifier(store, false), store); ProtocolSignedDelta signedDelta = manager.signDelta(canonicalDelta); try { manager.verifyDelta(signedDelta); fail("expected UnknownSignerException, but didn't get it"); } catch (UnknownSignerException e) { // expected } catch (Exception e) { fail("expected UnknownSignerExeception, but got " + e); } }