C - the generic type of the cipherK - the generic type of the keypublic abstract class AbstractCryptor<C,K> extends Object implements Serializable, de.alpharogroup.crypto.api.Cryptor
AbstractCryptor provides factory methods that may or must be
overwritten dependent of the specific implementor class.| Modifier and Type | Field and Description |
|---|---|
protected de.alpharogroup.crypto.model.CryptModel<C,K> |
model
The crypto model.
|
| Constructor and Description |
|---|
AbstractCryptor(de.alpharogroup.crypto.model.CryptModel<C,K> model)
Constructor with the given
CryptModel. |
AbstractCryptor(K key)
Constructor with a key.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
newAlgorithm()
Factory method for creating a new algorithm that will be used with the cipher object.
|
protected AlgorithmParameterSpec |
newAlgorithmParameterSpec(byte[] salt,
int iterationCount)
Factory method for creating a new
AlgorithmParameterSpec from the given salt and
iteration count. |
protected C |
newCipher(K key)
Factory method for creating a new
Cipher from the given private key. |
protected abstract C |
newCipher(K key,
String algorithm,
byte[] salt,
int iterationCount,
int operationMode)
Factory method for creating a new
Cipher from the given parameters. |
protected int |
newIterationCount()
Factory method for creating a new iteration count that will be used with the cipher object.
|
protected byte[] |
newSalt()
Factory method for creating a new salt that will be used with the cipher object.
|
protected SecretKeyFactory |
newSecretKeyFactory(String algorithm)
Factory method for creating a new
SecretKeyFactory from the given algorithm. |
protected void |
onInitialize()
This method initialize the cipher object.
|
public AbstractCryptor(de.alpharogroup.crypto.model.CryptModel<C,K> model) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException
CryptModel.model - The crypt model.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.NoSuchPaddingException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.public AbstractCryptor(K key) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException
key - The key.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.NoSuchPaddingException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.protected String newAlgorithm()
protected AlgorithmParameterSpec newAlgorithmParameterSpec(byte[] salt, int iterationCount)
AlgorithmParameterSpec from the given salt and
iteration count. This method is invoked in the constructor from the derived classes and can
be overridden so users can provide their own version of a new AlgorithmParameterSpec
from the given salt and iteration count.salt - the saltiterationCount - the iteration countAlgorithmParameterSpec from the given salt and iteration count.protected C newCipher(K key) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException
Cipher from the given private key. This method is
invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a new Cipher from the given private key.key - the keyCipher from the given private key.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchPaddingException - is thrown if instantiation of the cypher object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.protected abstract C newCipher(K key, String algorithm, byte[] salt, int iterationCount, int operationMode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException
Cipher from the given parameters. This method is
invoked in the constructor from the derived classes and can be overridden so users can
provide their own version of a new Cipher from the given parameters.key - the keyalgorithm - the algorithmsalt - the salt.iterationCount - the iteration countoperationMode - the operation mode for the new cipher objectNoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchPaddingException - is thrown if instantiation of the cypher object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.protected int newIterationCount()
protected byte[] newSalt()
protected SecretKeyFactory newSecretKeyFactory(String algorithm) throws NoSuchAlgorithmException
SecretKeyFactory from the given algorithm. This
method is invoked in the constructor from the derived classes and can be overridden so users
can provide their own version of a new SecretKeyFactory from the given algorithm.algorithm - the algorithmSecretKeyFactory from the given algorithm.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.protected void onInitialize()
throws InvalidKeyException,
NoSuchAlgorithmException,
InvalidKeySpecException,
NoSuchPaddingException,
InvalidAlgorithmParameterException,
UnsupportedEncodingException
InvalidAlgorithmParameterException - is thrown if initialization of the cypher object fails.NoSuchPaddingException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException - is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException - is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException - is thrown if initialization of the cypher object fails.UnsupportedEncodingException - is thrown if the named charset is not supported.Copyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.