Class SensitiveString
java.lang.Object
org.jpos.security.SensitiveString
- All Implemented Interfaces:
AutoCloseable, Supplier<String>
Holds a sensitive string in memory under AES-GCM encryption with a
per-instance key, exposing the cleartext only on demand and zeroing
the buffer when the instance is cleaned.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new SensitiveString holding the encrypted form ofs. -
Method Summary
-
Constructor Details
-
SensitiveString
public SensitiveString(String s) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchProviderException, InvalidAlgorithmParameterException Constructs a new SensitiveString holding the encrypted form ofs.- Parameters:
s- plaintext to protect- Throws:
NoSuchAlgorithmException- if AES is unavailableNoSuchPaddingException- if the configured padding is unavailableInvalidKeyException- if the generated key is rejectedIllegalBlockSizeException- on AES-GCM block-size errorsBadPaddingException- on AES-GCM padding errorsNoSuchProviderException- if the configured provider is unavailableInvalidAlgorithmParameterException- if the IV/parameters are rejected
-
-
Method Details
-
equals
-
clean
Zeroes the encrypted buffer so the cleartext is no longer recoverable. -
get
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-