All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quorum.tessera.recovery.workflow.SenderIsNotRecipient Maven / Gradle / Ivy

Go to download

Tessera is a stateless Java system that is used to enable the encryption, decryption, and distribution of private transactions for Quorum.

There is a newer version: 24.4.2
Show newest version
package com.quorum.tessera.recovery.workflow;

import com.quorum.tessera.enclave.Enclave;
import com.quorum.tessera.encryption.PublicKey;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SenderIsNotRecipient implements BatchWorkflowFilter {

  private static final Logger LOGGER = LoggerFactory.getLogger(SenderIsNotRecipient.class);

  private final Enclave enclave;

  public SenderIsNotRecipient(final Enclave enclave) {
    this.enclave = Objects.requireNonNull(enclave);
  }

  @Override
  public boolean filter(final BatchWorkflowContext context) {
    final PublicKey recipientKey = context.getRecipientKey();

    final boolean valid = !enclave.getPublicKeys().contains(recipientKey);

    if (!valid) {
      // we are trying to send something to ourselves - don't do it
      LOGGER.debug("Resend request for own key {}, not continuing", recipientKey.encodeToBase64());
    }
    return valid;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy