Class MemoryClearingBuffer
- java.lang.Object
-
- org.apache.directory.ldap.client.template.MemoryClearingBuffer
-
public final class MemoryClearingBuffer extends Object
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()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[].(package private) byte[]getComputedBytes()Returns a UTF8 encodedbyte[]representation of thechar[]used to create this buffer.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 Detail
-
newInstance
public static MemoryClearingBuffer newInstance(byte[] bytes)
Creates a new instance of MemoryClearingBuffer from abyte[].- Parameters:
bytes- A byte[]- Returns:
- A buffer
-
newInstance
public static MemoryClearingBuffer newInstance(char[] chars)
Creates a new instance of MemoryClearingBuffer from achar[].- Parameters:
chars- A char[]- Returns:
- A buffer
-
newInstance
public static MemoryClearingBuffer newInstance(char[] chars, boolean trim, boolean lowerCase)
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.
-
getComputedBytes
byte[] getComputedBytes()
Returns a UTF8 encodedbyte[]representation of thechar[]used to create this buffer.- Returns:
- A byte[]
-
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[]
-
-