Package cu.ftpd.user

Examples of cu.ftpd.user.User


        }
    }

    public void setProperty(String username, String property, String value) throws RemoteException {
        try {
            User user = userbase.getUser(username);
            // setting will happen VERY rarely, so the speed of this isn't particularly important.
            if ("lastlog".equals(property)) {
                user.setLastlog(Long.parseLong(value));
            } else if ("primarygroup".equals(property)) {
                user.setPrimaryGroup(value);
            } else if ("addip".equals(property)) {
                user.addIp(value);
            } else if ("delip".equals(property)) {
                user.delIp(value);
            } else if ("addgadminforgroup".equals(property)) {
                user.addGadminForGroup(value);
            } else if ("removegadminforgroup".equals(property)) {
                user.removeGadminForGroup(value);
            } else if ("hidden".equals(property)) {
                user.setHidden(Boolean.parseBoolean(value));
            } else if ("password".equals(property)) {
                user.passwd(value);
            } else if ("tagline".equals(property)) {
                user.setTagline(value);
            } else if ("logins".equals(property)) {
                user.setLogins(Integer.parseInt(value));
            } else if ("suspended".equals(property)) {
                user.setSuspended(Boolean.parseBoolean(value));
            } else if ("addpermission".equals(property)) {
                user.addPermission(Integer.parseInt(value));
            } else if ("delpermission".equals(property)) {
                user.delPermission(Integer.parseInt(value));
            } else if ("autg".equals(property)) {
                // we check that the group exists in the site-command
                user.addGroup(value);
            } else if ("rufg".equals(property)) {
                user.removeGroup(value);
            } else {
                throw new IllegalArgumentException("Tried to find property that does not exist: [" + username + ':' + property + ':' + value + ']');
            }
        // NOTE: we can be guaranteed to not get any NumberFormatExceptions here, since the caller of this method does a conversion FROM the appropriate formate before sending it over the wire
        } catch (NoSuchUserException e) {
View Full Code Here


        }
    }

    protected boolean currentUserIsGadminForUser(String username, User user) {
        try {
            User u = ServiceManager.getServices().getUserbase().getUser(username);
            //current user is gadmin for any of the groups the specified user is a member of
            for (String gadminGroup : user.getGadminGroups()) { // this is generally a smaller set, so it makes sense to go over that first, since we abort early
                if (u.isMemberOfGroup(gadminGroup)) {
                    return true;
                }
            }
        } catch (NoSuchUserException e) {
            // you can't be the gadmin of a user that doesn't exist
View Full Code Here

        }
    }

    public String getProperty(String username, String property) throws RemoteException {
        try {
            User user = userbase.getUser(username);
            // this is where it would be nice to have a HashMap with function pointers
            if ("leech".equals(property)) {
                return String.valueOf(user.hasLeech());
            } else if ("hidden".equals(property)) {
                return String.valueOf(user.isHidden());
            } else if ("created".equals(property)) {
                return String.valueOf(user.getCreated());
            } else if ("tagline".equals(property)) {
                return user.getTagline();
            } else if ("logins".equals(property)) {
                return String.valueOf(user.getLogins());
            } else if ("lastlog".equals(property)) {
                return String.valueOf(user.getLastlog());
            } else if ("password".equals(property)) {
                return user.getHashedPassword();
            } else if ("suspended".equals(property)) {
                return String.valueOf(user.isSuspended());
            } else if ("permissions".equals(property)) {
                return user.getPermissions();
            } else {
                throw new IllegalArgumentException("Tried to find property that does not exist: [" + username + ':' + property + ']');
            }
        } catch (NoSuchUserException e) {
            Logging.getErrorLog().reportCritical("Trying to get property '" + property + "' for a user that does not exist: " + username);
View Full Code Here


    public Collection getCollection(String username, String collection) throws RemoteException {
        if (username != null) {
            try {
                User user = userbase.getUser(username);
                if ("groups".equals(collection)) {
                    return user.getGroups();
                } else if ("ips".equals(collection)) {
                    return user.getIps();
                } else if ("gadmingroups".equals(collection)) {
                    return user.getGadminGroups();
                } else {
                    throw new IllegalArgumentException("CRITICAL: Trying to get non-existant collection '" + collection + '\'');
                }
            } catch (NoSuchUserException e) {
                Logging.getErrorLog().reportCritical("Trying to get collection '" + collection + "' for a user that does not exist: " + username);
View Full Code Here

                if ("*".equals(parameterList[1])) {
                  for (User u : Sort.users(ServiceManager.getServices().getUserbase().getUsers().values())) {
                        printUser(u, connection);
                    }
                } else {
                    User u = ServiceManager.getServices().getUserbase().getUser(parameterList[1]);
                    printUser(u, connection);
                }
            } catch (NoSuchUserException e) {
                // do NOT tell the user that the user didn't exist!
                connection.respond("500 User has not been online yet.");
View Full Code Here

        }
    }

    protected boolean currentUserIsGadminForUser(String username, User user) {
        try {
            User u = ServiceManager.getServices().getUserbase().getUser(username);
            //current user is gadmin for any of the groups the specified user is a member of
            for (String gadminGroup : user.getGadminGroups()) { // this is generally a smaller set, so it makes sense to go over that first, since we abort early
                if (u.isMemberOfGroup(gadminGroup)) {
                    return true;
                }
            }
        } catch (NoSuchUserException e) {
            // you can't be the gadmin of a user that doesn't exist
View Full Code Here

     * @param arg2 the second argument.
     * @return the boolean value for the predicate with the provided arguments
     */
    public boolean getBoolean(String predicate, String arg1, String arg2) throws RemoteException, NoSuchUserException {

        User user;
        if ("isMemberOfGroup".equals(predicate)) {
            user = userbase.getUser(arg1);
            return user.isMemberOfGroup(arg2);
        } else if ("isGadminForGroup".equals(predicate)) {
            user = userbase.getUser(arg1);
            return user.isGadminForGroup(arg2);
        } else if ("hasPermission".equals(predicate)) {
            user = userbase.getUser(arg1);
            return user.hasPermission(Integer.parseInt(arg2));
        } else if ("userExists".equals(predicate)) {
            try {
                userbase.getUser(arg1);
                return true;
            } catch (NoSuchUserException e) {
View Full Code Here

     * @return the newly created user, or <tt>null</tt> if <tt>checkSpace</tt> was set to <tt>true</tt> and the group was already full.
     * @throws cu.ftpd.user.groups.NoSuchGroupException thrown if the specified group doesn't exist.
     * @throws UserExistsException thrown if there is already a user with the specified username.
     */
    public String gAddUser(String groupname, String username, String password, boolean checkSpace) throws NoSuchGroupException, UserExistsException, RemoteException, GroupLimitReachedException {
        User user = userbase.gAddUser(groupname, username, password, checkSpace);
        return user.getUsername();
    }
View Full Code Here

        User user = userbase.gAddUser(groupname, username, password, checkSpace);
        return user.getUsername();
    }

    public String addUser(String username, String password) throws UserExistsException, RemoteException {
        User user = userbase.addUser(username, password);
        return user.getUsername();
    }
View Full Code Here

    protected UserbaseAction() {
    }

    protected boolean currentUserIsGadminForUser(String username, User user) {
        try {
            User u = ServiceManager.getServices().getUserbase().getUser(username);
            //current user is gadmin for any of the groups the specified user is a member of
            for (String gadminGroup : user.getGadminGroups()) { // this is generally a smaller set, so it makes sense to go over that first, since we abort early
                if (u.isMemberOfGroup(gadminGroup)) {
                    return true;
                }
            }
        } catch (NoSuchUserException e) {
            // you can't be the gadmin of a user that doesn't exist
View Full Code Here

TOP

Related Classes of cu.ftpd.user.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.