Search in sources :

Example 1 with CannotClearPasswordException

use of net.viperfish.journal.framework.errors.CannotClearPasswordException in project vsDiaryWriter by shilongdai.

the class OpenBSDBCryptAuthManager method clear.

/**
 * clears the content of the password file
 *
 * This method clears the content of the password file by writing an empty
 * string to the file.
 *
 * @throws CannotClearPasswordException
 *             if failed to write an empty string
 */
@Override
public synchronized void clear() throws CannotClearPasswordException {
    try {
        passwdFile.write("", StandardCharsets.US_ASCII);
        this.current = null;
        this.password = null;
    } catch (IOException e) {
        CannotClearPasswordException cp = new CannotClearPasswordException("Failed to clear password stored in the file:" + passwdFile.getFile() + ", message:" + e.getMessage());
        cp.initCause(e);
        throw cp;
    }
}
Also used : IOException(java.io.IOException) CannotClearPasswordException(net.viperfish.journal.framework.errors.CannotClearPasswordException)

Aggregations

IOException (java.io.IOException)1 CannotClearPasswordException (net.viperfish.journal.framework.errors.CannotClearPasswordException)1