/** * Returns true iff this byte array has been marked read-only * @return true iff this byte array has been marked read-only * @throws IllegalStateException If the byte array has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return _readOnly; }
/** * Returns true if this byte array has been marked read-only. * * @return true if this byte array has been marked read-only * @throws IllegalStateException * If the byte array has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return readOnly; }
/** * Mark this byte array as read-only. * * @throws IllegalStateException * If the byte array has been disposed */ public void makeReadOnly() { checkNotDisposed(); readOnly = true; }
/** * Mark this byte array as read-only. * @throws IllegalStateException If the byte array has been disposed */ public void makeReadOnly() { checkNotDisposed(); _readOnly = true; }
/** * Returns true if this byte array has been marked read-only. * * @return true if this byte array has been marked read-only * @throws IllegalStateException * If the byte array has been disposed */ public boolean isReadOnly() { checkNotDisposed(); return readOnly; }
/** * Mark this byte array as read-only. * * @throws IllegalStateException * If the byte array has been disposed */ public void makeReadOnly() { checkNotDisposed(); readOnly = true; }
/** * Verifies that this base-64 encoded SHA1 hash of this byte array * matches the given value. * @param hash The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException If the byte array has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return _base64SHA1Hash.equals(hash); }
/** * Verifies that this base-64 encoded SHA1 hash of this byte array matches * the given value. * * @param hash * The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException * If the byte array has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return base64SHA1Hash.equals(hash); }
/** * Verifies that this base-64 encoded SHA1 hash of this byte array matches * the given value. * * @param hash * The hash to verify against. * @return True if the hash matches the given parameter. * @throws IllegalStateException * If the byte array has been disposed */ public boolean verifyBase64SHA1Hash(String hash) { checkNotDisposed(); return base64SHA1Hash.equals(hash); }
/** * Create a copy of the byte array. * * If this instance is read-only, the copy will not be read-only. * * @return A copy of the byte array. * @throws IllegalStateException * If the byte array has been disposed */ public GuardedByteArray copy() { checkNotDisposed(); byte[] encryptedBytes2 = new byte[encryptedBytes.length]; System.arraycopy(encryptedBytes, 0, encryptedBytes2, 0, encryptedBytes.length); GuardedByteArray rv = new GuardedByteArray(); rv.encryptedBytes = encryptedBytes2; return rv; }
/** * Create a copy of the byte array. If this instance is read-only, * the copy will not be read-only. * @return A copy of the byte array. * @throws IllegalStateException If the byte array has been disposed */ public GuardedByteArray copy() { checkNotDisposed(); byte [] encryptedBytes2 = new byte[_encryptedBytes.length]; System.arraycopy(_encryptedBytes, 0, encryptedBytes2, 0, _encryptedBytes.length); GuardedByteArray rv = new GuardedByteArray(); rv._encryptedBytes = encryptedBytes2; return rv; }
/** * Create a copy of the byte array. * * If this instance is read-only, the copy will not be read-only. * * @return A copy of the byte array. * @throws IllegalStateException * If the byte array has been disposed */ public GuardedByteArray copy() { checkNotDisposed(); byte[] encryptedBytes2 = new byte[encryptedBytes.length]; System.arraycopy(encryptedBytes, 0, encryptedBytes2, 0, encryptedBytes.length); GuardedByteArray rv = new GuardedByteArray(); rv.encryptedBytes = encryptedBytes2; return rv; }
/** * Provides access to the clear-text value of the byte array in a controlled fashion. * The clear-text bytes 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 byte array match an expected hash value. * @param accessor Accessor callback. * @throws IllegalStateException If the byte array has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); byte[] clearBytes = null; try { clearBytes = decryptBytes(); accessor.access(clearBytes); } finally { SecurityUtil.clear(clearBytes); } }
/** * Provides access to the clear-text value of the byte array in a controlled * fashion. * * The clear-text bytes 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 byte array match an expected hash * value. * * @param accessor * Accessor callback. * @throws IllegalStateException * If the byte array has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); byte[] clearBytes = null; try { clearBytes = decryptBytes(); accessor.access(clearBytes); } finally { SecurityUtil.clear(clearBytes); } }
/** * Provides access to the clear-text value of the byte array in a controlled * fashion. * * The clear-text bytes 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 byte array match an expected hash * value. * * @param accessor * Accessor callback. * @throws IllegalStateException * If the byte array has been disposed */ public void access(Accessor accessor) { checkNotDisposed(); byte[] clearBytes = null; try { clearBytes = decryptBytes(); accessor.access(clearBytes); } finally { SecurityUtil.clear(clearBytes); } }
/** * Appends a single clear-text byte to the secure byte array. * The in-memory data will be decrypted, the byte will be * appended, and then it will be re-encrypted. * @param b The byte to append. * @throws IllegalStateException If the byte array is read-only * @throws IllegalStateException If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length+1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length-1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }
/** * Appends a single clear-text byte to the secure byte array. * * The in-memory data will be decrypted, the byte will be appended, and then * it will be re-encrypted. * * @param b * The byte to append. * @throws IllegalStateException * If the byte array is read-only * @throws IllegalStateException * If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length + 1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length - 1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }
/** * Appends a single clear-text byte to the secure byte array. * * The in-memory data will be decrypted, the byte will be appended, and then * it will be re-encrypted. * * @param b * The byte to append. * @throws IllegalStateException * If the byte array is read-only * @throws IllegalStateException * If the byte array has been disposed */ public void appendByte(byte b) { checkNotDisposed(); checkWriteable(); byte[] clearBytes = null; byte[] clearBytes2 = null; try { clearBytes = decryptBytes(); clearBytes2 = new byte[clearBytes.length + 1]; System.arraycopy(clearBytes, 0, clearBytes2, 0, clearBytes.length); clearBytes2[clearBytes2.length - 1] = b; encryptBytes(clearBytes2); } finally { SecurityUtil.clear(clearBytes); SecurityUtil.clear(clearBytes2); } }