Package cu.ftpd.user

Examples of cu.ftpd.user.User


        connection.respond("200 End of permissions.");
    }

    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 void execute(String[] parameterList, Connection connection, User user, FileSystem fs) {
        if (user.hasPermission(UserPermission.GROUPS)) { // gadmins can't add EXISTING users to their groups
            try {
                User u = ServiceManager.getServices().getUserbase().getUser(parameterList[1]);
                ServiceManager.getServices().getUserbase().getGroup(parameterList[2]); // this is done to verify that the group exists
                u.addGroup(parameterList[2]);
                connection.respond("200 sucessfully added user " + parameterList[1] + " to group " + parameterList[2] + '.');
            } catch (NoSuchUserException e) {
                connection.respond("500 " + e.getMessage());
            } catch (NoSuchGroupException e) {
                connection.respond("500 " + e.getMessage());
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

            if (user.hasPermission(UserPermission.ADDUSER)) {
                try {
                    // NOTE: this needs to be the cleartext password. we leave it up to the userbase in question how to deal with it.
                    // this is ok because we are either doing it in memory (LocalUserbase) or over an encrypted socket (RemoteUserbase).

                    User newuser = ServiceManager.getServices().getUserbase().addUser(parameterList[1], parameterList[2]);
                    // add ips if there are any. A user with no ip cannot log in
                    if (newuser != null) {
                        String wrongIps = "";
                        for (int i = 3; i < parameterList.length; i++) {
                            if (ip.matcher(parameterList[i]).matches()) {
                                newuser.addIp(parameterList[i]);
                            } else {
                                wrongIps += parameterList[i] + ' ';
                            }
                        }
                        connection.respond("200 User " + parameterList[1] + " successfully added." + (wrongIps.length() > 0 ? " The following ips were wrong: " + wrongIps : ""));
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 DelIP() {
        super("delip");
    }

    public void execute(String[] parameterList, Connection connection, User user, FileSystem fs) {
        User u;
        if (parameterList.length >= 3) {
            if (!user.hasPermission(UserPermission.USEREDIT) && !currentUserIsGadminForUser(parameterList[1], user)) {
                connection.respond("531 Permission denied.");
                return;
            } else {
                try {
                    u = ServiceManager.getServices().getUserbase().getUser(parameterList[1]); // this means that we are doing the user lookup twice, but it doesn't really matter, since it's O(1) in a hash map, and this happens rarely
                } catch (NoSuchUserException e) {
                    connection.respond("500 " + e.getMessage());
                    return;
                }
            }
        } else if (parameterList.length == 2) {
            u = user;
        } else {
            connection.respond("500 Syntax error: site delip [username] ident@ip");
            return;
        }
        String malformedIps = "";
        String removedIps = "";
        String invalidIps = "";
        for (int i = 2; i < parameterList.length; i++) {
            if (ip.matcher(parameterList[i]).matches()) {
                if (u.getIps().contains(parameterList[i])) {
                    u.delIp(parameterList[i]);
                    removedIps += parameterList[i] + ' ';
                } else {
                    invalidIps += parameterList[i] + ' ';
                }
            } else {
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

        if (user.hasPermission(UserPermission.KICK)) {
            Set<Connection> conns = Server.getInstance().getConnections();
            connection.respond(String.format(lineFormat, "Id", "Username", "Idletime", "ident@host", "Command"));
            synchronized(conns) {
                for (Connection c : conns) {
                    User u = c.getUser();
                    if (c.isUploading() || c.isDownloading()) {
                        connection.respond(String.format(lineFormat, c.getConnectionId(), (u == null ? "n/a" : u.getUsername()), c.getIdleTime(), c.getIdent() + "@" + c.getHost(), c.getLastCommand() + " @ " + Formatter.speedFromKBps(c.getCurrentSpeed())));
                    } else {
                        connection.respond(String.format(lineFormat, c.getConnectionId(), (u == null ? "n/a" : u.getUsername()), c.getIdleTime(), c.getIdent() + "@" + c.getHost(), "Idle"));
                    }
                }
                connection.respond("200 xwho");
            }
         } else {
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

        }
    }

    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.