Class SimpleByteSourceBroker

java.lang.Object
org.apache.shiro.crypto.cipher.SimpleByteSourceBroker
All Implemented Interfaces:
ByteSourceBroker, org.apache.shiro.lang.util.Destroyable

public class SimpleByteSourceBroker extends Object implements ByteSourceBroker, org.apache.shiro.lang.util.Destroyable
A simple implementation that maintains cipher service, ciphertext and key for decrypting it later. useBytes(ByteSourceUser) guarantees the sensitive data in byte array will be erased at end of use.
  • Constructor Details

    • SimpleByteSourceBroker

      public SimpleByteSourceBroker(JcaCipherService cipherService, byte[] ciphertext, byte[] key)
  • Method Details

    • useBytes

      public void useBytes(ByteSourceUser user)
      Description copied from interface: ByteSourceBroker
      This method accepts an implementation of ByteSourceUser functional interface.
      To limit the decrypted value's existence, developers should maintain the implementation part as short as possible.
      Specified by:
      useBytes in interface ByteSourceBroker
      Parameters:
      user - Implements a use-case for the decrypted value.
    • getClonedBytes

      public byte[] getClonedBytes()
      Description copied from interface: ByteSourceBroker
      As the name implies, this returns a cloned byte array and caller has a responsibility to wipe it out at end of use.
      Specified by:
      getClonedBytes in interface ByteSourceBroker
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface org.apache.shiro.lang.util.Destroyable
      Throws:
      Exception