Class DecryptionProviderImpl

java.lang.Object
org.refcodes.forwardsecrecy.DecryptionProviderImpl
All Implemented Interfaces:
DecryptionProvider, org.refcodes.mixin.Disposable, org.refcodes.security.Decrypter<String,String,org.refcodes.security.DecryptionException>

public class DecryptionProviderImpl extends Object implements DecryptionProvider
This class is a basic implementation of the DecryptionProvider interface.

ATTENTION: This implementation does not take care of housekeeping. In case this class is to be run as a service, it must provide housekeeping facilities in terms of cleaning up instances contained in internal data structures (such as the hash maps) after a defined period of time those instance were not accessed.

  • Constructor Details

    • DecryptionProviderImpl

      public DecryptionProviderImpl(DecryptionService aDecryptionService, Provider aJceProvider, String aJceAlgorithm)
      Constructs the DecryptionProvider with the given DecryptionService and with the specified JCE Provider as well as the according JCE algorithm.
      Parameters:
      aDecryptionService - The DecryptionService to use for getting the known ciphers for decryption
      aJceProvider - The JCE Provider to be used.
      aJceAlgorithm - the JCE algorithm to be used by the JCE Provider.
    • DecryptionProviderImpl

      public DecryptionProviderImpl(DecryptionService aDecryptionService)
      Constructs the DecryptionProvider using AES as implemented by the BouncyCastleProvider.
      Parameters:
      aDecryptionService - The service to use for getting the known ciphers for decryption
  • Method Details

    • toDecrypted

      public String toDecrypted(String aInput) throws UnknownCipherUidException, NoCipherUidException
      Encrypts a text with the latest known valid cipher.
      Specified by:
      toDecrypted in interface org.refcodes.security.Decrypter<String,String,org.refcodes.security.DecryptionException>
      Specified by:
      toDecrypted in interface DecryptionProvider
      Parameters:
      aInput - The text to be encrypted
      Returns:
      The encrypted text with a version prefixed identifying the cipher being used for encryption.
      Throws:
      UnknownCipherUidException - in case the cipher UID prefixed to the encrypted text is unknown
      NoCipherUidException - in case no cipher UID was found prefixed to the provided text.
    • toDecrypted

      public int toDecrypted(byte[] aInput, int aInputOffset, int aInputLength, byte[] aOutput, int aOutputOffset) throws org.refcodes.security.DecryptionException
      Specified by:
      toDecrypted in interface org.refcodes.security.Decrypter<String,String,org.refcodes.security.DecryptionException>
      Throws:
      org.refcodes.security.DecryptionException
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.refcodes.mixin.Disposable