Class DecryptionProviderImpl

  • All Implemented Interfaces:
    DecryptionProvider, org.refcodes.security.Decrypter<java.lang.String,java.lang.String,org.refcodes.security.DecryptionException>


    public class DecryptionProviderImpl
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int toDecrypted​(byte[] aInput, int aInputOffset, int aInputLength, byte[] aOutput, int aOutputOffset)
      java.lang.String toDecrypted​(java.lang.String aInput)
      Encrypts a text with the latest known valid cipher.
      • Methods inherited from class java.lang.Object

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

      • DecryptionProviderImpl

        public DecryptionProviderImpl​(DecryptionService aDecryptionService,
                                      java.security.Provider aJceProvider,
                                      java.lang.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 Detail

      • toDecrypted

        public java.lang.String toDecrypted​(java.lang.String aInput)
                                     throws UnknownCipherUidException,
                                            NoCipherUidException
        Encrypts a text with the latest known valid cipher.
        Specified by:
        toDecrypted in interface org.refcodes.security.Decrypter<java.lang.String,java.lang.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 javax.crypto.ShortBufferException,
                               org.refcodes.security.DecryptionException
        Specified by:
        toDecrypted in interface org.refcodes.security.Decrypter<java.lang.String,java.lang.String,org.refcodes.security.DecryptionException>
        Throws:
        javax.crypto.ShortBufferException
        org.refcodes.security.DecryptionException