Class MemoryClearingBuffer
java.lang.Object
org.apache.directory.ldap.client.template.MemoryClearingBuffer
A buffer for storing sensitive information like passwords. It provides
useful operations for characters such as character encoding/decoding,
whitespace trimming, and lowercasing. It can be cleared out when operations
are complete.
- Author:
- Apache Directory Project
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the buffer out, filling its cells with null.byte[]getBytes()Returns thebyte[]used to create this buffer, or getComputedBytes() if created with achar[].char[]getChars()Returns thechar[]used to create this buffer, or getComputedChars() if created with abyte[].static MemoryClearingBuffernewInstance(byte[] bytes) Creates a new instance of MemoryClearingBuffer from abyte[].static MemoryClearingBuffernewInstance(char[] chars) Creates a new instance of MemoryClearingBuffer from achar[].static MemoryClearingBuffernewInstance(char[] chars, boolean trim, boolean lowerCase) Creates a new instance of MemoryClearingBuffer from achar[], optionally performing whitespace trimming and conversion to lower case.
-
Method Details
-
newInstance
Creates a new instance of MemoryClearingBuffer from abyte[].- Parameters:
bytes- A byte[]- Returns:
- A buffer
-
newInstance
Creates a new instance of MemoryClearingBuffer from achar[].- Parameters:
chars- A char[]- Returns:
- A buffer
-
newInstance
Creates a new instance of MemoryClearingBuffer from achar[], optionally performing whitespace trimming and conversion to lower case.- Parameters:
chars- A char[]trim- If true, whitespace will be trimmed off of both ends of thechar[]lowerCase- If true, the characters will be converted to lower case- Returns:
- A buffer
-
clear
public void clear()Clears the buffer out, filling its cells with null. -
getBytes
public byte[] getBytes()Returns thebyte[]used to create this buffer, or getComputedBytes() if created with achar[].- Returns:
- A byte[]
-
getChars
public char[] getChars()Returns thechar[]used to create this buffer, or getComputedChars() if created with abyte[].- Returns:
- A byte[]
-