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>
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 Summary
ConstructorDescriptionDecryptionProviderImpl
(DecryptionService aDecryptionService) Constructs theDecryptionProvider
using AES as implemented by theBouncyCastleProvider
.DecryptionProviderImpl
(DecryptionService aDecryptionService, Provider aJceProvider, String aJceAlgorithm) Constructs theDecryptionProvider
with the givenDecryptionService
and with the specified JCEProvider
as well as the according JCE algorithm. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
int
toDecrypted
(byte[] aInput, int aInputOffset, int aInputLength, byte[] aOutput, int aOutputOffset) toDecrypted
(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
Methods inherited from interface org.refcodes.security.Decrypter
decrypt, decrypt
-
Constructor Details
-
DecryptionProviderImpl
public DecryptionProviderImpl(DecryptionService aDecryptionService, Provider aJceProvider, String aJceAlgorithm) Constructs theDecryptionProvider
with the givenDecryptionService
and with the specified JCEProvider
as well as the according JCE algorithm.- Parameters:
aDecryptionService
- TheDecryptionService
to use for getting the known ciphers for decryptionaJceProvider
- The JCEProvider
to be used.aJceAlgorithm
- the JCE algorithm to be used by the JCEProvider
.
-
DecryptionProviderImpl
Constructs theDecryptionProvider
using AES as implemented by theBouncyCastleProvider
.- Parameters:
aDecryptionService
- The service to use for getting the known ciphers for decryption
-
-
Method Details
-
toDecrypted
Encrypts a text with the latest known valid cipher.- Specified by:
toDecrypted
in interfaceorg.refcodes.security.Decrypter<String,
String, org.refcodes.security.DecryptionException> - Specified by:
toDecrypted
in interfaceDecryptionProvider
- 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 unknownNoCipherUidException
- 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 -
dispose
public void dispose()- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-