@Override
    public boolean commit() throws LoginException
    {
        if (debug)
        {
            LOG.debug("committing authentication");
        }

        if (!succeeded)
        {
            return false;
        }

        userPrincipal = new UserPrincipal(username);
        addNonExistentPrincipal(userPrincipal);

        List<String> roles = authenticationDao.loadRoles(username);
        for (String role : roles)
        {
            RolePrincipal rolePrincipal = new RolePrincipal(role);
            addNonExistentPrincipal(rolePrincipal);
        }

        username = null;
        commitSucceeded = true;

        return true;
    }