Class EncryptedTranscoder

  • All Implemented Interfaces:
    Transcoder

    public class EncryptedTranscoder
    extends java.lang.Object
    implements Transcoder
    Encodes an object by encrypting its serialized byte stream. Details of encryption are handled by an instance of CipherBean.

    Optional gzip compression of the serialized byte stream before encryption is supported and enabled by default.

    Since:
    6.1
    • Constructor Summary

      Constructors 
      Constructor Description
      EncryptedTranscoder​(org.cryptacular.bean.CipherBean cipherBean)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object decode​(byte[] encoded)
      Decodes a stream of bytes produced by Transcoder.encode(Object) back into the original object.
      byte[] encode​(java.lang.Object o)
      Encodes an object into a stream of bytes.
      protected byte[] encrypt​(java.io.ByteArrayOutputStream outBuffer)
      Encrypt.
      protected void writeObjectToOutputStream​(java.lang.Object o, java.io.ObjectOutputStream out)
      Write object to output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EncryptedTranscoder

        public EncryptedTranscoder​(org.cryptacular.bean.CipherBean cipherBean)
    • Method Detail

      • encode

        public byte[] encode​(java.lang.Object o)
                      throws java.io.IOException
        Description copied from interface: Transcoder
        Encodes an object into a stream of bytes.
        Specified by:
        encode in interface Transcoder
        Parameters:
        o - Object to encode.
        Returns:
        Object encoded as a byte array.
        Throws:
        java.io.IOException - On encoding errors.
      • writeObjectToOutputStream

        protected void writeObjectToOutputStream​(java.lang.Object o,
                                                 java.io.ObjectOutputStream out)
                                          throws java.io.IOException
        Write object to output stream.
        Parameters:
        o - the o
        out - the out
        Throws:
        java.io.IOException - the io exception
      • encrypt

        protected byte[] encrypt​(java.io.ByteArrayOutputStream outBuffer)
                          throws java.io.IOException
        Encrypt.
        Parameters:
        outBuffer - the out buffer
        Returns:
        the byte [ ]
        Throws:
        java.io.IOException - the io exception
      • decode

        public java.lang.Object decode​(byte[] encoded)
                                throws java.io.IOException
        Description copied from interface: Transcoder
        Decodes a stream of bytes produced by Transcoder.encode(Object) back into the original object.
        Specified by:
        decode in interface Transcoder
        Parameters:
        encoded - Encoded representation of an object.
        Returns:
        Object decoded from byte array.
        Throws:
        java.io.IOException - On decoding errors.