- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionIBMJCECCACleaner(byte[] sensitiveDataByte) Constructs anIBMJCECCACleanerobject to securely manage sensitive byte data.IBMJCECCACleaner(char[] sensitiveData) Constructs anIBMJCECCACleanerobject to securely manage sensitive character data. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this resource, clearing any sensitive data held and performing cleanup.Optional<char[]>Retrieves a safe copy of the sensitive data (the char array) stored in this object.Optional<byte[]>Retrieves a safe copy of the sensitive data (the byte array) stored in this object.
-
Constructor Details
-
IBMJCECCACleaner
public IBMJCECCACleaner(char[] sensitiveData) Constructs anIBMJCECCACleanerobject to securely manage sensitive character data.This constructor takes an array of characters containing sensitive information and clones it to protect the integrity of the original data. It initializes a cleanup mechanism using a
Runnabledefined as a lambda expression that, when executed, will overwrite the cloned sensitive data with zeros, effectively clearing it from memory to minimize the risk of unauthorized access or data leakage.The cleaner function is registered for future execution, ensuring that the sensitive data can be securely erased when the
IBMJCECCACleanerobject is no longer in use or is eligible for garbage collection. This approach aids in maintaining data privacy and security throughout the lifecycle of the sensitive data.- Parameters:
sensitiveData- the character array containing the sensitive data to be managed and securely cleared when appropriate.
-
IBMJCECCACleaner
public IBMJCECCACleaner(byte[] sensitiveDataByte) Constructs anIBMJCECCACleanerobject to securely manage sensitive byte data.This constructor takes an array of bytes containing sensitive information and clones it to protect the integrity of the original data. It initializes a cleanup mechanism using a
Runnabledefined as a lambda expression that, when executed, will overwrite the cloned sensitive data with zeros, effectively clearing it from memory to minimize the risk of unauthorized access or data leakage.The cleaner function is registered for future execution, ensuring that the sensitive data can be securely erased when the
IBMJCECCACleanerobject is no longer in use or is eligible for garbage collection. This approach aids in maintaining data privacy and security throughout the lifecycle of the sensitive data.- Parameters:
sensitiveData- the byte array containing the sensitive data to be managed and securely cleared when appropriate.
-
-
Method Details
-
sensitiveData
Retrieves a safe copy of the sensitive data (the char array) stored in this object.This method provides access to the sensitive data in a secure manner by returning an
Optionalthat contains a clone of the internal character array. If the internal data isnull, it returns an emptyOptionalinstead. This approach ensures that any modifications to the returned data do not affect the original sensitive data stored within the object.Use this method to access the sensitive data when needed, and be mindful to handle the data securely to prevent any unauthorized access or data leaks.
-
sensitiveDataByte
Retrieves a safe copy of the sensitive data (the byte array) stored in this object.This method provides access to the sensitive data in a secure manner by returning an
Optionalthat contains a clone of the internal byte array. If the internal data isnull, it returns an emptyOptionalinstead. This approach ensures that any modifications to the returned data do not affect the original sensitive data stored within the object.Use this method to access the sensitive data when needed, and be mindful to handle the data securely to prevent any unauthorized access or data leaks.
-
close
public void close()Closes this resource, clearing any sensitive data held and performing cleanup.This method sets any internal references to sensitive data to
nullto aid in their garbage collection and reduce the risk of sensitive data exposure. It also explicitly invokes the cleanup process on thecleanableresource associated with this object, which should contain logic to securely erase the sensitive data from memory.It's recommended to call this method when the instance is no longer needed to ensure that sensitive information is properly handled and memory resources are released in a timely manner. Failure to call this method could result in prolonged exposure of sensitive data in memory.
- Specified by:
closein interfaceAutoCloseable
-