/** * Check file write permission. */ public boolean isWritable() { LOG.debug("Checking authorization for " + getAbsolutePath()); if (user.authorize(new WriteRequest(getAbsolutePath())) == null) { LOG.debug("Not authorized"); return false; } LOG.debug("Checking if file exists"); if (file.exists()) { LOG.debug("Checking can write: " + file.canWrite()); return file.canWrite(); } LOG.debug("Authorized"); return true; }
/** * Has delete permission. */ public boolean isRemovable() { // root cannot be deleted if ("/".equals(fileName)) { return false; } /* Added 12/08/2008: in the case that the permission is not explicitly denied for this file * we will check if the parent file has write permission as most systems consider that a file can * be deleted when their parent directory is writable. */ String fullName = getAbsolutePath(); // we check FTPServer's write permission for this file. if (user.authorize(new WriteRequest(fullName)) == null) { return false; } // In order to maintain consistency, when possible we delete the last '/' character in the String int indexOfSlash = fullName.lastIndexOf('/'); String parentFullName; if (indexOfSlash == 0) { parentFullName = "/"; } else { parentFullName = fullName.substring(0, indexOfSlash); } // we check if the parent FileObject is writable. NativeFtpFile parentObject = new NativeFtpFile(parentFullName, file .getAbsoluteFile().getParentFile(), user); return parentObject.isWritable(); }
public final long transferFromClient(FtpSession session, final OutputStream out) throws IOException { TransferRateRequest transferRateRequest = new TransferRateRequest(); transferRateRequest = (TransferRateRequest) session.getUser() .authorize(transferRateRequest); int maxRate = 0; if (transferRateRequest != null) { maxRate = transferRateRequest.getMaxUploadRate(); } InputStream is = getDataInputStream(); try { return transfer(session, false, is, out, maxRate); } finally { IoUtils.close(is); } }
public final long transferToClient(FtpSession session, final InputStream in) throws IOException { TransferRateRequest transferRateRequest = new TransferRateRequest(); transferRateRequest = (TransferRateRequest) session.getUser() .authorize(transferRateRequest); int maxRate = 0; if (transferRateRequest != null) { maxRate = transferRateRequest.getMaxDownloadRate(); } OutputStream out = getDataOutputStream(); try { return transfer(session, true, in, out, maxRate); } finally { IoUtils.close(out); } }
userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM, usr.authorize(new WriteRequest()) != null); userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME, usr.getMaxIdleTime()); transferRateRequest = (TransferRateRequest) usr.authorize(transferRateRequest); concurrentLoginRequest = (ConcurrentLoginRequest) usr.authorize(concurrentLoginRequest);
userDataProp.setProperty(thisPrefix + ATTR_ENABLE, usr.getEnabled()); userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM, usr .authorize(new WriteRequest()) != null); userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME, usr .getMaxIdleTime()); .authorize(transferRateRequest); 0, 0); concurrentLoginRequest = (ConcurrentLoginRequest) usr .authorize(concurrentLoginRequest);
userDataProp.setProperty(thisPrefix + ATTR_ENABLE, usr.getEnabled()); userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM, usr .authorize(new WriteRequest()) != null); userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME, usr .getMaxIdleTime()); .authorize(transferRateRequest); 0, 0); concurrentLoginRequest = (ConcurrentLoginRequest) usr .authorize(concurrentLoginRequest);
stat.getCurrentUserLoginNumber(configUser, address) + 1); if (configUser.authorize(loginRequest) == null) { LOG.debug("User logged in too many sessions, user will be disconnected"); session