hammant 01/12/13 05:26:05
Modified: apps/ftpserver build.xml
apps/ftpserver/src/conf ftp-assembly.xml
apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui
CommonHandler.java FtpAdminFrame.java
FtpTreeModel.java
Added: apps/ftpserver/src/java/org/apache/avalon/ftpserver/blocks/server
DefaultFtpServer.java DefaultFtpServer.xinfo
RemoteAdminAdaptor.java
apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui
FtpAdminDialog.java
apps/ftpserver/src/java/org/apache/avalon/ftpserver/interfaces
FtpAdmin.java FtpRemoteAdmin.java
apps/ftpserver/src/java/org/apache/avalon/ftpserver/services
FtpServer.java
Removed: apps/ftpserver/src/java/org/apache/avalon/ftpserver
FtpServerImpl.java FtpServerImpl.xinfo
apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui
FtpAdmin.java
apps/ftpserver/src/java/org/apache/avalon/ftpserver/interfaces
FtpServerInterface.java
Log:
first stage of refactoring
Revision Changes Path
1.21 +19 -3 jakarta-avalon-cornerstone/apps/ftpserver/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/ftpserver/build.xml,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- build.xml 2001/11/10 21:43:02 1.20
+++ build.xml 2001/12/13 13:26:04 1.21
@@ -91,7 +91,12 @@
</fileset>
</path>
+ <path id="test.path">
+ <pathelement path="${build.lib}/ftp-admin.jar" />
+ <pathelement path="lib/jesktop-frimble.jar" />
+ </path>
+
<!--
===================================================================
Help on usage
@@ -163,7 +168,7 @@
<rmic base="${build.classes}"
includes="org/apache/avalon/ftpserver/FtpStatistics.class, \
org/apache/avalon/ftpserver/FtpConfig.class, \
- org/apache/avalon/ftpserver/FtpServerImpl.class, \
+
org/apache/avalon/ftpserver/blocks/server/RemoteAdminAdaptor.class, \
org/apache/avalon/ftpserver/FtpUserHandler.class, \
org/apache/avalon/ftpserver/IpRestrictor.class, \
org/apache/avalon/ftpserver/gui/FtpStatisticsPanel.class, \
@@ -398,13 +403,17 @@
Phoenix should have been shut down first
===================================================================
-->
- <target name="install" depends="all,check-phoenix" description="Installs
FtpServer into Phoenix">
- <delete dir="${phoenix.apps}/${jar.name}/" />
+ <target name="install" depends="main,check-phoenix" description="Installs
FtpServer into Phoenix">
+ <echo message="Installing ${jar.name}.sar to ${install.dir}" />
+ <delete file="${installvar.dir}/${jar.name}-install.log" />
+ <delete file="${install.dir}/${jar.name}/SAR-INF/lib/${jar.name}.jar" />
+ <delete dir="${install.dir}/${jar.name}" />
<copy todir="${phoenix.apps}" filtering="off">
<fileset dir="dist">
<include name="${jar.name}.sar"/>
</fileset>
</copy>
+ <echo message="Installed" />
</target>
<target name="check-phoenix" unless="phoenix.apps">
@@ -415,6 +424,13 @@
<delete dir="${phoenix.apps}/${jar.name}/" />
<delete file="${jar.name}.sar" dir="${phoenix.apps}"/>
</target>
+
+ <target name="admintest" depends="main">
+ <java classname="org.apache.avalon.ftpserver.gui.FtpAdminFrame"
fork="true">
+ <classpath refid="test.path"/>
+ </java>
+ </target>
+
<!--
===================================================================
1.4 +1 -1
jakarta-avalon-cornerstone/apps/ftpserver/src/conf/ftp-assembly.xml
Index: ftp-assembly.xml
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/ftpserver/src/conf/ftp-assembly.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ftp-assembly.xml 2001/09/20 00:55:03 1.3
+++ ftp-assembly.xml 2001/12/13 13:26:04 1.4
@@ -29,7 +29,7 @@
role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
</block>
- <block class="org.apache.avalon.ftpserver.FtpServerImpl" name="ftp-server"
>
+ <block class="org.apache.avalon.ftpserver.blocks.server.DefaultFtpServer"
name="ftp-server" >
<provide name="sockets"
role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
<provide name="connections"
role="org.apache.avalon.cornerstone.services.connection.ConnectionManager" />
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/blocks/server/DefaultFtpServer.java
Index: DefaultFtpServer.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.blocks.server;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.UnknownHostException;
import java.rmi.server.UnicastRemoteObject;
import org.apache.avalon.ftpserver.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
import org.apache.avalon.ftpserver.FtpConfig;
import org.apache.avalon.ftpserver.FtpConnection;
import org.apache.avalon.ftpserver.FtpException;
import org.apache.avalon.ftpserver.FtpUser;
import org.apache.avalon.ftpserver.services.FtpServer;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.configuration.*;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
import
org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
import org.apache.avalon.cornerstone.services.sockets.SocketManager;
import org.apache.avalon.cornerstone.services.scheduler.TimeScheduler;
import org.apache.avalon.phoenix.Block;
import org.apache.avalon.phoenix.BlockContext;
/**
* Ftp server starting point. Avalon framework will load this
* from the jar file. This is also the starting point of remote
* admin.
*
* @author Rana Bhattacharyya <[EMAIL PROTECTED]>
* @author Paul Hammant <[EMAIL PROTECTED]>
* @version 1.0
*/
public class DefaultFtpServer extends AbstractLogEnabled
implements Block, FtpServer, Contextualizable,
Composable, Configurable, Initializable, ConnectionHandlerFactory {
private ServerSocket mServerSocket = null;
private FtpConfig mConfig = null;
private SocketManager mSocManager = null;
private ConnectionManager mConManager = null;
private TimeScheduler mTimeScheduler = null;
private BlockContext mContext = null;
private RemoteAdminAdaptor mRemoteAdminAdaptor;
/**
* Set application context
*/
public void contextualize(Context context) {
mContext = (BlockContext)context;
}
/**
* Configure the server.
*
* @param conf the XML configuration block
*/
public void configure(Configuration conf) throws ConfigurationException {
try {
mConfig = new FtpConfig(conf, mContext, getLogger(),
mTimeScheduler);
mRemoteAdminAdaptor = new RemoteAdminAdaptor(this);
UnicastRemoteObject.exportObject(mRemoteAdminAdaptor);
if(mConfig.isRemoteAdminSupported()) {
mConfig.getRegistry().rebind(FtpAdmin.class.getName(),
mRemoteAdminAdaptor);
}
System.out.println("FTP server ready!");
}
catch(Exception ex) {
ex.printStackTrace();
throw new ConfigurationException(ex.getMessage(), ex);
}
}
/**
* Get all managers.
*/
public void compose(ComponentManager compManager) {
getLogger().info("FtpServer compose");
try{
mSocManager =
(SocketManager)compManager.lookup(SocketManager.ROLE);
mConManager =
(ConnectionManager)compManager.lookup(ConnectionManager.ROLE);
mTimeScheduler =
(TimeScheduler)compManager.lookup(TimeScheduler.ROLE);
//TODO (PH) should fall through or be rethrown ?
} catch (ComponentException ce) {
getLogger().error("compose(): ComponentException",ce);
}
}
/**
* Initialize server socket.
*/
public void initialize() throws Exception {
ServerSocketFactory factory =
mSocManager.getServerSocketFactory("plain");
mServerSocket = factory.createServerSocket(mConfig.getServerPort(),
5, mConfig.getServerAddress());
mConManager.connect(DISPLAY_NAME, mServerSocket, this );
getLogger().info("FTP Server started!");
}
/**
* Construct an appropriate <code>ConnectionHandler</code>
* to handle a new connection.
*
* @return the new ConnectionHandler
* @exception Exception if an error occurs
*/
public ConnectionHandler createConnectionHandler() throws Exception {
FtpConnection conHandle = new FtpConnection(mConfig);
setupLogger(conHandle, getLogger());
return conHandle;
}
/**
* Get the server object.
*/
public FtpConfigInterface getConfigInterface(String sessId) throws
FtpException {
isAdminLogin(sessId);
return mConfig;
}
/**
* Remote login
*/
public String adminLogin(String id, String psd) throws FtpException {
if(id == null || psd == null) {
throw new FtpException(530);
}
if (!id.equals(FtpUser.ADMIN)) {
throw new FtpException(530);
}
FtpUser adminUser = new FtpUser(mConfig, null, null);
adminUser.setName(id);
adminUser.setPassword(psd);
mConfig.getUserHandler().newConnection(adminUser);
mConfig.getUserHandler().login(adminUser.getSessionId());
getLogger().info("Remote admin login");
return adminUser.getSessionId();
}
/**
* Remote admin logout.
*/
public void adminLogout(String sessId) throws FtpException {
isAdminLogin(sessId);
mConfig.getUserHandler().closeConnection(sessId);
getLogger().info("Remote admin logout");
}
/**
* Check admin login status.
*/
private void isAdminLogin(String sessId) throws FtpException {
if(sessId == null) {
throw new FtpException(530);
}
FtpUser adminUser = mConfig.getUserHandler().getConnectedUser(sessId);
if(adminUser == null) {
throw new FtpException(530);
}
if(!adminUser.getIsAdmin()) {
throw new FtpException(530);
}
if (!adminUser.hasLoggedIn()) {
throw new FtpException(530);
}
}
}
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/blocks/server/DefaultFtpServer.xinfo
Index: DefaultFtpServer.xinfo
===================================================================
<?xml version="1.0"?>
<blockinfo>
<!-- section to describe block -->
<block>
<version>1.0</version>
</block>
<!-- services that are offered by this block -->
<services>
<service name="org.apache.avalon.ftpserver.services.FtpServer"
version="1.0" />
</services>
<dependencies>
<dependency>
<service
name="org.apache.avalon.cornerstone.services.sockets.SocketManager"
version="1.0"/>
</dependency>
<dependency>
<service
name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
version="1.0"/>
</dependency>
<dependency>
<service
name="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"
version="1.0"/>
</dependency>
</dependencies>
</blockinfo>
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/blocks/server/RemoteAdminAdaptor.java
Index: RemoteAdminAdaptor.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.blocks.server;
import org.apache.avalon.ftpserver.interfaces.FtpRemoteAdmin;
import org.apache.avalon.ftpserver.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
import org.apache.avalon.ftpserver.FtpException;
import java.rmi.RemoteException;
public class RemoteAdminAdaptor implements FtpRemoteAdmin {
FtpAdmin mFtpAdmin;
public RemoteAdminAdaptor(FtpAdmin ftpAdmin) {
mFtpAdmin = ftpAdmin;
}
/**
* Remote admin login
*/
public String adminLogin(String id, String password) throws
RemoteException, FtpException {
return mFtpAdmin.adminLogin(id,password);
}
/**
* Remote admin logout
*/
public void adminLogout(String sessId) throws RemoteException,
FtpException {
mFtpAdmin.adminLogout(sessId);
}
/**
* Get configuration interface
*/
public FtpConfigInterface getConfigInterface(String sessId) throws
RemoteException, FtpException {
return mFtpAdmin.getConfigInterface(sessId);
}
}
1.3 +2 -2
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/CommonHandler.java
Index: CommonHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/CommonHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommonHandler.java 2001/09/12 14:42:13 1.2
+++ CommonHandler.java 2001/12/13 13:26:04 1.3
@@ -9,8 +9,8 @@
package org.apache.avalon.ftpserver.gui;
import java.awt.Component;
-import org.apache.avalon.ftpserver.interfaces.FtpServerInterface;
import org.apache.avalon.ftpserver.interfaces.FtpConfigInterface;
+import org.apache.avalon.ftpserver.interfaces.FtpRemoteAdmin;
/**
* GUI common handler methods.
@@ -39,7 +39,7 @@
/**
* Get ftp server interface
*/
- FtpServerInterface getServer();
+ FtpRemoteAdmin getServer();
/**
1.8 +4 -4
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdminFrame.java
Index: FtpAdminFrame.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdminFrame.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FtpAdminFrame.java 2001/11/10 21:34:04 1.7
+++ FtpAdminFrame.java 2001/12/13 13:26:04 1.8
@@ -15,7 +15,7 @@
import javax.swing.event.*;
import javax.swing.tree.*;
-import org.apache.avalon.ftpserver.interfaces.FtpServerInterface;
+import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
import org.apache.avalon.ftpserver.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.FtpException;
import org.jesktop.frimble.JFrimble;
@@ -54,7 +54,7 @@
jm.add(jmi);
jmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- new FtpAdmin(FtpAdminFrame.this);
+ new FtpAdminDialog(FtpAdminFrame.this);
}
});
super.setJMenuBar(jmb);
@@ -99,10 +99,10 @@
mjFtpPane.add(mRootPane);
mjFtpTree.addTreeSelectionListener(this);
- mjFtpTree.setSelectionPath(new
TreePath(FtpServerInterface.DISPLAY_NAME));
+ mjFtpTree.setSelectionPath(new TreePath(FtpAdmin.DISPLAY_NAME));
jSplitPane.setDividerLocation(120);
- mjTabPane.addTab(FtpServerInterface.DISPLAY_NAME, jSplitPane);
+ mjTabPane.addTab(FtpAdmin.DISPLAY_NAME, jSplitPane);
mFtpAdminPanel.add(mjTabPane, BorderLayout.CENTER);
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
1.5 +4 -4
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpTreeModel.java
Index: FtpTreeModel.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpTreeModel.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FtpTreeModel.java 2001/11/10 21:34:04 1.4
+++ FtpTreeModel.java 2001/12/13 13:26:04 1.5
@@ -14,7 +14,7 @@
import javax.swing.tree.TreeModel;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
-import org.apache.avalon.ftpserver.interfaces.FtpServerInterface;
+import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
/**
* This is FTP user interface tree structure. Currently it is very simple.
@@ -58,7 +58,7 @@
* get root object
*/
public Object getRoot() {
- return FtpServerInterface.DISPLAY_NAME;
+ return FtpAdmin.DISPLAY_NAME;
}
/**
@@ -72,7 +72,7 @@
* get child count
*/
public int getChildCount(Object parent) {
- if(parent.equals(FtpServerInterface.DISPLAY_NAME)) {
+ if(parent.equals(FtpAdmin.DISPLAY_NAME)) {
return CHILDREN.length;
}
return 0;
@@ -82,7 +82,7 @@
* is a leaf or node
*/
public boolean isLeaf(Object node) {
- return !node.equals(FtpServerInterface.DISPLAY_NAME);
+ return !node.equals(FtpAdmin.DISPLAY_NAME);
}
/**
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdminDialog.java
Index: FtpAdminDialog.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.gui;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.apache.avalon.ftpserver.FtpException;
import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
import org.apache.avalon.ftpserver.interfaces.FtpConfigInterface;
import org.apache.avalon.ftpserver.interfaces.FtpRemoteAdmin;
/**
* Ftp admin gui starting point. It look up for
* the server object and logs in the admin user.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rana Bhattacharyya</a>
*/
public
class FtpAdminDialog extends JDialog implements CommonHandler {
private String mstSessionId = null;
private JTextField mjHostTxt = null;
private JTextField mjPortTxt = null;
private JTextField mjAdminTxt = null;
private JPasswordField mjPasswordTxt = null;
private FtpRemoteAdmin mServer = null;
private FtpConfigInterface mConfig = null;
private FtpAdminFrame mFtpAdminFrame;
/**
* Consructor - initialize components and display
* the login dialog box.
*/
public FtpAdminDialog(FtpAdminFrame faf) {
mFtpAdminFrame = faf;
initComponents();
pack();
setResizable(false);
setTitle("Login");
GuiUtils.setLocation(this);
show();
}
/**
* Iniialize all the swing components.
*/
public void initComponents() {
GridBagConstraints gc;
getContentPane().setLayout(new GridBagLayout());
// Host name
JLabel jHostLab = new JLabel("Host");
jHostLab.setHorizontalAlignment(JLabel.RIGHT);
jHostLab.setForeground(Color.black);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 0;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(0, 0, 5, 10);
getContentPane().add(jHostLab, gc);
mjHostTxt = new JTextField("localhost");
mjHostTxt.setColumns(15);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = 0;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
getContentPane().add(mjHostTxt, gc);
// Port number
JLabel jPortLab = new JLabel("Port");
jPortLab.setHorizontalAlignment(JLabel.RIGHT);
jPortLab.setForeground(Color.black);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 1;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(0, 0, 5, 10);
getContentPane().add(jPortLab, gc);
mjPortTxt = new JTextField(String.valueOf(Registry.REGISTRY_PORT));
mjPortTxt.setColumns(5);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = 1;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
getContentPane().add(mjPortTxt, gc);
// Admin login id
JLabel jAdminLab = new JLabel("Admin Id");
jAdminLab.setHorizontalAlignment(JLabel.RIGHT);
jAdminLab.setForeground(Color.black);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(0, 0, 5, 10);
getContentPane().add(jAdminLab, gc);
mjAdminTxt = new JTextField();
mjAdminTxt.setColumns(15);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = 2;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
getContentPane().add(mjAdminTxt, gc);
// Admin password
JLabel jPasswordLab = new JLabel("Admin Password");
jPasswordLab.setHorizontalAlignment(JLabel.RIGHT);
jPasswordLab.setForeground(Color.black);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 3;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(0, 0, 5, 10);
getContentPane().add(jPasswordLab, gc);
mjPasswordTxt = new JPasswordField();
mjPasswordTxt.setColumns(15);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = 3;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
getContentPane().add(mjPasswordTxt, gc);
// button panel
JPanel btnPane = new JPanel();
btnPane.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton jLoginBtn = new JButton("Login");
jLoginBtn.setSelected(true);
jLoginBtn.setDefaultCapable(true);
btnPane.add(jLoginBtn);
JButton jCancelBtn = new JButton("Cancel");
btnPane.add(jCancelBtn);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 4;
gc.gridwidth = 3;
getContentPane().add(btnPane, gc);
// event listeners
jLoginBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
login();
}
});
jCancelBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
terminate();
}
});
}
/*
* Handle window closing event.
*/
protected void processWindowEvent(WindowEvent e) {
int id = e.getID();
if (id == WindowEvent.WINDOW_CLOSING) {
super.processWindowEvent(e);
terminate();
}
}
/**
* Login and get remote object
*/
private void login() {
try {
String host = mjHostTxt.getText();
String port = mjPortTxt.getText();
String login = mjAdminTxt.getText();
String password = new String(mjPasswordTxt.getPassword());
mjHostTxt.setText("localhost");
mjPortTxt.setText(String.valueOf(Registry.REGISTRY_PORT));
mjAdminTxt.setText("");
mjPasswordTxt.setText("");
String url = "rmi://" + host + ":" + port + "/" +
FtpAdmin.class.getName();
mServer = (FtpRemoteAdmin)Naming.lookup(url);
mstSessionId = mServer.adminLogin(login, password);
mConfig = mServer.getConfigInterface(mstSessionId);
mFtpAdminFrame.setCommonHandler(this);
setVisible(false);
}
catch(FtpException ex) {
GuiUtils.showErrorMessage(getTopComponent(), "Login failuer - try
again.");
}
catch(Exception ex) {
handleException(ex);
}
}
/**
* Handle exception
*/
public void handleException(Exception ex) {
//ex.printStackTrace();
GuiUtils.showErrorMessage(getTopComponent(), ex.getMessage());
if (ex instanceof java.rmi.RemoteException) {
logout();
}
}
/**
* Terminate application
*/
public void terminate() {
logout();
dispose();
//System.exit(0);
}
/**
* Get admin session id
*/
public String getSessionId() {
return mstSessionId;
}
/**
* Get server interface
*/
public FtpRemoteAdmin getServer() {
return mServer;
}
/**
* Get ftp server configuration
*/
public FtpConfigInterface getConfig() {
return mConfig;
}
/**
* Logout admin user
*/
public void logout() {
if (mFtpAdminFrame != null) {
mFtpAdminFrame.close();
mFtpAdminFrame = null;
}
setVisible(true);
if (mServer != null) {
try {
mServer.adminLogout(mstSessionId);
}
catch(Exception ex) {
}
mServer = null;
}
mstSessionId = null;
mConfig = null;
}
/**
* Get top component of this application
*/
public Component getTopComponent() {
return this;
}
}
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/interfaces/FtpAdmin.java
Index: FtpAdmin.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.interfaces;
import org.apache.avalon.ftpserver.FtpException;
/**
* Ftp server interface. Only the implementation of this
* interface will be bound. After binding we have to call
* <code>adminLogin(user, password)</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rana Bhattacharyya</a>
*/
public
interface FtpAdmin {
/**
* Ftp server name
*/
String DISPLAY_NAME = "Ftp";
/**
* Remote admin login
*/
String adminLogin(String id, String password) throws FtpException;
/**
* Remote admin logout
*/
void adminLogout(String sessId) throws FtpException;
/**
* Get configuration interface
*/
FtpConfigInterface getConfigInterface(String sessId) throws FtpException;
}
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/interfaces/FtpRemoteAdmin.java
Index: FtpRemoteAdmin.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.interfaces;
import org.apache.avalon.ftpserver.FtpException;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
* Ftp server interface. Only the implementation of this
* interface will be bound. After binding we have to call
* <code>adminLogin(user, password)</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rana Bhattacharyya</a>
*/
public
interface FtpRemoteAdmin extends Remote {
/**
* Ftp server name
*/
String DISPLAY_NAME = "Ftp";
/**
* Remote admin login
*/
String adminLogin(String id, String password) throws RemoteException,
FtpException;
/**
* Remote admin logout
*/
void adminLogout(String sessId) throws RemoteException, FtpException;
/**
* Get configuration interface
*/
FtpConfigInterface getConfigInterface(String sessId) throws
RemoteException, FtpException;
}
1.1
jakarta-avalon-cornerstone/apps/ftpserver/src/java/org/apache/avalon/ftpserver/services/FtpServer.java
Index: FtpServer.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.services;
import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
/**
* Ftp server interface. Only the implementation of this
* interface will be bound. After binding we have to call
* <code>adminLogin(user, password)</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rana Bhattacharyya</a>
*/
public
interface FtpServer extends FtpAdmin {
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>