Package org.apache.james.services

Examples of org.apache.james.services.User


     */
    protected User getUserByName(String name, boolean ignoreCase) {
        // Just iterate through all of the users until we find one matching.
        Iterator users = listAllUsers();
        while ( users.hasNext() ) {
            User user = (User)users.next();
            String username = user.getUserName();
            if (( !ignoreCase && username.equals(name) ) ||
                ( ignoreCase && username.equalsIgnoreCase(name) )) {
                return user;
            }
        }
View Full Code Here


     * @param name the name of the user to be added
     * @param attributes the password value as a String
     */
    public void addUser(String name, Object attributes)  {
        if (attributes instanceof String) {
            User newbie = new DefaultUser(name, "SHA");
            newbie.setPassword( (String) attributes );
            addUser(newbie);
        } else {
            throw new RuntimeException("Improper use of deprecated method"
                                       + " - use addUser(User user)");
        }
View Full Code Here

     * Removes a user from the repository
     *
     * @param user the user to be removed
     */
    public void removeUser(String name) {
        User user = getUserByName(name);
        if ( user != null ) {
            doRemoveUser(user);
        }
    }
View Full Code Here

     *
     * @return the correct case sensitive name of the user
     */
    public String getRealName(String name) {
        // Get the user by name, ignoring case, and return the correct name.
        User user = getUserByName(name, true);
        if ( user == null ) {
            return null;
        } else {
            return user.getUserName();
        }
    }
View Full Code Here

    /**
     * Returns whether or not this user is in the repository
     */
    public boolean contains(String name) {
        User user = getUserByName(name, false);
        return ( user != null );
    }
View Full Code Here

    /**
     * Returns whether or not this user is in the repository. Names are
     * matched on a case insensitive basis.
     */
    public boolean containsCaseInsensitive(String name) {
        User user = getUserByName( name, true );
        return ( user != null );
    }
View Full Code Here

     *              password is incorrect or the user doesn't
     *              exist
     * @since James 1.2.2
     */
    public boolean test(String name, String password) {
        User user = getUserByName(name, false);
        if ( user == null ) {
            return false;
        } else {
            return user.verifyPassword(password);
        }
    }
View Full Code Here

                conn.prepareStatement(m_getUsersSql);
            rsUsers = getUsersStatement.executeQuery();

            // Loop through and build a User for every row.
            while ( rsUsers.next() ) {
                User user = readUserFromResultSet(rsUsers);
                userList.add(user);
            }
        }
        catch ( SQLException sqlExc) {
            throw new CascadingRuntimeException("Error accessing database", sqlExc);
View Full Code Here

            getUsersStatement.setString(1, name.toLowerCase(Locale.US));

            rsUsers = getUsersStatement.executeQuery();

            // For case-insensitive matching, the first matching user will be returned.
            User user = null;
            while ( rsUsers.next() ) {
                User rowUser = readUserFromResultSet(rsUsers);
                String actualName = rowUser.getUserName();
                   
                // Check case before we assume it's the right one.
                if ( ignoreCase || actualName.equals(name) ) {
                    user = rowUser;
                    break;
View Full Code Here

        return true;
    }

    public void addUser(String name, Object attributes) {
        if (attributes instanceof String) {
            User newbie = new DefaultUser(name, "SHA");
            newbie.setPassword( (String) attributes);
            addUser(newbie);
        }
        else {
            throw new RuntimeException("Improper use of deprecated method"
                                       + " - use addUser(User user)");
View Full Code Here

TOP

Related Classes of org.apache.james.services.User

Copyright © 2018 www.massapicom. 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.