Class AbstractTlsSecret

  • All Implemented Interfaces:
    TlsSecret
    Direct Known Subclasses:
    BcTlsSecret, JceTlsSecret

    public abstract class AbstractTlsSecret
    extends java.lang.Object
    implements TlsSecret
    Base class for a TlsSecret implementation which captures common code and fields.
    • Field Detail

      • data

        protected byte[] data
    • Constructor Detail

      • AbstractTlsSecret

        protected AbstractTlsSecret​(byte[] data)
        Base constructor.
        Parameters:
        data - the byte[] making up the secret value.
    • Method Detail

      • checkAlive

        protected void checkAlive()
      • calculateHMAC

        public byte[] calculateHMAC​(int cryptoHashAlgorithm,
                                    byte[] buf,
                                    int off,
                                    int len)
        Description copied from interface: TlsSecret
        Calculate an HMAC with this secret's data as the key.
        Specified by:
        calculateHMAC in interface TlsSecret
        Parameters:
        cryptoHashAlgorithm - the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
        buf - array containing the input data.
        off - offset into the input array the input starts at.
        len - the length of the input data.
        Returns:
      • destroy

        public void destroy()
        Description copied from interface: TlsSecret
        Destroy the internal state of the secret. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.
        Specified by:
        destroy in interface TlsSecret
      • encrypt

        public byte[] encrypt​(TlsEncryptor encryptor)
                       throws java.io.IOException
        Description copied from interface: TlsSecret
        Return an encrypted copy of the data this secret is based on.
        Specified by:
        encrypt in interface TlsSecret
        Parameters:
        encryptor - the encryptor to use for protecting the internal data.
        Returns:
        an encrypted copy of this secret's internal data.
        Throws:
        java.io.IOException
      • extract

        public byte[] extract()
        Description copied from interface: TlsSecret
        Return the internal data from this secret. The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.
        Specified by:
        extract in interface TlsSecret
        Returns:
        the secret's internal data.
      • isAlive

        public boolean isAlive()
        Specified by:
        isAlive in interface TlsSecret