Package org.flasby.settings
Class Encrypt
java.lang.Object
org.flasby.settings.Encrypt
- Direct Known Subclasses:
MixedEncrypt
encrypts all key value pairs when adding them as a setting. decrypting will generate a new Cipher
instance for decryption as every encrypted value will likely have a different IV.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.flasby.settings.Settings
Settings.ApplyWithExistingValue, Settings.ApplyWithMissingKey
-
Constructor Summary
ConstructorsConstructorDescriptionEncrypt
(SimpleSettings settings, char[] passPhrase) create a wrapped SimpleSettings which is internally encrypted.Encrypt
(SimpleSettings settings, char[] passPhrase, byte[] salt, String keyAlgorithm) -
Method Summary
Modifier and TypeMethodDescriptionvoid
byte[]
decrypt
(byte[] encrypt) void
doIfExists
(String name, Settings.ApplyWithExistingValue ifExists) void
doIfExists
(String key, Settings.ApplyWithExistingValue ifExists, Settings.ApplyWithMissingKey otherwise) byte[]
encrypt
(byte[] toEncrypt) encrypt the plain byte array and prepend the IV value.gets a value from this settings group.boolean
isEmpty()
iterator()
static void
void
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Encrypt
create a wrapped SimpleSettings which is internally encrypted.- Parameters:
settings
- to be encrypted.- Throws:
Exception
-
Encrypt
public Encrypt(SimpleSettings settings, char[] passPhrase, byte[] salt, String keyAlgorithm) throws Exception - Throws:
Exception
-
-
Method Details
-
encrypt
-
encrypt
encrypt the plain byte array and prepend the IV value.- Parameters:
toEncrypt
-- Returns:
- a pair contaiing the IV and the encrypted array of bytes
- Throws:
Exception
-
decrypt
-
decrypt
- Throws:
Exception
-
main
- Throws:
Exception
-
iterator
-
get
Description copied from interface:SimpleSettings
gets a value from this settings group.- Specified by:
get
in interfaceSettings
- Specified by:
get
in interfaceSimpleSettings
- Parameters:
name
-- Returns:
-
add
- Specified by:
add
in interfaceSimpleSettings
-
remove
- Specified by:
remove
in interfaceSimpleSettings
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceSettings
- Specified by:
isEmpty
in interfaceSimpleSettings
-
doIfExists
- Specified by:
doIfExists
in interfaceSettings
-
doIfExists
public void doIfExists(String key, Settings.ApplyWithExistingValue ifExists, Settings.ApplyWithMissingKey otherwise) - Specified by:
doIfExists
in interfaceSettings
-