Package org.refcodes.forwardsecrecy
Class AbstractCipherVersionGenerator<CV extends CipherVersion>
- java.lang.Object
-
- org.refcodes.forwardsecrecy.AbstractCipherVersionGenerator<CV>
-
- Type Parameters:
CV
- The type of theCipherVersion
to be generated.
- All Implemented Interfaces:
Iterator<CV>
,CipherVersionGenerator<CV>
,org.refcodes.generator.Generator<CV>
- Direct Known Subclasses:
CipherVersionGeneratorImpl
public abstract class AbstractCipherVersionGenerator<CV extends CipherVersion> extends Object implements CipherVersionGenerator<CV>
Default implementation of a cipher version generator.
-
-
Constructor Summary
Constructors Constructor Description AbstractCipherVersionGenerator(CipherVersionFactory<CV> aCipherVersionFactory)
Constructor for theAbstractCipherVersionGenerator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
createCipher()
Hook factory method to be implemented by subclasses.protected String
createCipherUid()
Hook factory method to be implemented by subclasses.boolean
hasNext()
CV
next()
Generator method to be implemented by subclasses.void
remove()
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
AbstractCipherVersionGenerator
public AbstractCipherVersionGenerator(CipherVersionFactory<CV> aCipherVersionFactory)
Constructor for theAbstractCipherVersionGenerator
. The providedCipherVersionFactory
is used to create the actualCipherVersion
instances generated by thisCipherVersionGenerator
.- Parameters:
aCipherVersionFactory
- TheCipherVersionFactory
used to create theCipherVersion
instances of the required type.
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceorg.refcodes.generator.Generator<CV extends CipherVersion>
- Specified by:
hasNext
in interfaceIterator<CV extends CipherVersion>
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<CV extends CipherVersion>
-
next
public CV next()
Generator method to be implemented by subclasses. Required to create implementation dependent cipher version objects. Retrieves the next valid cipher which may be used for encrypting data.- Specified by:
next
in interfaceCipherVersionGenerator<CV extends CipherVersion>
- Specified by:
next
in interfaceorg.refcodes.generator.Generator<CV extends CipherVersion>
- Specified by:
next
in interfaceIterator<CV extends CipherVersion>
- Returns:
- The next valid
CipherVersion
for encryption.
-
createCipherUid
protected String createCipherUid()
Hook factory method to be implemented by subclasses. A special algorithm can be used to generate unique cipher UIDs. In case the cipher UID is not unique, another one is requested until a cipher UID is found which is unique regarding the systems of forward secrecy cryptography architecture.- Returns:
- A more or less unique cipher UID.
-
createCipher
protected String createCipher()
Hook factory method to be implemented by subclasses. A special algorithm is to be implemented creating a good random cipher.- Returns:
- A good random cipher.
-
-