Package cu.ftpd.user.groups

Examples of cu.ftpd.user.groups.Group


    }

    public void execute(String[] parameterList, Connection connection, User user, FileSystem fs) {
        if (user.hasPermission(UserPermission.GROUPS) && user.hasPermission(UserPermission.USEREDIT)) {
            try {
                Group g = ServiceManager.getServices().getUserbase().getGroup(parameterList[2]);
                User u = ServiceManager.getServices().getUserbase().getUser(parameterList[1]);
                if (add) {
                    u.addGroup(g.getName()); // must be a member of the group you are adminning
                    u.addGadminForGroup(g.getName());
                } else {
                    u.removeGadminForGroup(g.getName());
                }
                connection.respond("200 Operation completed successfully.");
            } catch (NoSuchGroupException e) {
                connection.respond("550 " + e.getMessage());
            } catch (NoSuchUserException e) {
View Full Code Here


            File groupfile = new File(glftpdRoot, "/etc/group");
            in = new BufferedReader(new InputStreamReader(new FileInputStream(groupfile)));
            String line;
            while ((line = in.readLine()) != null) {
                String[] parts = line.split(":");
                Group g = null;
                try {
                    g = userbase.createGroup(parts[0], parts[1]);
                } catch (GroupExistsException e) {
                    System.err.println(e.getMessage());
                    System.err.println("skipping...");
                    continue;
                }
                File detailedGroupfile = new File(glftpdRoot, "/ftp-data/groups/" + g.getName());
                try {
                    fillGroup(g, detailedGroupfile);
                } catch (IOException e) {
                    System.err.println("Failed to read groupfile: " + e.getMessage());
                }
View Full Code Here

        return null;
    }

    public String getGroupProperty(String groupname, String property) throws RemoteException {
        try {
            Group g = userbase.getGroup(groupname);
            // this is where it would be nice to have a HashMap with function pointers
            if ("getgroupslots".equals(property)) {
                return String.valueOf(g.getSlots());
            } else if ("getleechslots".equals(property)) {
                return String.valueOf(g.getLeechSlots());
            } else if ("getdescription".equals(property)) {
                return g.getDescription();
            } else if ("getmaxallotment".equals(property)) {
                return String.valueOf(g.getMaxAllotment());
            } else if ("getallotmentslots".equals(property)) {
                return String.valueOf(g.getAllotmentSlots());
            } else {
                throw new IllegalArgumentException("Tried to find property that does not exist: [" + groupname + ':' + property + ']');
            }
        } catch (NoSuchGroupException e) {
            Logging.getErrorLog().reportCritical("Trying to get property '" + property + "' for a group that does not exist: " + groupname);
View Full Code Here

        return null;
    }

    public void setGroupProperty(String groupname, String property, String value) throws RemoteException {
        try {
            Group g = userbase.getGroup(groupname);
            // this is where it would be nice to have a HashMap with function pointers
            if ("setgroupslots".equals(property)) {
                g.setSlots(Integer.parseInt(value));
            } else if ("setleechslots".equals(property)) {
                g.setLeechSlots(Integer.parseInt(value));
            } else if ("setdescription".equals(property)) {
                g.setDescription(value);
            } else if ("setmaxallotment".equals(property)) {
                g.setMaxAllotment(Long.parseLong(value));
            } else if ("setallotmentslots".equals(property)) {
                g.setAllotmentSlots(Integer.parseInt(value));
            } else {
                throw new IllegalArgumentException("Tried to find property that does not exist: [" + groupname + ':' + property + ']');
            }
        // 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 (NoSuchGroupException e) {
View Full Code Here

        }
    }

    public Group createGroup(String name, String description) throws GroupExistsException {
        try {
            Group g = rmi.createGroup(name, description);
            // otherwise we get a group of the wrong type
            return new RemoteGroup(g.getName(), this);
        } catch (RemoteException e) {
            System.err.println(e.getMessage()); reinitialize();
            return createGroup(name, description);
        }
    }
View Full Code Here

TOP

Related Classes of cu.ftpd.user.groups.Group

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.