public void enableLogging( Logger logger ) { super.enableLogging( logger ); // Create a child logger for logging setValue and increment calls so // that they can be filtered out. m_valueLogger = logger.getChildLogger( "values" ); }
/** * Close the user manager - remove existing entries. */ public void dispose() { getLogger().info("Closing properties user manager..."); if (mUserData != null) { mUserData.clear(); mUserData = null; } } }
/** * Helper method to setup other components with same logger. * * @param component the component to pass logger object to */ protected void setupLogger( final Object component ) { setupLogger( component, (String)null ); }
/** * Close user manager - dummy implementation. */ public void dispose() { getLogger().info("Closing ip restrictor..."); }
/** * Helper method to setup other components with logger. * The logger has the subcategory of this components logger. * * @param component the component to pass logger object to * @param subCategory the subcategory to use (may be null) */ protected void setupLogger( final Object component, final String subCategory ) { Logger logger = m_logger; if( null != subCategory ) { logger = m_logger.getChildLogger( subCategory ); } setupLogger( component, logger ); }
/** * Close connection to database. */ private void closeDbConnection() { if (mDbConnection != null) { try {mDbConnection.close(); } catch(SQLException ex) {} mDbConnection = null; } getLogger().info("Connection closed."); }
/** * Reload the user data if necessary */ public synchronized void reload() throws Exception { long lastModified = mUserDataFile.lastModified(); if (lastModified > mlLastModified) { FileInputStream fis = new FileInputStream(mUserDataFile); mUserData.load(fis); fis.close(); mlLastModified = lastModified; getLogger().info("File modified - loading " + mUserDataFile.getAbsolutePath()); } }
/** * Close user manager - dummy implementation. */ public void dispose() { getLogger().info("Closing user manager..."); }
/** * Open connection to database. */ private void openDbConnection() throws SQLException { mDbConnection = DriverManager.getConnection(mUrl, mUser, mPassword); mDbConnection.setAutoCommit(true); getLogger().info("Connection opened."); }
getLogger().error("DbUserManager.getAllUserNames()", ex);
/** * Get all user names. */ public synchronized List getAllUserNames() { ArrayList allUsers = new ArrayList(); try { Attributes matchAttrs = new BasicAttributes(true); matchAttrs.put(mObjClassAttr); NamingEnumeration answers = mAdminContext.search(mstRoot, matchAttrs, UID_ATTRS); while (answers.hasMore()) { SearchResult sr = (SearchResult)answers.next(); String uid = sr.getAttributes().get(User.ATTR_LOGIN).get().toString(); allUsers.add(uid); } } catch(Exception ex) { getLogger().error("LdapUserManager.getAllUserNames()", ex); } Collections.sort(allUsers); return allUsers; }
getLogger().error("DbUserManager.authenticate()", ex); return false;
getLogger().error("DbUserManager.doesExist()", ex);
/** * Get user object. */ public synchronized User getUserByName(String name) { User user = null; try { String dn = getDN(name); Attributes attrs = mAdminContext.getAttributes(dn, ALL_ATTRS); user = new User(); user.setName(attrs.get(User.ATTR_LOGIN).get().toString()); user.getVirtualDirectory().setRootDirectory(new File(attrs.get(User.ATTR_HOME).get().toString())); user.setEnabled(Boolean.TRUE.toString().equals(attrs.get(User.ATTR_ENABLE).get().toString())); user.getVirtualDirectory().setWritePermission(Boolean.TRUE.toString().equals(attrs.get(User.ATTR_WRITE_PERM).get().toString())); user.setMaxIdleTime( Integer.parseInt(attrs.get(User.ATTR_MAX_IDLE_TIME).get().toString()) ); user.setMaxUploadRate( Integer.parseInt(attrs.get(User.ATTR_MAX_UPLOAD_RATE).get().toString()) ); user.setMaxDownloadRate( Integer.parseInt(attrs.get(User.ATTR_MAX_DOWNLOAD_RATE).get().toString()) ); } catch(Exception ex) { getLogger().error("LdapUserManager.getUserByName()", ex); user = null; } return user; }
/** * Release all resources. */ public void dispose() { getLogger().info( "Closing Ftp server..." ); if ( configuration != null ) { try { configuration.dispose(); ((DefaultConnectionManager)connectionManager).dispose(); serverSocket.close(); } catch ( Exception ex ) { getLogger().warn( "FtpServerImpl.dispose()", ex ); } } }
/** * Set configuration */ public void configure(Configuration conf) throws ConfigurationException { super.configure(conf); mbEncrypt = conf.getChild("encrypt").getValueAsBoolean(false); try { mUserDataFile = new File(getBaseDirectory(), USER_PROP); mUserDataFile.createNewFile(); mUserData = new BaseProperties(mUserDataFile); mlLastModified = mUserDataFile.lastModified(); getLogger().info("Loaded user data file - " + mUserDataFile); } catch(IOException ex) { getLogger().error(ex.getMessage(), ex); throw new ConfigurationException(ex.getMessage()); } }
/** * Set application context. */ public void contextualize(Context context) throws ContextException { super.contextualize(context); mIpFile = new File( getBaseDirectory(), "ip.properties" ); try { reload(); } catch(IOException ex) { getLogger().error("IpRestrictor:contextualize()", ex); throw new ContextException("IpRestrictor:contextualize()", ex); } getLogger().info("IP restrictor file = " + mIpFile); }
/** * Set application context - first spep. */ public void contextualize( Context context ) throws ContextException { try { configuration = new FtpConfig(); configuration.setLogger( getLogger() ); this.context = context; configuration.setContext( this.context ); } catch ( Exception ex ) { getLogger().error( "FtpServerImpl.contextualize()", ex ); throw new ContextException( "FtpServerImpl.contextualize()", ex ); } }
getLogger().error("DbUserManager.getUserByName()", ex);
getLogger().error( "FtpServerImpl.configure()", ex );