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

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

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

public void testDeletePrincipal() {
    File testFile = createPasswordFile(1, 1);

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

    Principal user = _database.getUser(USERNAME + "0");
    assertNotNull("Generated user not present.", user);

    try {
        _database.deletePrincipal(user);
    } catch (AccountNotFoundException e) {
        fail("User should be present" + e.getMessage());
    }

    try {
        _database.deletePrincipal(user);
        fail("User should not be present");
    } catch (AccountNotFoundException e) {
        //pass
    }

    loadPasswordFile(testFile);

    try {
        _database.deletePrincipal(user);
        fail("User should not be present");
    } catch (AccountNotFoundException e) {
        //pass
    }

    assertNull("Deleted user still present.", _database.getUser(USERNAME + "0"));
}

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

public void testUpdatePasswordIsSavedToFile() {

    File testFile = createPasswordFile(1, 1);

    loadPasswordFile(testFile);/*from  www.  j av a2s  .  c  om*/

    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());
    }
}