/** * Initialized the GuardedString from the given clear characters. * Caller is responsible for zeroing out the array of characters * after the call. * @param clearChars The clear-text characters */ public GuardedString(char [] clearChars) { encryptChars(clearChars); }
/** * Initialized the GuardedString from the given clear characters. * * Caller is responsible for zeroing out the array of characters after the * call. * * @param clearChars * The clear-text characters */ public GuardedString(char[] clearChars) { encryptChars(clearChars); }
/** * Initialized the GuardedString from the given clear characters. * * Caller is responsible for zeroing out the array of characters after the * call. * * @param clearChars * The clear-text characters */ public GuardedString(char[] clearChars) { encryptChars(clearChars); }
/** * Appends a single clear-text character to the secure string. * The in-memory data will be decrypted, the character will be * appended, and then it will be re-encrypted. * @param c The character to append. * @throws IllegalStateException If the string is read-only * @throws IllegalStateException If the string has been disposed */ public void appendChar(char c) { checkNotDisposed(); checkWriteable(); char [] clearChars = null; char [] clearChars2 = null; try { clearChars = decryptChars(); clearChars2 = new char[clearChars.length+1]; System.arraycopy(clearChars, 0, clearChars2, 0, clearChars.length); clearChars2[clearChars2.length-1] = c; encryptChars(clearChars2); } finally { SecurityUtil.clear(clearChars); SecurityUtil.clear(clearChars2); } }
/** * Appends a single clear-text character to the secure string. * * The in-memory data will be decrypted, the character will be appended, and * then it will be re-encrypted. * * @param c * The character to append. * @throws IllegalStateException * If the string is read-only * @throws IllegalStateException * If the string has been disposed */ public void appendChar(char c) { checkNotDisposed(); checkWriteable(); char[] clearChars = null; char[] clearChars2 = null; try { clearChars = decryptChars(); clearChars2 = new char[clearChars.length + 1]; System.arraycopy(clearChars, 0, clearChars2, 0, clearChars.length); clearChars2[clearChars2.length - 1] = c; encryptChars(clearChars2); } finally { SecurityUtil.clear(clearChars); SecurityUtil.clear(clearChars2); } }
/** * Appends a single clear-text character to the secure string. * * The in-memory data will be decrypted, the character will be appended, and * then it will be re-encrypted. * * @param c * The character to append. * @throws IllegalStateException * If the string is read-only * @throws IllegalStateException * If the string has been disposed */ public void appendChar(char c) { checkNotDisposed(); checkWriteable(); char[] clearChars = null; char[] clearChars2 = null; try { clearChars = decryptChars(); clearChars2 = new char[clearChars.length + 1]; System.arraycopy(clearChars, 0, clearChars2, 0, clearChars.length); clearChars2[clearChars2.length - 1] = c; encryptChars(clearChars2); } finally { SecurityUtil.clear(clearChars); SecurityUtil.clear(clearChars2); } }