/** * Mark this string as read-only. * @throws IllegalStateException If the string has been disposed */ public void makeReadOnly() { checkNotDisposed(); _readOnly = true; }
/** * Returns true if this string has been marked read-only. * * @return true if this string has been marked read-only. * @throws IllegalStateException * If the string has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return readOnly; }
/** * Mark this string as read-only. * * @throws IllegalStateException * If the string has been disposed */ public void makeReadOnly() { checkNotDisposed(); readOnly = true; }
/** * Returns true iff this string has been marked read-only * @return true iff this string has been marked read-only * @throws IllegalStateException If the string has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return _readOnly; }
/** * Returns true if this string has been marked read-only. * * @return true if this string has been marked read-only. * @throws IllegalStateException * If the string has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return readOnly; }
/** * Mark this string as read-only. * * @throws IllegalStateException * If the string has been disposed */ public void makeReadOnly() { checkNotDisposed(); readOnly = true; }
/** * Verifies that this base-64 encoded SHA1 hash of this string * matches the given value. * @param hash The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException If the string has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return _base64SHA1Hash.equals(hash); }
/** * Verifies that this base-64 encoded SHA1 hash of this string matches the * given value. * * @param hash * The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException * If the string has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return base64SHA1Hash.equals(hash); }
/** * Verifies that this base-64 encoded SHA1 hash of this string matches the * given value. * * @param hash * The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException * If the string has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return base64SHA1Hash.equals(hash); }
/** * Create a copy of the string. If this instance is read-only, * the copy will not be read-only. * @return A copy of the string. * @throws IllegalStateException If the string has been disposed */ public GuardedString copy() { checkNotDisposed(); byte [] encryptedBytes2 = new byte[_encryptedBytes.length]; System.arraycopy(_encryptedBytes, 0, encryptedBytes2, 0, _encryptedBytes.length); GuardedString rv = new GuardedString(); rv._encryptedBytes = encryptedBytes2; return rv; }
/** * Create a copy of the string. * * If this instance is read-only, the copy will not be read-only. * * @return A copy of the string. * @throws IllegalStateException * If the string has been disposed */ public GuardedString copy() { checkNotDisposed(); byte[] encryptedBytes2 = new byte[encryptedBytes.length]; System.arraycopy(encryptedBytes, 0, encryptedBytes2, 0, encryptedBytes.length); GuardedString rv = new GuardedString(); rv.encryptedBytes = encryptedBytes2; return rv; }
/** * Create a copy of the string. * * If this instance is read-only, the copy will not be read-only. * * @return A copy of the string. * @throws IllegalStateException * If the string has been disposed */ public GuardedString copy() { checkNotDisposed(); byte[] encryptedBytes2 = new byte[encryptedBytes.length]; System.arraycopy(encryptedBytes, 0, encryptedBytes2, 0, encryptedBytes.length); GuardedString rv = new GuardedString(); rv.encryptedBytes = encryptedBytes2; return rv; }
/** * Provides access to the clear-text value of the string in a controlled fashion. * The clear-text characters will only be available for the duration of the call * and automatically zeroed out following the call. * * <p> * <b>NOTE:</b> Callers are encouraged to use {@link #verifyBase64SHA1Hash(String)} * where possible if the intended use is merely to verify the contents of * the string match an expected hash value. * @param accessor Accessor callback. * @throws IllegalStateException If the string has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); char [] clearChars = null; try { clearChars = decryptChars(); accessor.access(clearChars); } finally { SecurityUtil.clear(clearChars); } }
/** * Provides access to the clear-text value of the string in a controlled * fashion. * * The clear-text characters will only be available for the duration of the * call and automatically zeroed out following the call. * <p> * <b>NOTE:</b> Callers are encouraged to use * {@link #verifyBase64SHA1Hash(String)} where possible if the intended use * is merely to verify the contents of the string match an expected hash * value. * * @param accessor * Accessor callback. * @throws IllegalStateException * If the string has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); char[] clearChars = null; try { clearChars = decryptChars(); accessor.access(clearChars); } finally { SecurityUtil.clear(clearChars); } }
/** * Provides access to the clear-text value of the string in a controlled * fashion. * * The clear-text characters will only be available for the duration of the * call and automatically zeroed out following the call. * <p> * <b>NOTE:</b> Callers are encouraged to use * {@link #verifyBase64SHA1Hash(String)} where possible if the intended use * is merely to verify the contents of the string match an expected hash * value. * * @param accessor * Accessor callback. * @throws IllegalStateException * If the string has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); char[] clearChars = null; try { clearChars = decryptChars(); accessor.access(clearChars); } finally { SecurityUtil.clear(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); } }