Package cu.ftpd.filesystem.permissions

Examples of cu.ftpd.filesystem.permissions.PermissionDeniedException


        } else {
            // nlst the pwd
            dir = pwdFile;
        }
        if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.LIST, resolvePath(dir), user)) {
            throw new PermissionDeniedException(ActionPermission.LIST, resolvePath(dir), user);
        }
        if (dir.exists() && dir.isDirectory()) {
            File[] files = dir.listFiles(forbiddenFiles);
            List<String> listOfFiles = new LinkedList<>();
            if (files != null && pwdFile.exists()) {
View Full Code Here


            pwdFile = resolveFile(path);
            pwd = resolvePath(pwdFile);
            //pwd = (path.startsWith("/")) ? path : pwd + path; // from diff
        }
        if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.LIST, pwd, user)) {
            throw new PermissionDeniedException(ActionPermission.LIST, pwd, user);
        }
        // note: 'pwd' and 'pwdFile' are now being shadowed by local variables, as LIST is actually supposed to support parameters
        //long start = System.currentTimeMillis();
        File[] files = pwdFile.listFiles(forbiddenFiles); // only list allowed files
        LinkedList<String> lines;
View Full Code Here

        return lines;
    }
    public List<String> mlsd(String path) throws FileNotFoundException, PermissionDeniedException {
        File dir = resolveFile(path);
        if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.LIST, resolvePath(dir), user)) {
            throw new PermissionDeniedException(ActionPermission.LIST, resolvePath(dir), user);
        }
        File[] files = dir.listFiles(forbiddenFiles); // only list allowed files
        LinkedList<String> lines;
        if (files == null || !dir.exists()) {
            // it the dir is empty we get a list of length 0, so it'll still be executed properly
View Full Code Here

                // the bug could only by found by using more lax permission settings
                // the problem here is that, since resolvePath never returns null, the path looks right, when in actuality, it is wrong
            } else {
                String path = resolvePath(t);
                if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.CWD, path, user)) {
                    throw new PermissionDeniedException(ActionPermission.CWD, path, user);
                }
                pwdFile = t;
                if (path.length() == 0) {
                    pwd = "/";
                } else {
View Full Code Here

        File mkd = resolveFile(directory);
        String ftpPathToDir = resolvePath(mkd);
        // we want to check the permissions in the directory that contains the directory we are aiming for, and since
        // MKD can take parameters with full path names, we need to check in the parent
        if (ftpPathToDir == null || !ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.MKDIR, ftpPathToDir, user)) {
            throw new PermissionDeniedException(ActionPermission.MKDIR, ftpPathToDir, user);
        }
        if (!mkd.exists()) {
            boolean success = mkd.mkdirs();
            if (success) {
              MetadataHandler metadataHandler = ServiceManager.getServices().getMetadataHandler();
View Full Code Here

    public void rmd(String path) throws PermissionDeniedException, AccessControlException, IOException {
        File directory = resolveFile(path);
        String ftpPathToDir = resolvePath(directory);
        // we want to check the permissions in the directory that contains the directory we are aiming for, and since RMD can take parameters with full path names, we need to check in the parent
        if (ftpPathToDir == null || !ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.RMDIR, ftpPathToDir, user)) {
            throw new PermissionDeniedException(ActionPermission.RMDIR, ftpPathToDir, user);
        }
        if (directory.exists()) {
            if (directory.isDirectory()) {
                if (isEmpty(directory)) {
                    // apparently we need to delete the hidden files first, since rmd.delete() will not succeed if there are files left in the directory.
View Full Code Here

            permission = ActionPermission.DELETEOWN;
        } else {
            permission = ActionPermission.DELETE;
        }
        if (!ServiceManager.getServices().getPermissions().hasPermission(permission, ftpPathToFile, user)) {
            throw new PermissionDeniedException(permission, ftpPathToFile, user);
        }
        if (!file.exists()) {
            throw new FileNotFoundException("File not deleted: file not found.");
        } else if (file.isDirectory()) {
            throw new IOException("File not deleted: filename indicates a directory");
View Full Code Here

    private void checkRenamePermissions(File file) throws PermissionDeniedException {
        if (isOwner(user, file)) {
            // check permission RENAMEOWN
            if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.RENAMEOWN, resolvePath(file), user)) {
                throw new PermissionDeniedException(ActionPermission.RENAMEOWN, resolvePath(file), user);
            }
        } else {
            // check permission RENAME
            if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.RENAME, resolvePath(file), user)) {
                throw new PermissionDeniedException(ActionPermission.RENAME, resolvePath(file), user);
            }
        }
    }
View Full Code Here

    public void setLastModified(String filename, long time) throws PermissionDeniedException, FileNotFoundException {
        File file = resolveFile(filename);
        if (file.exists()) {
            if (!ServiceManager.getServices().getPermissions().hasPermission(ActionPermission.SETTIME, resolvePath(file), user)) {
                throw new PermissionDeniedException(ActionPermission.SETTIME, resolvePath(file), user);
            }
            file.setLastModified(time);
        } else {
            throw new FileNotFoundException(resolvePath(file));
        }
View Full Code Here

TOP

Related Classes of cu.ftpd.filesystem.permissions.PermissionDeniedException

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.