Example usage for javax.security.auth.login AccountNotFoundException toString

List of usage examples for javax.security.auth.login AccountNotFoundException toString

Introduction

In this page you can find the example usage for javax.security.auth.login AccountNotFoundException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabaseTest.java

public void testUpdatePasswordIsSavedToFile() {

    File testFile = createPasswordFile(1, 1);

    loadPasswordFile(testFile);/*from  w ww. j  a  v  a  2  s  . co  m*/

    Principal testUser = _database.getUser(USERNAME + "0");

    assertNotNull(testUser);

    String NEW_PASSWORD = "guest";
    String NEW_PASSWORD_HASH = "CE4DQ6BIb/BVMN9scFyLtA==";
    try {
        _database.updatePassword(testUser, NEW_PASSWORD.toCharArray());
    } catch (AccountNotFoundException e) {
        fail(e.toString());
    }

    try {
        BufferedReader reader = new BufferedReader(new FileReader(testFile));

        assertTrue("File has no content", reader.ready());

        assertEquals("Comment line has been corrupted.", TEST_COMMENT, reader.readLine());

        assertTrue("File is missing user data.", reader.ready());

        String userLine = reader.readLine();

        String[] result = Pattern.compile(":").split(userLine);

        assertEquals("User line not complete '" + userLine + "'", 2, result.length);

        assertEquals("Username not correct,", USERNAME + "0", result[0]);
        assertEquals("New Password not correct,", NEW_PASSWORD_HASH, result[1]);

        assertFalse("File has more content", reader.ready());

    } catch (IOException e) {
        fail("Unable to valdate file contents due to:" + e.getMessage());
    }
}