Package org.refcodes.forwardsecrecy
Class DecryptionProviderImpl
- java.lang.Object
-
- org.refcodes.forwardsecrecy.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 theDecryptionProvider
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
Constructors Constructor Description DecryptionProviderImpl(DecryptionService aDecryptionService)
Constructs theDecryptionProvider
using AES as implemented by theBouncyCastleProvider
.DecryptionProviderImpl(DecryptionService aDecryptionService, java.security.Provider aJceProvider, java.lang.String aJceAlgorithm)
Constructs theDecryptionProvider
with the givenDecryptionService
and with the specified JCEProvider
as well as the according JCE algorithm.
-
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.
-
-
-
Constructor Detail
-
DecryptionProviderImpl
public DecryptionProviderImpl(DecryptionService aDecryptionService, java.security.Provider aJceProvider, java.lang.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
public DecryptionProviderImpl(DecryptionService aDecryptionService)
Constructs theDecryptionProvider
using AES as implemented by theBouncyCastleProvider
.- 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 interfaceorg.refcodes.security.Decrypter<java.lang.String,java.lang.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 javax.crypto.ShortBufferException, org.refcodes.security.DecryptionException
- Specified by:
toDecrypted
in interfaceorg.refcodes.security.Decrypter<java.lang.String,java.lang.String,org.refcodes.security.DecryptionException>
- Throws:
javax.crypto.ShortBufferException
org.refcodes.security.DecryptionException
-
-