Examples of UsersRepositoryException


Examples of org.apache.james.user.api.UsersRepositoryException

    @Override
    protected void doAddUser(String username, String password) throws UsersRepositoryException {
        String lowerCasedUsername = username.toLowerCase();
        if (contains(lowerCasedUsername)) {
            throw new UsersRepositoryException(lowerCasedUsername + " already exists.");
        }
        try {
            final Session session = login();
            try {
                final String name = toSafeName(lowerCasedUsername);
                final String path = USERS_PATH + "/" + name;
                final Node rootNode = session.getRootNode();
                try {
                    rootNode.getNode(path);
                    getLogger().info("User already exists");
                    throw new UsersRepositoryException("User " + lowerCasedUsername + " already exists");
                } catch (PathNotFoundException e) {
                    // user does not exist
                }
                Node parent;
                try {
                    parent = rootNode.getNode(USERS_PATH);
                } catch (PathNotFoundException e) {
                    // TODO: Need to consider whether should insist that parent
                    // TODO: path exists.
                    parent = rootNode.addNode(USERS_PATH);
                }

                Node node = parent.addNode(name);
                node.setProperty(USERNAME_PROPERTY, lowerCasedUsername);
                final String hashedPassword;
                if (password == null) {
                    // Support easy password reset
                    hashedPassword = "";
                } else {
                    hashedPassword = JCRUser.hashPassword(lowerCasedUsername, password);
                }
                node.setProperty(PASSWD_PROPERTY, hashedPassword);
                session.save();
            } finally {
                session.logout();
            }

        } catch (RepositoryException e) {
            if (getLogger().isInfoEnabled()) {
                getLogger().info("Failed to add user: " + lowerCasedUsername, e);
            }
            throw new UsersRepositoryException("Failed to add user: " + lowerCasedUsername, e);

        }

    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    public int countUsers() throws UsersRepositoryException {
        try {
            return getValidUsers().size();
        } catch (NamingException e) {
            log.error("Unable to retrieve user count from ldap", e);
            throw new UsersRepositoryException("Unable to retrieve user count from ldap", e);

        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    public User getUserByName(String name) throws UsersRepositoryException {
        try {
          return searchAndBuildUser(name);
        } catch (NamingException e) {
            log.error("Unable to retrieve user from ldap", e);
            throw new UsersRepositoryException("Unable to retrieve user from ldap", e);

        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

                }
            }

        } catch (NamingException e) {
            log.error("Unable to retrieve user from ldap", e);
            throw new UsersRepositoryException("Unable to retrieve user from ldap", e);

        }
        return null;
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

            for (ReadOnlyLDAPUser readOnlyLDAPUser : buildUserCollection(getValidUsers())) {
                result.add(readOnlyLDAPUser.getUserName());
            }
        } catch (NamingException namingException) {
            throw new UsersRepositoryException(
                    "Unable to retrieve users list from LDAP due to unknown naming error.",
                    namingException);
        }

        return result.iterator();
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    /**
     * @see UsersRepository#removeUser(java.lang.String)
     */
    public void removeUser(String name) throws UsersRepositoryException {
        log.warn("This user-repository is read-only. Modifications are not permitted.");
        throw new UsersRepositoryException(
                "This user-repository is read-only. Modifications are not permitted.");

    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    /**
     * @see UsersRepository#addUser(java.lang.String, java.lang.String)
     */
    public void addUser(String username, String password) throws UsersRepositoryException {
        log.error("This user-repository is read-only. Modifications are not permitted.");
        throw new UsersRepositoryException(
                "This user-repository is read-only. Modifications are not permitted.");
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    /**
     */
    public void updateUser(User user) throws UsersRepositoryException {
        log.error("This user-repository is read-only. Modifications are not permitted.");
        throw new UsersRepositoryException(
                "This user-repository is read-only. Modifications are not permitted.");
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

    /**
     * @see org.apache.james.user.lib.AbstractJamesUsersRepository#doAddUser(org.apache.james.user.api.model.User)
     */
    protected void doAddUser(User user) throws UsersRepositoryException {
        if (contains(user.getUserName())) {
            throw new UsersRepositoryException(user.getUserName() + " already exists.");
        }
        try {
            objectRepository.put(user.getUserName(), user);
        } catch (Exception e) {
            throw new UsersRepositoryException("Exception caught while storing user: " + e);
        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

        }
        if (contains(name)) {
            try {
                return (User) objectRepository.get(name);
            } catch (Exception e) {
                throw new UsersRepositoryException("Exception while retrieving user: " + e.getMessage());
            }
        } else {
            return null;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.