You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ra...@apache.org on 2002/03/06 15:01:52 UTC
cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote ConnectionService.java FtpConfig.java FtpConnectionObserverAdapter.java FtpFileListenerAdapter.java FtpStatistics.java FtpStatisticsListenerAdapter.java IpRestrictor.java RemoteHandler.java SpyConnectionAdapter.java UserManager.java
rana_b 02/03/06 06:01:52
Added: ftpserver/src/java/org/apache/avalon/ftpserver/remote
ConnectionService.java FtpConfig.java
FtpConnectionObserverAdapter.java
FtpFileListenerAdapter.java FtpStatistics.java
FtpStatisticsListenerAdapter.java IpRestrictor.java
RemoteHandler.java SpyConnectionAdapter.java
UserManager.java
Log:
second stage of refactoring
Revision Changes Path
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/ConnectionService.java
Index: ConnectionService.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.util.List;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import org.apache.avalon.ftpserver.FtpUser;
import org.apache.avalon.ftpserver.FtpConnection;
import org.apache.avalon.ftpserver.remote.interfaces.SpyConnectionInterface;
import org.apache.avalon.ftpserver.remote.interfaces.FtpConnectionObserver;
/**
* Ftp remote user service adapter class - used by remote admin GUI.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class ConnectionService implements org.apache.avalon.ftpserver.remote.interfaces.ConnectionServiceInterface {
private org.apache.avalon.ftpserver.ConnectionService mConnectionService;
private FtpConnectionObserverAdapter mConnectionObserverAdapter;
/**
* Constructor - sets the actual connection service object
*/
public ConnectionService(final org.apache.avalon.ftpserver.ConnectionService conService) throws RemoteException {
mConnectionService = conService;
mConnectionObserverAdapter = new FtpConnectionObserverAdapter();
UnicastRemoteObject.exportObject(this);
}
/**
* Get the actual object.
*/
public org.apache.avalon.ftpserver.ConnectionService getConnectionService() {
return mConnectionService;
}
/**
* It returns a list of all the currently connected users.
*/
public List getAllUsers() {
return mConnectionService.getAllUsers();
}
/**
* Set connection observer.
*/
public void setObserver(final FtpConnectionObserver obsr) {
mConnectionObserverAdapter.setConnectionObserver(obsr);
if (obsr == null) {
mConnectionService.setObserver(null);
}
else {
mConnectionService.setObserver(mConnectionObserverAdapter);
}
}
/**
* Get the observer.
*/
public FtpConnectionObserver getObserver() {
return mConnectionObserverAdapter.getConnectionObserver();
}
/**
* Get connected user
*/
public FtpUser getUser(final String sessId) {
FtpConnection con = mConnectionService.getConnection(sessId);
return (con != null) ? con.getUser() : null;
}
/**
* Set spy object
*/
public void setSpyObject(final String sessId, final SpyConnectionInterface spy) {
if (spy == null) {
mConnectionService.setSpyObject(sessId, null);
}
else {
SpyConnectionAdapter newAdapter = new SpyConnectionAdapter(spy);
mConnectionService.setSpyObject(sessId, newAdapter);
}
}
/**
* Close ftp connection for this session id.
*/
public void closeConnection(final String sessionId) {
mConnectionService.closeConnection(sessionId);
}
/**
* Close all - close all the connections.
*/
public void closeAllConnections() {
mConnectionService.closeAllConnections();
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/FtpConfig.java
Index: FtpConfig.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.net.InetAddress;
import org.apache.avalon.ftpserver.remote.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.remote.interfaces.IpRestrictorInterface;
import org.apache.avalon.ftpserver.remote.interfaces.ConnectionServiceInterface;
import org.apache.avalon.ftpserver.remote.interfaces.UserManagerInterface;
import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsInterface;
/**
* Ftp configuration remote adapter. It is used by remote admin GUI.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpConfig implements FtpConfigInterface {
private org.apache.avalon.ftpserver.FtpConfig mConfig;
private IpRestrictor mIpRestrictor;
private UserManager mUserManager;
private ConnectionService mConService;
private FtpStatistics mStatistics;
/**
* Constructor - sets the actual config object.
*/
public FtpConfig(org.apache.avalon.ftpserver.FtpConfig config) throws RemoteException {
mConfig = config;
mIpRestrictor = new IpRestrictor(config.getIpRestrictor());
mUserManager = new UserManager(config.getUserManager());
mConService = new ConnectionService(config.getConnectionService());
mStatistics = new FtpStatistics(config.getStatistics());
UnicastRemoteObject.exportObject(this);
}
/**
* Get config
*/
public org.apache.avalon.ftpserver.FtpConfig getConfig() {
return mConfig;
}
/**
* Get user manager
*/
public UserManagerInterface getUserManager() {
return mUserManager;
}
/**
* Get IP restrictor object.
*/
public IpRestrictorInterface getIpRestrictor() {
return mIpRestrictor;
}
/**
* Get server bind address.
*/
public InetAddress getServerAddress() {
return mConfig.getServerAddress();
}
/**
* Get server port.
*/
public int getServerPort() {
return mConfig.getServerPort();
}
/**
* Check annonymous login support.
*/
public boolean isAnonymousLoginAllowed() {
return mConfig.isAnonymousLoginAllowed();
}
/**
* Get the connection handler
*/
public ConnectionServiceInterface getConnectionService() {
return mConService;
}
/**
* Get maximum number of connections.
*/
public int getMaxConnections() {
return mConfig.getMaxConnections();
}
/**
* Get maximum number of anonymous connections.
*/
public int getMaxAnonymousLogins() {
return mConfig.getMaxAnonymousLogins();
}
/**
* Get poll interval in seconds.
*/
public int getSchedulerInterval() {
return mConfig.getSchedulerInterval();
}
/**
* Get default idle time in seconds.
*/
public int getDefaultIdleTime() {
return mConfig.getDefaultIdleTime();
}
/**
* Get default root directory
*/
public String getDefaultRoot() {
return mConfig.getDefaultRoot().getAbsolutePath();
}
/**
* Get global statistics object.
*/
public FtpStatisticsInterface getStatistics() {
return mStatistics;
}
/**
* Get rmi port
*/
public int getRemoteAdminPort() {
return mConfig.getRemoteAdminPort();
}
/**
* Is remote admin allowed
*/
public boolean isRemoteAdminAllowed() {
return mConfig.isRemoteAdminAllowed();
}
/**
* Get base directory
*/
public String getBaseDirectory() {
return mConfig.getBaseDirectory().getAbsolutePath();
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/FtpConnectionObserverAdapter.java
Index: FtpConnectionObserverAdapter.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.rmi.RemoteException;
import org.apache.avalon.ftpserver.FtpUser;
import org.apache.avalon.ftpserver.remote.interfaces.FtpConnectionObserver;
/**
* This connection observer remote adapter class.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpConnectionObserverAdapter implements org.apache.avalon.ftpserver.interfaces.FtpConnectionObserver {
private FtpConnectionObserver mObserver;
/**
* Default constructor.
*/
public FtpConnectionObserverAdapter() {
}
/**
* Get observer
*/
public FtpConnectionObserver getConnectionObserver() {
return mObserver;
}
/**
* Set observer
*/
public void setConnectionObserver(FtpConnectionObserver observer) {
mObserver = observer;
}
/**
* New connection notification.
* @param user newly connected user
*/
public void newConnection(final FtpUser user) {
FtpConnectionObserver observer = mObserver;
if (observer != null) {
try {
observer.newConnection(user);
}
catch(RemoteException ex) {
mObserver = null;
}
}
}
/**
* Close connection notification
* @param user closed user object.
*/
public void removeConnection(final FtpUser user) {
FtpConnectionObserver observer = mObserver;
if (observer != null) {
try {
observer.removeConnection(user);
}
catch(RemoteException ex) {
mObserver = null;
}
}
}
/**
* Update connection notification
* @param user updated user object
*/
public void updateConnection(final FtpUser user) {
FtpConnectionObserver observer = mObserver;
if (observer != null) {
try {
observer.updateConnection(user);
}
catch(RemoteException ex) {
mObserver = null;
}
}
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/FtpFileListenerAdapter.java
Index: FtpFileListenerAdapter.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.io.File;
import java.rmi.RemoteException;
import org.apache.avalon.ftpserver.remote.interfaces.FtpFileListener;
/**
* Ftp file upload/download/delete listener remote interface.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpFileListenerAdapter implements org.apache.avalon.ftpserver.interfaces.FtpFileListener {
private FtpFileListener mFileListener = null;
/**
* Default constructor.
*/
public FtpFileListenerAdapter() {
}
/**
* Get actual listener object
*/
public FtpFileListener getFileListener() {
return mFileListener;
}
/**
* Set file listener
*/
public void setFileListener(FtpFileListener listener) {
mFileListener = listener;
}
/**
* User file upload notification.
*/
public void notifyUpload(final File file, final String sessionId) {
FtpFileListener listener = mFileListener;
if (listener != null) {
try {
listener.notifyUpload(file.getAbsolutePath(), sessionId);
}
catch(RemoteException ex) {
mFileListener = null;
}
}
}
/**
* User file download notification.
*/
public void notifyDownload(final File file, final String sessionId) {
FtpFileListener listener = mFileListener;
if (listener != null) {
try {
listener.notifyDownload(file.getAbsolutePath(), sessionId);
}
catch(RemoteException ex) {
mFileListener = null;
}
}
}
/**
* User file delete notification.
*/
public void notifyDelete(final File file, final String sessionId) {
FtpFileListener listener = mFileListener;
if (listener != null) {
try {
listener.notifyDelete(file.getAbsolutePath(), sessionId);
}
catch(RemoteException ex) {
mFileListener = null;
}
}
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/FtpStatistics.java
Index: FtpStatistics.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Date;
import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsInterface;
import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsListener;
import org.apache.avalon.ftpserver.remote.interfaces.FtpFileListener;
/**
* Ftp statistis remote adapter class.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpStatistics implements FtpStatisticsInterface {
private org.apache.avalon.ftpserver.FtpStatistics mStatistics;
private FtpStatisticsListenerAdapter mStatisticsListener;
private FtpFileListenerAdapter mFileListener;
/**
* Constructor - sets the actual statistics object
*/
public FtpStatistics(final org.apache.avalon.ftpserver.FtpStatistics statistics) throws RemoteException {
mStatistics = statistics;
mStatisticsListener = new FtpStatisticsListenerAdapter();
mFileListener = new FtpFileListenerAdapter();
UnicastRemoteObject.exportObject(this);
}
/**
* Get server start time.
*/
public Date getStartTime() {
return mStatistics.getStartTime();
}
/**
* Get number of files uploaded.
*/
public int getFileUploadNbr() {
return mStatistics.getFileUploadNbr();
}
/**
* Get number of files downloaded.
*/
public int getFileDownloadNbr() {
return mStatistics.getFileDownloadNbr();
}
/**
* Get number of files deleted.
*/
public int getFileDeleteNbr() {
return mStatistics.getFileDeleteNbr();
}
/**
* Get total number of bytes uploaded.
*/
public long getFileUploadSize() {
return mStatistics.getFileUploadSize();
}
/**
* Get total number of bytes downloaded.
*/
public long getFileDownloadSize() {
return mStatistics.getFileDownloadSize();
}
/**
* Get current number of connections.
*/
public int getConnectionNbr() {
return mStatistics.getConnectionNbr();
}
/**
* Get total number of connections
*/
public int getTotalConnectionNbr() {
return mStatistics.getTotalConnectionNbr();
}
/**
* Get current number of logins
*/
public int getLoginNbr() {
return mStatistics.getLoginNbr();
}
/**
* Get total number of logins
*/
public int getTotalLoginNbr() {
return mStatistics.getTotalLoginNbr();
}
/**
* Get current number of anonymous logins.
*/
public int getAnonLoginNbr() {
return mStatistics.getAnonLoginNbr();
}
/**
* Get total number of anonymous logins
*/
public int getTotalAnonLoginNbr() {
return mStatistics.getTotalAnonLoginNbr();
}
/**
* Set a listener object.
*/
public void setListener(FtpStatisticsListener listener) {
mStatisticsListener.setStatisticsListener(listener);
if (listener == null) {
mStatistics.setListener(null);
}
else {
mStatistics.setListener(mStatisticsListener);
}
}
/**
* Get listener object.
*/
public FtpStatisticsListener getListener() {
return mStatisticsListener.getStatisticsListener();
}
/**
* Get file listener
*/
public void setFileListener(FtpFileListener listener) {
mFileListener.setFileListener(listener);
if (listener == null) {
mStatistics.setFileListener(null);
}
else {
mStatistics.setFileListener(mFileListener);
}
}
/**
* Set file listener
*/
public FtpFileListener getFileListener() {
return mFileListener.getFileListener();
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/FtpStatisticsListenerAdapter.java
Index: FtpStatisticsListenerAdapter.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.rmi.RemoteException;
import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsListener;
/**
* Ftp statistics listener remote interface.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpStatisticsListenerAdapter implements org.apache.avalon.ftpserver.interfaces.FtpStatisticsListener {
private FtpStatisticsListener mListener = null;
/**
* Constructor - set the actual listener object
*/
public FtpStatisticsListenerAdapter() {
}
/**
* Get the actual listener object
*/
public FtpStatisticsListener getStatisticsListener() {
return mListener;
}
/**
* Set the actual listener object.
*/
public void setStatisticsListener(FtpStatisticsListener listener) {
mListener = listener;
}
/**
* User file upload notification.
*/
public void notifyUpload() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyUpload();
}
catch(RemoteException ex) {
mListener = null;
}
}
}
/**
* User file download notification.
*/
public void notifyDownload() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyDownload();
}
catch(RemoteException ex) {
mListener = null;
}
}
}
/**
* User file delete notification.
*/
public void notifyDelete() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyDelete();
}
catch(RemoteException ex) {
mListener = null;
}
}
}
/**
* New user login notification.
*/
public void notifyLogin() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyLogin();
}
catch(RemoteException ex) {
mListener = null;
}
}
}
/**
* User logout notification.
*/
public void notifyLogout() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyLogout();
}
catch(RemoteException ex) {
mListener = null;
}
}
}
/**
* Connection open/close notification
*/
public void notifyConnection() {
FtpStatisticsListener listener = mListener;
if (listener != null) {
try {
listener.notifyConnection();
}
catch(RemoteException ex){
mListener = null;
}
}
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/IpRestrictor.java
Index: IpRestrictor.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Collection;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/**
* IP Restrictor remotr adapter class. Used by admin GUI.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class IpRestrictor implements org.apache.avalon.ftpserver.remote.interfaces.IpRestrictorInterface{
private org.apache.avalon.ftpserver.ip.IpRestrictorInterface mIpRestrictor;
/**
* Constructor - sets the actual ip restrictor object
*/
public IpRestrictor(org.apache.avalon.ftpserver.ip.IpRestrictorInterface ipRestrictor) throws RemoteException {
mIpRestrictor = ipRestrictor;
UnicastRemoteObject.exportObject(this);
}
/**
* Get the actual object.
*/
public org.apache.avalon.ftpserver.ip.IpRestrictorInterface getActualObject() {
return mIpRestrictor;
}
/**
* Reload data from store.
*/
public void reload() throws IOException {
mIpRestrictor.reload();
}
/**
* Save data into store.
*/
public void save() throws IOException {
mIpRestrictor.save();
}
/**
* Check IP permission.
*/
public boolean hasPermission(InetAddress addr) {
return mIpRestrictor.hasPermission(addr);
}
/**
* Clear all entries.
*/
public void clear() {
mIpRestrictor.clear();
}
/**
* Add new entry
*/
public void addEntry(String str) {
mIpRestrictor.addEntry(str);
}
/**
* Remove entry
*/
public void removeEntry(String str) {
mIpRestrictor.removeEntry(str);
}
/**
* Get all entries
*/
public Collection getAllEntries() {
return mIpRestrictor.getAllEntries();
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/RemoteHandler.java
Index: RemoteHandler.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.Unreferenced;
import java.rmi.server.UID;
import org.apache.avalon.ftpserver.usermanager.User;
import org.apache.avalon.ftpserver.remote.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.remote.interfaces.RemoteHandlerInterface;
/**
* Ftp server remote admin adapter. This is the starting point of remote admin.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class RemoteHandler implements RemoteHandlerInterface, Unreferenced {
private FtpConfig mFtpConfig;
private String mstAdminSession;
private Registry mRegistry;
/**
* Constructor - set the actual user config object
*/
public RemoteHandler(org.apache.avalon.ftpserver.FtpConfig config) throws RemoteException {
// open registry
int rmiPort = config.getRemoteAdminPort();
try {
mRegistry = LocateRegistry.getRegistry(rmiPort);
mRegistry.list();
}
catch(RemoteException ex) {
mRegistry = null;
}
if(mRegistry == null) {
mRegistry = LocateRegistry.createRegistry(rmiPort);
}
UnicastRemoteObject.exportObject(this);
mRegistry.rebind(BIND_NAME, this);
mFtpConfig = new FtpConfig(config);
}
/**
* Remote admin login
*/
public synchronized String login(String id, String password) throws Exception {
try {
mFtpConfig.getConfig().getLogger().info("Remote admin login request from " + UnicastRemoteObject.getClientHost());
}
catch(Exception ex) {
mFtpConfig.getConfig().getLogger().error("RemoteHandler.login()", ex);
}
// data validation
if(mstAdminSession != null) {
throw new Exception("Multiple admin session is not possible.");
}
if(id == null) {
throw new Exception("Please specify user Id");
}
if(password == null) {
throw new Exception("Please specify password");
}
if(!User.ADMIN.equals(id)) {
throw new Exception("Not an admin user");
}
boolean bSuccess = mFtpConfig.getConfig().getUserManager().authenticate(id, password);
if(!bSuccess) {
throw new Exception("Login failure.");
}
try {
mFtpConfig.getConfig().getLogger().info("Remote admin login from " + UnicastRemoteObject.getClientHost());
}
catch(Exception ex) {
mFtpConfig.getConfig().getLogger().error("RemoteHandler.login()", ex);
}
mstAdminSession = new UID().toString();
return mstAdminSession;
}
/**
* Remote admin logout
*/
public synchronized boolean logout(String sessId) {
if( (sessId == null) || (!sessId.equals(mstAdminSession)) ) {
return false;
}
mFtpConfig.getConfig().getLogger().info("Remote admin logout");
resetObservers();
mstAdminSession = null;
return true;
}
/**
* Get configuration interface
*/
public FtpConfigInterface getConfigInterface(String sessId) {
if( (sessId == null) || (!sessId.equals(mstAdminSession)) ) {
return null;
}
return mFtpConfig;
}
/**
* Reset observers
*/
private void resetObservers() {
ConnectionService conService = (ConnectionService)mFtpConfig.getConnectionService();
conService.setObserver(null);
conService.getConnectionService().resetAllSpyObjects();
FtpStatistics statistics = (FtpStatistics)mFtpConfig.getStatistics();
statistics.setListener(null);
statistics.setFileListener(null);
}
/**
* Close the remote handler
*/
public void close() {
resetObservers();
try {
if (mRegistry != null) {
mRegistry.unbind(BIND_NAME);
mRegistry = null;
}
}
catch(Exception ex) {
}
}
/**
* Unreferenced - admin user idle timeout
*/
public synchronized void unreferenced() {
mFtpConfig.getConfig().getLogger().info("Remote admin timeout");
logout(mstAdminSession);
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/SpyConnectionAdapter.java
Index: SpyConnectionAdapter.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.io.IOException;
import java.rmi.RemoteException;
import org.apache.avalon.ftpserver.remote.interfaces.SpyConnectionInterface;
/**
* This remote spy user adapter.
*/
public
class SpyConnectionAdapter implements org.apache.avalon.ftpserver.interfaces.SpyConnectionInterface {
private SpyConnectionInterface mSpy;
/**
* Default constructor.
*/
public SpyConnectionAdapter(SpyConnectionInterface spy) {
mSpy = spy;
}
/**
* Get spy user
*/
public SpyConnectionInterface getSpyObject() {
return mSpy;
}
/**
* Get spy user
*/
public void setSpyObject(SpyConnectionInterface spy) {
mSpy = spy;
}
/**
* Write user spy message.
*/
public void write(final String msg) throws IOException {
SpyConnectionInterface spy = mSpy;
if(spy != null) {
try {
spy.write(msg);
}
catch(RemoteException ex) {
mSpy = null;
}
}
}
}
1.1 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/remote/UserManager.java
Index: UserManager.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.ftpserver.remote;
import java.util.List;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import org.apache.avalon.ftpserver.usermanager.User;
import org.apache.avalon.ftpserver.remote.interfaces.UserManagerInterface;
/**
* This is user manager remote adapter class. This is used by remote admin GUI.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class UserManager implements UserManagerInterface {
private org.apache.avalon.ftpserver.usermanager.UserManagerInterface mUserManager;
/**
* Constructor - sets the actual user manager
*/
public UserManager(org.apache.avalon.ftpserver.usermanager.UserManagerInterface userManager) throws RemoteException {
mUserManager = userManager;
UnicastRemoteObject.exportObject(this);
}
/**
* Get the actual user manager
*/
public org.apache.avalon.ftpserver.usermanager.UserManagerInterface getUserManager() {
return mUserManager;
}
/**
* Save the user. If a new user, create it else update the
* existing user.
*/
public void save(User user) throws Exception {
mUserManager.save(user);
}
/**
* Delete the user from the system.
*
* @param name name of the user to be deleted.
*/
public void delete(String userName) throws Exception {
mUserManager.delete(userName);
}
/**
* Get user by name.
*/
public User getUserByName(String name) {
return mUserManager.getUserByName(name);
}
/**
* Get all user names in the system.
*/
public List getAllUserNames() {
return mUserManager.getAllUserNames();
}
/**
* User existance check.
*
* @param name user name
*/
public boolean doesExist(String name) {
return mUserManager.doesExist(name);
}
/**
* Authenticate user
*/
public boolean authenticate(String login, String password) {
return mUserManager.authenticate(login, password);
}
/**
* Load the user data again
*/
public void reload() throws Exception {
mUserManager.reload();
}
/**
* Close the user manager
*/
public void close() {
mUserManager.close();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>