/** * @throws FtpException * always, operation not supported * @see org.apache.ftpserver.ftplet.UserManager#save(org.apache.ftpserver.ftplet.User) */ public void save(User user) throws FtpException { throw new FtpException("No custom user handling on this instance"); }
/** * @see org.apache.ftpserver.ftplet.UserManager#getAdminName() */ public String getAdminName() throws FtpException { throw new FtpException("No custom user handling on this instance"); }
/** * @see org.apache.ftpserver.ftplet.UserManager#getAllUserNames() */ public String[] getAllUserNames() throws FtpException { throw new FtpException("No custom user handling on this instance"); }
/** * @throws FtpException * always, operation not supported. * @see org.apache.ftpserver.ftplet.UserManager#delete(java.lang.String) */ public void delete(String username) throws FtpException { throw new FtpException("No custom user handling on this instance"); }
/** * Get long value. */ public long getLong(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return Long.parseLong(value); } catch (NumberFormatException ex) { throw new FtpException("BaseProperties.getLong()", ex); } }
/** * Get <code>InetAddress</code>. */ public InetAddress getInetAddress(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return InetAddress.getByName(value); } catch (UnknownHostException ex) { throw new FtpException("Host " + value + " not found"); } }
/** * Get <code>Date</code> object. */ public Date getDate(final String str, final DateFormat fmt) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return fmt.parse(value); } catch (ParseException ex) { throw new FtpException("BaseProperties.getdate()", ex); } }
/** * Get integer value. */ public int getInteger(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return Integer.parseInt(value); } catch (NumberFormatException ex) { throw new FtpException("BaseProperties.getInteger()", ex); } }
/** * Get double value. */ public double getDouble(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return Double.parseDouble(value); } catch (NumberFormatException ex) { throw new FtpException("BaseProperties.getDouble()", ex); } }
/** * Get <code>Class</code> object */ public Class<?> getClass(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return Class.forName(value); } catch (ClassNotFoundException ex) { throw new FtpException("BaseProperties.getClass()", ex); } }
/** * Get <code>DateFormat</code> object. */ public SimpleDateFormat getDateFormat(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } try { return new SimpleDateFormat(value); } catch (IllegalArgumentException e) { throw new FtpException("Date format was incorrect: " + value, e); } }
/** * Get boolean value. */ public boolean getBoolean(final String str) throws FtpException { String prop = getProperty(str); if (prop == null) { throw new FtpException(str + " not found"); } return prop.toLowerCase().equals("true"); }
/** * Get <code>String</code>. */ public String getString(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } return value; }
/** * Get <code>File</code> object. */ public File getFile(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } return new File(value); }
@Override public FileSystemView createFileSystemView( User user ) throws FtpException { MiltonUser mu = (MiltonUser) user; Resource root; try { root = resourceFactory.getResource( mu.domain, "/" ); } catch (NotAuthorizedException ex) { throw new FtpException(ex); } catch (BadRequestException ex) { throw new FtpException(ex); } return new MiltonFsView( Path.root, mu.domain, resourceFactory, (MiltonUser) user ); }
/** * Get <code>TimeZone</code> */ public TimeZone getTimeZone(final String str) throws FtpException { String value = getProperty(str); if (value == null) { throw new FtpException(str + " not found"); } return TimeZone.getTimeZone(value); }
private CollectionResource getWorkingDir() throws FtpException { try { Resource working = resourceFactory.getResource(host, currentPath.toString()); if (working instanceof CollectionResource) { return (CollectionResource) working; } return null; } catch (NotAuthorizedException e) { throw new FtpException(e); } catch (BadRequestException e) { throw new FtpException(e); } }
@Override public FtpFile getHomeDirectory() throws FtpException { try { Resource home = resourceFactory.getResource(host, homePath.toString()); return wrap(homePath, home); } catch (NotAuthorizedException ex) { throw new FtpException(ex); } catch (BadRequestException ex) { throw new FtpException(ex); } }
/** * @throws FtpException */ private void saveUserData() throws FtpException { if (userDataFile == null) { return; } File dir = userDataFile.getAbsoluteFile().getParentFile(); if (dir != null && !dir.exists() && !dir.mkdirs()) { String dirName = dir.getAbsolutePath(); throw new FtpServerConfigurationException( "Cannot create directory for user data file : " + dirName); } // save user data FileOutputStream fos = null; try { fos = new FileOutputStream(userDataFile); userDataProp.store(fos, "Generated file - don't edit (please)"); } catch (IOException ex) { LOG.error("Failed saving user data", ex); throw new FtpException("Failed saving user data", ex); } finally { IoUtils.close(fos); } }
/** * Get the user object. Fetch the row from the table. */ public User getUserByName(String name) throws FtpException { Statement stmt = null; ResultSet rs = null; try { BaseUser user = selectUserByName(name); if(user != null) { // reset the password, not to be sent to API users user.setPassword(null); } return user; } catch (SQLException ex) { LOG.error("DbUserManager.getUserByName()", ex); throw new FtpException("DbUserManager.getUserByName()", ex); } finally { closeQuitely(rs); closeQuitely(stmt); } }