You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-commits@incubator.apache.org by ng...@apache.org on 2007/01/02 16:17:26 UTC

svn commit: r491831 [4/4] - in /incubator/ftpserver/trunk: admin-gui/src/java/org/apache/ftpserver/gui/ core/src/java/org/apache/ftpserver/ core/src/java/org/apache/ftpserver/command/ core/src/java/org/apache/ftpserver/ftplet/ core/src/java/org/apache/...

Added: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java?view=auto&rev=491831
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java (added)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java Tue Jan  2 08:17:22 2007
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */  
+
+package org.apache.ftpserver.ftplet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.util.Date;
+
+/**
+ * Defines an client session with the FTP server. The session is born 
+ * when the client connects and dies when the client disconnects. 
+ * Ftplet methods will always get the same session for one user and one 
+ * connection.
+ * So the attributes set by <code>setAttribute()</code> will be always 
+ * available later unless that attribute is removed or the client disconnects.
+ */
+public 
+interface FtpSession {
+
+    /**
+     * Receive the current ongoing {@link FtpRequest}. If no request
+     * is currently active, this method will return null.
+     * @return The active {@link FtpRequest} or null.
+     */
+    FtpRequest getCurrentRequest();
+    
+    /**
+     * Returns the IP address of the client that sent the request.
+     */
+    InetAddress getRemoteAddress();
+    
+    /**
+     * Get connection time.
+     */
+    Date getConnectionTime();
+    
+    /**
+     * Get the login time.
+     */
+    Date getLoginTime();
+    
+    /**
+     * Get last access time.
+     */
+    Date getLastAccessTime();
+
+    /**
+     * Returns maximum idle time. This time equals to
+     * {@link ConnectionManagerImpl#getDefaultIdleSec()} until user login, and
+     * {@link User#getMaxIdleTime()} after user login.
+     */
+    int getMaxIdleTime();
+    
+    /**
+     * Set maximum idle time in seconds. This time equals to
+     * {@link ConnectionManagerImpl#getDefaultIdleSec()} until user login, and
+     * {@link User#getMaxIdleTime()} after user login.
+     */
+    void setMaxIdleTime(int maxIdleTimeSec);
+
+    /**
+     * Get user object.
+     */
+    User getUser();
+
+    /**
+     * Returns user name entered in USER command
+     * 
+     * @return user name entered in USER command
+     */
+    String getUserArgument();
+    
+    /**
+     * Get the requested language.
+     */
+    String getLanguage();
+    
+    /**
+     * Is the user logged in?
+     */
+    boolean isLoggedIn();
+
+    /**
+     * Get user file system view.
+     */
+    FileSystemView getFileSystemView();
+    
+    /**
+     * Get file upload/download offset.
+     */
+    long getFileOffset();
+    
+    /**
+     * Get rename from file object.
+     */
+    FileObject getRenameFrom();
+    
+    /**
+     * Get data input stream.
+     */
+    InputStream getDataInputStream() throws IOException;
+    
+    /**
+     * Get data output stream.
+     */
+    OutputStream getDataOutputStream() throws IOException;
+    
+    /**
+     * Returns the value of the named attribute as an Object, 
+     * or null if no attribute of the given name exists.
+     */
+    Object getAttribute(String name);
+    
+    /**
+     * Stores an attribute in this request. It will be available 
+     * until it was removed or when the connection ends. 
+     */
+    void setAttribute(String name, Object value);
+    
+    /**
+     * Removes an attribute from this request.
+     */
+    void removeAttribute(String name);
+    
+    /**
+     * Clear all attributes
+     */
+    void clear();
+}

Propchange: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Ftplet.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Ftplet.java?view=diff&rev=491831&r1=491830&r2=491831
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Ftplet.java (original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Ftplet.java Tue Jan  2 08:17:22 2007
@@ -69,103 +69,103 @@
     /**
      * Client connect notification method.
      */
-    FtpletEnum onConnect(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onConnect(FtpSession session, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Client disconnect notification method. This is the last callback method.
      */
-    FtpletEnum onDisconnect(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onDisconnect(FtpSession session, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Client successful login notification method. 
      * If the user has successfully authenticated, the 
-     * {@link FtpRequest#getUser()} method will return the user,
+     * {@link FtpSession#getUser()} method will return the user,
      * otherwise it will return null.
      */
-    FtpletEnum onLogin(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onLogin(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
             
     /**
      * File delete request notification method.
      */
-    FtpletEnum onDeleteStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onDeleteStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * File delete success notification method.
      */
-    FtpletEnum onDeleteEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * File upload request notification method.
      */
-    FtpletEnum onUploadStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onUploadStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
 
     /**
      * File upload success notification method.
      */
-    FtpletEnum onUploadEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onUploadEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * File download request notification method.
      */
-    FtpletEnum onDownloadStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onDownloadStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * File download success notification method.
      */
-    FtpletEnum onDownloadEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Remove directory request notification method.
      */
-    FtpletEnum onRmdirStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onRmdirStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Directory removal success notification method.
      */
-    FtpletEnum onRmdirEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Directory creation request notification method.
      */
-    FtpletEnum onMkdirStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onMkdirStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Directory creation success notification method.
      */
-    FtpletEnum onMkdirEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
             
     /**
      * File append request notification method.
      */
-    FtpletEnum onAppendStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onAppendStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * File append success notification method.
      */
-    FtpletEnum onAppendEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onAppendEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Unique file create request notification method.
      */
-    FtpletEnum onUploadUniqueStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Unique file create success notification method.
      */
-    FtpletEnum onUploadUniqueEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Rename start notification method.
      */
-    FtpletEnum onRenameStart(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onRenameStart(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * Rename end notification method.
      */
-    FtpletEnum onRenameEnd(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onRenameEnd(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
     
     /**
      * SITE command notification method.
      */
-    FtpletEnum onSite(FtpRequest request, FtpResponse response) throws FtpException, IOException;
+    FtpletEnum onSite(FtpSession session, FtpRequest request, FtpResponse response) throws FtpException, IOException;
 }