Class EncryptionKey

java.lang.Object
org.acemq.amqp.crypto.EncryptionKey

public final class EncryptionKey extends Object
A key and the name messages will refer to it by.

The identifier is the part that makes rotation possible. It travels in every message, so a message written last month can still be read by a service whose current key is a different one, without anybody having to know when the change happened.

Identifiers are public. They sit in the clear in front of the ciphertext where anyone holding the message can read them, which is the point — the reader has to know what to ask the key store for before it can decrypt anything. Name them for the key, not for what they protect: orders-2026-09 rather than customer-card-numbers.

  • Constructor Details

    • EncryptionKey

      public EncryptionKey(String id, SecretKey key)
      Parameters:
      id - what messages written with this key will name, in ASCII
      key - an AES key; 256-bit unless there is a reason
  • Method Details

    • id

      public String id()
      Returns:
      the identifier written into every message this key encrypts
    • key

      public SecretKey key()
      Returns:
      the key itself
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the identifier and nothing else. The key must not appear in a log