You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/08/17 21:52:49 UTC
svn commit: r686637 [7/16] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/command/
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/ ...
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -52,490 +52,531 @@
import org.apache.mina.core.write.WriteRequest;
import org.apache.mina.filter.ssl.SslFilter;
+/**
+ *
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
public class FtpIoSession implements IoSession {
/**
* Contains user name between USER and PASS commands
*/
- public static final String ATTRIBUTE_PREFIX = "org.apache.ftpserver.";
- private static final String ATTRIBUTE_USER_ARGUMENT = ATTRIBUTE_PREFIX + "user-argument";
- private static final String ATTRIBUTE_USER = ATTRIBUTE_PREFIX + "user";
- private static final String ATTRIBUTE_LANGUAGE = ATTRIBUTE_PREFIX + "language";
- private static final String ATTRIBUTE_LOGIN_TIME = ATTRIBUTE_PREFIX + "login-time";
- private static final String ATTRIBUTE_DATA_CONNECTION = ATTRIBUTE_PREFIX + "data-connection";
- private static final String ATTRIBUTE_FILE_SYSTEM = ATTRIBUTE_PREFIX + "file-system";
- private static final String ATTRIBUTE_RENAME_FROM = ATTRIBUTE_PREFIX + "rename-from";
- private static final String ATTRIBUTE_FILE_OFFSET = ATTRIBUTE_PREFIX + "file-offset";
- private static final String ATTRIBUTE_DATA_TYPE = ATTRIBUTE_PREFIX + "data-type";
- private static final String ATTRIBUTE_STRUCTURE = ATTRIBUTE_PREFIX + "structure";
- private static final String ATTRIBUTE_FAILED_LOGINS = ATTRIBUTE_PREFIX + "failed-logins";
- private static final String ATTRIBUTE_LISTENER = ATTRIBUTE_PREFIX + "listener";
- private static final String ATTRIBUTE_MAX_IDLE_TIME = ATTRIBUTE_PREFIX + "max-idle-time";
- private static final String ATTRIBUTE_LAST_ACCESS_TIME = ATTRIBUTE_PREFIX + "last-access-time";
- private static final String ATTRIBUTE_CACHED_REMOTE_ADDRESS = ATTRIBUTE_PREFIX + "cached-remote-address";
-
- private IoSession wrappedSession;
- private FtpServerContext context;
-
+ public static final String ATTRIBUTE_PREFIX = "org.apache.ftpserver.";
+
+ private static final String ATTRIBUTE_USER_ARGUMENT = ATTRIBUTE_PREFIX
+ + "user-argument";
+
+ private static final String ATTRIBUTE_USER = ATTRIBUTE_PREFIX + "user";
+
+ private static final String ATTRIBUTE_LANGUAGE = ATTRIBUTE_PREFIX
+ + "language";
+
+ private static final String ATTRIBUTE_LOGIN_TIME = ATTRIBUTE_PREFIX
+ + "login-time";
+
+ private static final String ATTRIBUTE_DATA_CONNECTION = ATTRIBUTE_PREFIX
+ + "data-connection";
+
+ private static final String ATTRIBUTE_FILE_SYSTEM = ATTRIBUTE_PREFIX
+ + "file-system";
+
+ private static final String ATTRIBUTE_RENAME_FROM = ATTRIBUTE_PREFIX
+ + "rename-from";
+
+ private static final String ATTRIBUTE_FILE_OFFSET = ATTRIBUTE_PREFIX
+ + "file-offset";
+
+ private static final String ATTRIBUTE_DATA_TYPE = ATTRIBUTE_PREFIX
+ + "data-type";
+
+ private static final String ATTRIBUTE_STRUCTURE = ATTRIBUTE_PREFIX
+ + "structure";
+
+ private static final String ATTRIBUTE_FAILED_LOGINS = ATTRIBUTE_PREFIX
+ + "failed-logins";
+
+ private static final String ATTRIBUTE_LISTENER = ATTRIBUTE_PREFIX
+ + "listener";
+
+ private static final String ATTRIBUTE_MAX_IDLE_TIME = ATTRIBUTE_PREFIX
+ + "max-idle-time";
+
+ private static final String ATTRIBUTE_LAST_ACCESS_TIME = ATTRIBUTE_PREFIX
+ + "last-access-time";
+
+ private static final String ATTRIBUTE_CACHED_REMOTE_ADDRESS = ATTRIBUTE_PREFIX
+ + "cached-remote-address";
+
+ private IoSession wrappedSession;
+
+ private FtpServerContext context;
+
/* Begin wrapped IoSession methods */
-
- /**
- * @see IoSession#close()
- */
- public CloseFuture close() {
- return wrappedSession.close();
- }
-
- /**
- * @see IoSession#close(boolean)
- */
- public CloseFuture close(boolean immediately) {
- return wrappedSession.close(immediately);
- }
-
- /**
- * @see IoSession#closeOnFlush()
- */
- public CloseFuture closeOnFlush() {
- return wrappedSession.closeOnFlush();
- }
-
- /**
- * @see IoSession#containsAttribute(Object)
- */
- public boolean containsAttribute(Object key) {
- return wrappedSession.containsAttribute(key);
- }
-
- /**
- * @see IoSession#getAttachment()
- */
- @SuppressWarnings("deprecation")
- public Object getAttachment() {
- return wrappedSession.getAttachment();
- }
-
- /**
- * @see IoSession#getAttribute(Object)
- */
- public Object getAttribute(Object key) {
- return wrappedSession.getAttribute(key);
- }
-
- /**
- * @see IoSession#getAttribute(Object, Object)
- */
- public Object getAttribute(Object key, Object defaultValue) {
- return wrappedSession.getAttribute(key, defaultValue);
- }
-
- /**
- * @see IoSession#getAttributeKeys()
- */
- public Set<Object> getAttributeKeys() {
- return wrappedSession.getAttributeKeys();
- }
-
- /**
- * @see IoSession#getBothIdleCount()
- */
- public int getBothIdleCount() {
- return wrappedSession.getBothIdleCount();
- }
-
- /**
- * @see IoSession#getCloseFuture()
- */
- public CloseFuture getCloseFuture() {
- return wrappedSession.getCloseFuture();
- }
-
- /**
- * @see IoSession#getConfig()
- */
- public IoSessionConfig getConfig() {
- return wrappedSession.getConfig();
- }
-
- /**
- * @see IoSession#getCreationTime()
- */
- public long getCreationTime() {
- return wrappedSession.getCreationTime();
- }
-
- /**
- * @see IoSession#getFilterChain()
- */
- public IoFilterChain getFilterChain() {
- return wrappedSession.getFilterChain();
- }
-
- /**
- * @see IoSession#getHandler()
- */
- public IoHandler getHandler() {
- return wrappedSession.getHandler();
- }
-
- /**
- * @see IoSession#getId()
- */
- public long getId() {
- return wrappedSession.getId();
- }
-
- /**
- * @see IoSession#getIdleCount(IdleStatus)
- */
- public int getIdleCount(IdleStatus status) {
- return wrappedSession.getIdleCount(status);
- }
-
- /**
- * @see IoSession#getLastBothIdleTime()
- */
- public long getLastBothIdleTime() {
- return wrappedSession.getLastBothIdleTime();
- }
-
- /**
- * @see IoSession#getLastIdleTime(IdleStatus)
- */
- public long getLastIdleTime(IdleStatus status) {
- return wrappedSession.getLastIdleTime(status);
- }
-
- /**
- * @see IoSession#getLastIoTime()
- */
- public long getLastIoTime() {
- return wrappedSession.getLastIoTime();
- }
-
- /**
- * @see IoSession#getLastReadTime()
- */
- public long getLastReadTime() {
- return wrappedSession.getLastReadTime();
- }
-
- /**
- * @see IoSession#getLastReaderIdleTime()
- */
- public long getLastReaderIdleTime() {
- return wrappedSession.getLastReaderIdleTime();
- }
-
- /**
- * @see IoSession#getLastWriteTime()
- */
- public long getLastWriteTime() {
- return wrappedSession.getLastWriteTime();
- }
-
- /**
- * @see IoSession#getLastWriterIdleTime()
- */
- public long getLastWriterIdleTime() {
- return wrappedSession.getLastWriterIdleTime();
- }
-
- /**
- * @see IoSession#getLocalAddress()
- */
- public SocketAddress getLocalAddress() {
- return wrappedSession.getLocalAddress();
- }
-
- /**
- * @see IoSession#getReadBytes()
- */
- public long getReadBytes() {
- return wrappedSession.getReadBytes();
- }
-
- /**
- * @see IoSession#getReadBytesThroughput()
- */
- public double getReadBytesThroughput() {
- return wrappedSession.getReadBytesThroughput();
- }
-
- /**
- * @see IoSession#getReadMessages()
- */
- public long getReadMessages() {
- return wrappedSession.getReadMessages();
- }
-
- /**
- * @see IoSession#getReadMessagesThroughput()
- */
- public double getReadMessagesThroughput() {
- return wrappedSession.getReadMessagesThroughput();
- }
-
- /**
- * @see IoSession#getReaderIdleCount()
- */
- public int getReaderIdleCount() {
- return wrappedSession.getReaderIdleCount();
- }
-
- /**
- * @see IoSession#getRemoteAddress()
- */
- public SocketAddress getRemoteAddress() {
- // when closing a socket, the remote address might be reset to null
- // therefore, we attempt to keep a cached copy around
-
- SocketAddress address = wrappedSession.getRemoteAddress();
- if(address == null && containsAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS)) {
- return (SocketAddress) getAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS);
- } else {
- setAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS, address);
- return address;
- }
- }
-
- /**
- * @see IoSession#getScheduledWriteBytes()
- */
- public long getScheduledWriteBytes() {
- return wrappedSession.getScheduledWriteBytes();
- }
-
- /**
- * @see IoSession#getScheduledWriteMessages()
- */
- public int getScheduledWriteMessages() {
- return wrappedSession.getScheduledWriteMessages();
- }
-
- /**
- * @see IoSession#getService()
- */
- public IoService getService() {
- return wrappedSession.getService();
- }
-
- /**
- * @see IoSession#getServiceAddress()
- */
- public SocketAddress getServiceAddress() {
- return wrappedSession.getServiceAddress();
- }
-
- /**
- * @see IoSession#getTrafficMask()
- */
- public TrafficMask getTrafficMask() {
- return wrappedSession.getTrafficMask();
- }
-
- /**
- * @see IoSession#getTransportMetadata()
- */
- public TransportMetadata getTransportMetadata() {
- return wrappedSession.getTransportMetadata();
- }
-
- /**
- * @see IoSession#getWriterIdleCount()
- */
- public int getWriterIdleCount() {
- return wrappedSession.getWriterIdleCount();
- }
-
- /**
- * @see IoSession#getWrittenBytes()
- */
- public long getWrittenBytes() {
- return wrappedSession.getWrittenBytes();
- }
-
- /**
- * @see IoSession#getWrittenBytesThroughput()
- */
- public double getWrittenBytesThroughput() {
- return wrappedSession.getWrittenBytesThroughput();
- }
-
- /**
- * @see IoSession#getWrittenMessages()
- */
- public long getWrittenMessages() {
- return wrappedSession.getWrittenMessages();
- }
-
- /**
- * @see IoSession#getWrittenMessagesThroughput()
- */
- public double getWrittenMessagesThroughput() {
- return wrappedSession.getWrittenMessagesThroughput();
- }
-
- /**
- * @see IoSession#isClosing()
- */
- public boolean isClosing() {
- return wrappedSession.isClosing();
- }
-
- /**
- * @see IoSession#isConnected()
- */
- public boolean isConnected() {
- return wrappedSession.isConnected();
- }
-
- /**
- * @see IoSession#isIdle(IdleStatus)
- */
- public boolean isIdle(IdleStatus status) {
- return wrappedSession.isIdle(status);
- }
-
- /**
- * @see IoSession#read()
- */
- public ReadFuture read() {
- return wrappedSession.read();
- }
-
- /**
- * @see IoSession#removeAttribute(Object)
- */
- public Object removeAttribute(Object key) {
- return wrappedSession.removeAttribute(key);
- }
-
- /**
- * @see IoSession#removeAttribute(Object, Object)
- */
- public boolean removeAttribute(Object key, Object value) {
- return wrappedSession.removeAttribute(key, value);
- }
-
- /**
- * @see IoSession#replaceAttribute(Object, Object, Object)
- */
- public boolean replaceAttribute(Object key, Object oldValue, Object newValue) {
- return wrappedSession.replaceAttribute(key, oldValue, newValue);
- }
-
- /**
- * @see IoSession#resumeRead()
- */
- public void resumeRead() {
- wrappedSession.resumeRead();
- }
-
- /**
- * @see IoSession#resumeWrite()
- */
- public void resumeWrite() {
- wrappedSession.resumeWrite();
- }
-
- /**
- * @see IoSession#setAttachment(Object)
- */
- @SuppressWarnings("deprecation")
- public Object setAttachment(Object attachment) {
- return wrappedSession.setAttachment(attachment);
- }
-
- /**
- * @see IoSession#setAttribute(Object)
- */
- public Object setAttribute(Object key) {
- return wrappedSession.setAttribute(key);
- }
-
- /**
- * @see IoSession#setAttribute(Object, Object)
- */
- public Object setAttribute(Object key, Object value) {
- return wrappedSession.setAttribute(key, value);
- }
-
- /**
- * @see IoSession#setAttributeIfAbsent(Object)
- */
- public Object setAttributeIfAbsent(Object key) {
- return wrappedSession.setAttributeIfAbsent(key);
- }
-
- /**
- * @see IoSession#setAttributeIfAbsent(Object, Object)
- */
- public Object setAttributeIfAbsent(Object key, Object value) {
- return wrappedSession.setAttributeIfAbsent(key, value);
- }
-
- /**
- * @see IoSession#setTrafficMask(TrafficMask)
- */
- public void setTrafficMask(TrafficMask trafficMask) {
- wrappedSession.setTrafficMask(trafficMask);
- }
-
- /**
- * @see IoSession#suspendRead()
- */
- public void suspendRead() {
- wrappedSession.suspendRead();
- }
-
- /**
- * @see IoSession#suspendWrite()
- */
- public void suspendWrite() {
- wrappedSession.suspendWrite();
- }
-
- /**
- * @see IoSession#write(Object)
- */
- public WriteFuture write(Object message) {
- return wrappedSession.write(message);
- }
-
- /**
- * @see IoSession#write(Object, SocketAddress)
- */
- public WriteFuture write(Object message, SocketAddress destination) {
- return wrappedSession.write(message, destination);
- }
-
- /* End wrapped IoSession methods */
-
- public void resetState() {
- removeAttribute(ATTRIBUTE_RENAME_FROM);
- removeAttribute(ATTRIBUTE_FILE_OFFSET);
- }
-
- public synchronized ServerDataConnectionFactory getDataConnection() {
- if(containsAttribute(ATTRIBUTE_DATA_CONNECTION)) {
- return (ServerDataConnectionFactory) getAttribute(ATTRIBUTE_DATA_CONNECTION);
- } else {
- IODataConnectionFactory dataCon = new IODataConnectionFactory(context, this);
- dataCon.setServerControlAddress(((InetSocketAddress)getLocalAddress()).getAddress());
- setAttribute(ATTRIBUTE_DATA_CONNECTION, dataCon);
-
- return dataCon;
- }
- }
-
- public FileSystemView getFileSystemView() {
- return (FileSystemView) getAttribute(ATTRIBUTE_FILE_SYSTEM);
- }
-
- public User getUser() {
- return (User) getAttribute(ATTRIBUTE_USER);
- }
+
+ /**
+ * @see IoSession#close()
+ */
+ public CloseFuture close() {
+ return wrappedSession.close();
+ }
+
+ /**
+ * @see IoSession#close(boolean)
+ */
+ public CloseFuture close(boolean immediately) {
+ return wrappedSession.close(immediately);
+ }
+
+ /**
+ * @see IoSession#closeOnFlush()
+ */
+ public CloseFuture closeOnFlush() {
+ return wrappedSession.closeOnFlush();
+ }
+
+ /**
+ * @see IoSession#containsAttribute(Object)
+ */
+ public boolean containsAttribute(Object key) {
+ return wrappedSession.containsAttribute(key);
+ }
+
+ /**
+ * @see IoSession#getAttachment()
+ */
+ @SuppressWarnings("deprecation")
+ public Object getAttachment() {
+ return wrappedSession.getAttachment();
+ }
+
+ /**
+ * @see IoSession#getAttribute(Object)
+ */
+ public Object getAttribute(Object key) {
+ return wrappedSession.getAttribute(key);
+ }
+
+ /**
+ * @see IoSession#getAttribute(Object, Object)
+ */
+ public Object getAttribute(Object key, Object defaultValue) {
+ return wrappedSession.getAttribute(key, defaultValue);
+ }
+
+ /**
+ * @see IoSession#getAttributeKeys()
+ */
+ public Set<Object> getAttributeKeys() {
+ return wrappedSession.getAttributeKeys();
+ }
+
+ /**
+ * @see IoSession#getBothIdleCount()
+ */
+ public int getBothIdleCount() {
+ return wrappedSession.getBothIdleCount();
+ }
+
+ /**
+ * @see IoSession#getCloseFuture()
+ */
+ public CloseFuture getCloseFuture() {
+ return wrappedSession.getCloseFuture();
+ }
+
+ /**
+ * @see IoSession#getConfig()
+ */
+ public IoSessionConfig getConfig() {
+ return wrappedSession.getConfig();
+ }
+
+ /**
+ * @see IoSession#getCreationTime()
+ */
+ public long getCreationTime() {
+ return wrappedSession.getCreationTime();
+ }
+
+ /**
+ * @see IoSession#getFilterChain()
+ */
+ public IoFilterChain getFilterChain() {
+ return wrappedSession.getFilterChain();
+ }
+
+ /**
+ * @see IoSession#getHandler()
+ */
+ public IoHandler getHandler() {
+ return wrappedSession.getHandler();
+ }
+
+ /**
+ * @see IoSession#getId()
+ */
+ public long getId() {
+ return wrappedSession.getId();
+ }
+
+ /**
+ * @see IoSession#getIdleCount(IdleStatus)
+ */
+ public int getIdleCount(IdleStatus status) {
+ return wrappedSession.getIdleCount(status);
+ }
+
+ /**
+ * @see IoSession#getLastBothIdleTime()
+ */
+ public long getLastBothIdleTime() {
+ return wrappedSession.getLastBothIdleTime();
+ }
+
+ /**
+ * @see IoSession#getLastIdleTime(IdleStatus)
+ */
+ public long getLastIdleTime(IdleStatus status) {
+ return wrappedSession.getLastIdleTime(status);
+ }
+
+ /**
+ * @see IoSession#getLastIoTime()
+ */
+ public long getLastIoTime() {
+ return wrappedSession.getLastIoTime();
+ }
+
+ /**
+ * @see IoSession#getLastReadTime()
+ */
+ public long getLastReadTime() {
+ return wrappedSession.getLastReadTime();
+ }
+
+ /**
+ * @see IoSession#getLastReaderIdleTime()
+ */
+ public long getLastReaderIdleTime() {
+ return wrappedSession.getLastReaderIdleTime();
+ }
+
+ /**
+ * @see IoSession#getLastWriteTime()
+ */
+ public long getLastWriteTime() {
+ return wrappedSession.getLastWriteTime();
+ }
+
+ /**
+ * @see IoSession#getLastWriterIdleTime()
+ */
+ public long getLastWriterIdleTime() {
+ return wrappedSession.getLastWriterIdleTime();
+ }
+
+ /**
+ * @see IoSession#getLocalAddress()
+ */
+ public SocketAddress getLocalAddress() {
+ return wrappedSession.getLocalAddress();
+ }
+
+ /**
+ * @see IoSession#getReadBytes()
+ */
+ public long getReadBytes() {
+ return wrappedSession.getReadBytes();
+ }
+
+ /**
+ * @see IoSession#getReadBytesThroughput()
+ */
+ public double getReadBytesThroughput() {
+ return wrappedSession.getReadBytesThroughput();
+ }
+
+ /**
+ * @see IoSession#getReadMessages()
+ */
+ public long getReadMessages() {
+ return wrappedSession.getReadMessages();
+ }
+
+ /**
+ * @see IoSession#getReadMessagesThroughput()
+ */
+ public double getReadMessagesThroughput() {
+ return wrappedSession.getReadMessagesThroughput();
+ }
+
+ /**
+ * @see IoSession#getReaderIdleCount()
+ */
+ public int getReaderIdleCount() {
+ return wrappedSession.getReaderIdleCount();
+ }
+
+ /**
+ * @see IoSession#getRemoteAddress()
+ */
+ public SocketAddress getRemoteAddress() {
+ // when closing a socket, the remote address might be reset to null
+ // therefore, we attempt to keep a cached copy around
+
+ SocketAddress address = wrappedSession.getRemoteAddress();
+ if (address == null
+ && containsAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS)) {
+ return (SocketAddress) getAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS);
+ } else {
+ setAttribute(ATTRIBUTE_CACHED_REMOTE_ADDRESS, address);
+ return address;
+ }
+ }
+
+ /**
+ * @see IoSession#getScheduledWriteBytes()
+ */
+ public long getScheduledWriteBytes() {
+ return wrappedSession.getScheduledWriteBytes();
+ }
+
+ /**
+ * @see IoSession#getScheduledWriteMessages()
+ */
+ public int getScheduledWriteMessages() {
+ return wrappedSession.getScheduledWriteMessages();
+ }
+
+ /**
+ * @see IoSession#getService()
+ */
+ public IoService getService() {
+ return wrappedSession.getService();
+ }
+
+ /**
+ * @see IoSession#getServiceAddress()
+ */
+ public SocketAddress getServiceAddress() {
+ return wrappedSession.getServiceAddress();
+ }
+
+ /**
+ * @see IoSession#getTrafficMask()
+ */
+ public TrafficMask getTrafficMask() {
+ return wrappedSession.getTrafficMask();
+ }
+
+ /**
+ * @see IoSession#getTransportMetadata()
+ */
+ public TransportMetadata getTransportMetadata() {
+ return wrappedSession.getTransportMetadata();
+ }
+
+ /**
+ * @see IoSession#getWriterIdleCount()
+ */
+ public int getWriterIdleCount() {
+ return wrappedSession.getWriterIdleCount();
+ }
+
+ /**
+ * @see IoSession#getWrittenBytes()
+ */
+ public long getWrittenBytes() {
+ return wrappedSession.getWrittenBytes();
+ }
+
+ /**
+ * @see IoSession#getWrittenBytesThroughput()
+ */
+ public double getWrittenBytesThroughput() {
+ return wrappedSession.getWrittenBytesThroughput();
+ }
+
+ /**
+ * @see IoSession#getWrittenMessages()
+ */
+ public long getWrittenMessages() {
+ return wrappedSession.getWrittenMessages();
+ }
+
+ /**
+ * @see IoSession#getWrittenMessagesThroughput()
+ */
+ public double getWrittenMessagesThroughput() {
+ return wrappedSession.getWrittenMessagesThroughput();
+ }
+
+ /**
+ * @see IoSession#isClosing()
+ */
+ public boolean isClosing() {
+ return wrappedSession.isClosing();
+ }
+
+ /**
+ * @see IoSession#isConnected()
+ */
+ public boolean isConnected() {
+ return wrappedSession.isConnected();
+ }
+
+ /**
+ * @see IoSession#isIdle(IdleStatus)
+ */
+ public boolean isIdle(IdleStatus status) {
+ return wrappedSession.isIdle(status);
+ }
+
+ /**
+ * @see IoSession#read()
+ */
+ public ReadFuture read() {
+ return wrappedSession.read();
+ }
+
+ /**
+ * @see IoSession#removeAttribute(Object)
+ */
+ public Object removeAttribute(Object key) {
+ return wrappedSession.removeAttribute(key);
+ }
+
+ /**
+ * @see IoSession#removeAttribute(Object, Object)
+ */
+ public boolean removeAttribute(Object key, Object value) {
+ return wrappedSession.removeAttribute(key, value);
+ }
+
+ /**
+ * @see IoSession#replaceAttribute(Object, Object, Object)
+ */
+ public boolean replaceAttribute(Object key, Object oldValue, Object newValue) {
+ return wrappedSession.replaceAttribute(key, oldValue, newValue);
+ }
+
+ /**
+ * @see IoSession#resumeRead()
+ */
+ public void resumeRead() {
+ wrappedSession.resumeRead();
+ }
+
+ /**
+ * @see IoSession#resumeWrite()
+ */
+ public void resumeWrite() {
+ wrappedSession.resumeWrite();
+ }
+
+ /**
+ * @see IoSession#setAttachment(Object)
+ */
+ @SuppressWarnings("deprecation")
+ public Object setAttachment(Object attachment) {
+ return wrappedSession.setAttachment(attachment);
+ }
+
+ /**
+ * @see IoSession#setAttribute(Object)
+ */
+ public Object setAttribute(Object key) {
+ return wrappedSession.setAttribute(key);
+ }
+
+ /**
+ * @see IoSession#setAttribute(Object, Object)
+ */
+ public Object setAttribute(Object key, Object value) {
+ return wrappedSession.setAttribute(key, value);
+ }
+
+ /**
+ * @see IoSession#setAttributeIfAbsent(Object)
+ */
+ public Object setAttributeIfAbsent(Object key) {
+ return wrappedSession.setAttributeIfAbsent(key);
+ }
+
+ /**
+ * @see IoSession#setAttributeIfAbsent(Object, Object)
+ */
+ public Object setAttributeIfAbsent(Object key, Object value) {
+ return wrappedSession.setAttributeIfAbsent(key, value);
+ }
+
+ /**
+ * @see IoSession#setTrafficMask(TrafficMask)
+ */
+ public void setTrafficMask(TrafficMask trafficMask) {
+ wrappedSession.setTrafficMask(trafficMask);
+ }
+
+ /**
+ * @see IoSession#suspendRead()
+ */
+ public void suspendRead() {
+ wrappedSession.suspendRead();
+ }
+
+ /**
+ * @see IoSession#suspendWrite()
+ */
+ public void suspendWrite() {
+ wrappedSession.suspendWrite();
+ }
+
+ /**
+ * @see IoSession#write(Object)
+ */
+ public WriteFuture write(Object message) {
+ return wrappedSession.write(message);
+ }
+
+ /**
+ * @see IoSession#write(Object, SocketAddress)
+ */
+ public WriteFuture write(Object message, SocketAddress destination) {
+ return wrappedSession.write(message, destination);
+ }
+
+ /* End wrapped IoSession methods */
+
+ public void resetState() {
+ removeAttribute(ATTRIBUTE_RENAME_FROM);
+ removeAttribute(ATTRIBUTE_FILE_OFFSET);
+ }
+
+ public synchronized ServerDataConnectionFactory getDataConnection() {
+ if (containsAttribute(ATTRIBUTE_DATA_CONNECTION)) {
+ return (ServerDataConnectionFactory) getAttribute(ATTRIBUTE_DATA_CONNECTION);
+ } else {
+ IODataConnectionFactory dataCon = new IODataConnectionFactory(
+ context, this);
+ dataCon
+ .setServerControlAddress(((InetSocketAddress) getLocalAddress())
+ .getAddress());
+ setAttribute(ATTRIBUTE_DATA_CONNECTION, dataCon);
+
+ return dataCon;
+ }
+ }
+
+ public FileSystemView getFileSystemView() {
+ return (FileSystemView) getAttribute(ATTRIBUTE_FILE_SYSTEM);
+ }
+
+ public User getUser() {
+ return (User) getAttribute(ATTRIBUTE_USER);
+ }
/**
* Is logged-in
@@ -544,136 +585,137 @@
return containsAttribute(ATTRIBUTE_USER);
}
- public Listener getListener() {
- return (Listener) getAttribute(ATTRIBUTE_LISTENER);
- }
-
- public void setListener(Listener listener) {
- setAttribute(ATTRIBUTE_LISTENER, listener);
- }
-
-
- public FtpSession getFtpletSession() {
- return new FtpSessionImpl(this);
- }
-
- public String getLanguage() {
- return (String) getAttribute(ATTRIBUTE_LANGUAGE);
- }
-
- public void setLanguage(String language) {
- setAttribute(ATTRIBUTE_LANGUAGE, language);
-
- }
-
- public String getUserArgument() {
- return (String) getAttribute(ATTRIBUTE_USER_ARGUMENT);
- }
-
- public void setUser(User user) {
- setAttribute(ATTRIBUTE_USER, user);
-
- }
-
- public void setUserArgument(String userArgument) {
- setAttribute(ATTRIBUTE_USER_ARGUMENT, userArgument);
-
- }
-
- public int getMaxIdleTime() {
- return (Integer) getAttribute(ATTRIBUTE_MAX_IDLE_TIME, 0);
- }
-
- public void setMaxIdleTime(int maxIdleTime) {
- setAttribute(ATTRIBUTE_MAX_IDLE_TIME, maxIdleTime);
-
- }
-
- public synchronized void increaseFailedLogins() {
- int failedLogins = (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0);
- failedLogins++;
- setAttribute(ATTRIBUTE_FAILED_LOGINS, failedLogins);
- }
-
- public int getFailedLogins() {
- return (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0);
- }
-
- public void setLogin(FileSystemView fsview) {
- setAttribute(ATTRIBUTE_LOGIN_TIME, new Date());
- setAttribute(ATTRIBUTE_FILE_SYSTEM, fsview);
- }
-
- public void reinitialize() {
- removeAttribute(ATTRIBUTE_USER);
- removeAttribute(ATTRIBUTE_USER_ARGUMENT);
- removeAttribute(ATTRIBUTE_LOGIN_TIME);
- removeAttribute(ATTRIBUTE_FILE_SYSTEM);
- removeAttribute(ATTRIBUTE_RENAME_FROM);
+ public Listener getListener() {
+ return (Listener) getAttribute(ATTRIBUTE_LISTENER);
+ }
+
+ public void setListener(Listener listener) {
+ setAttribute(ATTRIBUTE_LISTENER, listener);
+ }
+
+ public FtpSession getFtpletSession() {
+ return new FtpSessionImpl(this);
+ }
+
+ public String getLanguage() {
+ return (String) getAttribute(ATTRIBUTE_LANGUAGE);
+ }
+
+ public void setLanguage(String language) {
+ setAttribute(ATTRIBUTE_LANGUAGE, language);
+
+ }
+
+ public String getUserArgument() {
+ return (String) getAttribute(ATTRIBUTE_USER_ARGUMENT);
+ }
+
+ public void setUser(User user) {
+ setAttribute(ATTRIBUTE_USER, user);
+
+ }
+
+ public void setUserArgument(String userArgument) {
+ setAttribute(ATTRIBUTE_USER_ARGUMENT, userArgument);
+
+ }
+
+ public int getMaxIdleTime() {
+ return (Integer) getAttribute(ATTRIBUTE_MAX_IDLE_TIME, 0);
+ }
+
+ public void setMaxIdleTime(int maxIdleTime) {
+ setAttribute(ATTRIBUTE_MAX_IDLE_TIME, maxIdleTime);
+
+ }
+
+ public synchronized void increaseFailedLogins() {
+ int failedLogins = (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0);
+ failedLogins++;
+ setAttribute(ATTRIBUTE_FAILED_LOGINS, failedLogins);
+ }
+
+ public int getFailedLogins() {
+ return (Integer) getAttribute(ATTRIBUTE_FAILED_LOGINS, 0);
+ }
+
+ public void setLogin(FileSystemView fsview) {
+ setAttribute(ATTRIBUTE_LOGIN_TIME, new Date());
+ setAttribute(ATTRIBUTE_FILE_SYSTEM, fsview);
+ }
+
+ public void reinitialize() {
+ removeAttribute(ATTRIBUTE_USER);
+ removeAttribute(ATTRIBUTE_USER_ARGUMENT);
+ removeAttribute(ATTRIBUTE_LOGIN_TIME);
+ removeAttribute(ATTRIBUTE_FILE_SYSTEM);
+ removeAttribute(ATTRIBUTE_RENAME_FROM);
removeAttribute(ATTRIBUTE_FILE_OFFSET);
- }
+ }
+
+ public void setFileOffset(long fileOffset) {
+ setAttribute(ATTRIBUTE_FILE_OFFSET, fileOffset);
+
+ }
+
+ public void setRenameFrom(FileObject renFr) {
+ setAttribute(ATTRIBUTE_RENAME_FROM, renFr);
+
+ }
+
+ public FileObject getRenameFrom() {
+ return (FileObject) getAttribute(ATTRIBUTE_RENAME_FROM);
+ }
- public void setFileOffset(long fileOffset) {
- setAttribute(ATTRIBUTE_FILE_OFFSET, fileOffset);
-
- }
-
- public void setRenameFrom(FileObject renFr) {
- setAttribute(ATTRIBUTE_RENAME_FROM, renFr);
-
- }
-
- public FileObject getRenameFrom() {
- return (FileObject) getAttribute(ATTRIBUTE_RENAME_FROM);
- }
-
- public long getFileOffset() {
- return (Long) getAttribute(ATTRIBUTE_FILE_OFFSET, 0L);
- }
-
- public void setStructure(Structure structure) {
- setAttribute(ATTRIBUTE_STRUCTURE, structure);
- }
-
- public void setDataType(DataType dataType) {
- setAttribute(ATTRIBUTE_DATA_TYPE, dataType);
-
- }
-
- public FtpIoSession(IoSession wrappedSession, FtpServerContext context) {
- this.wrappedSession = wrappedSession;
- this.context = context;
- }
-
- public Structure getStructure() {
- return (Structure) getAttribute(ATTRIBUTE_STRUCTURE, Structure.FILE);
- }
- public DataType getDataType() {
- return (DataType) getAttribute(ATTRIBUTE_DATA_TYPE, DataType.ASCII);
- }
-
- public Date getLoginTime() {
- return (Date) getAttribute(ATTRIBUTE_LOGIN_TIME);
- }
-
- public Date getLastAccessTime() {
- return (Date) getAttribute(ATTRIBUTE_LAST_ACCESS_TIME);
- }
+ public long getFileOffset() {
+ return (Long) getAttribute(ATTRIBUTE_FILE_OFFSET, 0L);
+ }
+
+ public void setStructure(Structure structure) {
+ setAttribute(ATTRIBUTE_STRUCTURE, structure);
+ }
+
+ public void setDataType(DataType dataType) {
+ setAttribute(ATTRIBUTE_DATA_TYPE, dataType);
+
+ }
+
+ public FtpIoSession(IoSession wrappedSession, FtpServerContext context) {
+ this.wrappedSession = wrappedSession;
+ this.context = context;
+ }
+
+ public Structure getStructure() {
+ return (Structure) getAttribute(ATTRIBUTE_STRUCTURE, Structure.FILE);
+ }
+
+ public DataType getDataType() {
+ return (DataType) getAttribute(ATTRIBUTE_DATA_TYPE, DataType.ASCII);
+ }
+
+ public Date getLoginTime() {
+ return (Date) getAttribute(ATTRIBUTE_LOGIN_TIME);
+ }
+
+ public Date getLastAccessTime() {
+ return (Date) getAttribute(ATTRIBUTE_LAST_ACCESS_TIME);
+ }
public Certificate[] getClientCertificates() {
- if(getFilterChain().contains(SslFilter.class)) {
- SslFilter sslFilter = (SslFilter) getFilterChain().get(SslFilter.class);
-
+ if (getFilterChain().contains(SslFilter.class)) {
+ SslFilter sslFilter = (SslFilter) getFilterChain().get(
+ SslFilter.class);
+
SSLSession sslSession = sslFilter.getSslSession(this);
-
- if(sslSession != null) {
+
+ if (sslSession != null) {
try {
return sslSession.getPeerCertificates();
- } catch(SSLPeerUnverifiedException e) {
+ } catch (SSLPeerUnverifiedException e) {
// ignore, certificate will not be available to the session
}
}
-
+
}
// no certificates available
@@ -681,51 +723,52 @@
}
- public void updateLastAccessTime() {
- setAttribute(ATTRIBUTE_LAST_ACCESS_TIME, new Date());
-
- }
-
- /**
- * @see IoSession#getCurrentWriteMessage()
- */
- public Object getCurrentWriteMessage() {
- return wrappedSession.getCurrentWriteMessage();
- }
-
- /**
- * @see IoSession#getCurrentWriteRequest()
- */
- public WriteRequest getCurrentWriteRequest() {
- return wrappedSession.getCurrentWriteRequest();
- }
-
- /**
- * @see IoSession#isBothIdle()
- */
- public boolean isBothIdle() {
- return wrappedSession.isBothIdle();
- }
-
- /**
- * @see IoSession#isReaderIdle()
- */
- public boolean isReaderIdle() {
- return wrappedSession.isReaderIdle();
- }
-
- /**
- * @see IoSession#isWriterIdle()
- */
- public boolean isWriterIdle() {
- return wrappedSession.isWriterIdle();
- }
-
- /**
- * Indicates whether the control socket for this session is secure,
- * that is, running over SSL/TLS
- * @return true if the control socket is secured
- */
+ public void updateLastAccessTime() {
+ setAttribute(ATTRIBUTE_LAST_ACCESS_TIME, new Date());
+
+ }
+
+ /**
+ * @see IoSession#getCurrentWriteMessage()
+ */
+ public Object getCurrentWriteMessage() {
+ return wrappedSession.getCurrentWriteMessage();
+ }
+
+ /**
+ * @see IoSession#getCurrentWriteRequest()
+ */
+ public WriteRequest getCurrentWriteRequest() {
+ return wrappedSession.getCurrentWriteRequest();
+ }
+
+ /**
+ * @see IoSession#isBothIdle()
+ */
+ public boolean isBothIdle() {
+ return wrappedSession.isBothIdle();
+ }
+
+ /**
+ * @see IoSession#isReaderIdle()
+ */
+ public boolean isReaderIdle() {
+ return wrappedSession.isReaderIdle();
+ }
+
+ /**
+ * @see IoSession#isWriterIdle()
+ */
+ public boolean isWriterIdle() {
+ return wrappedSession.isWriterIdle();
+ }
+
+ /**
+ * Indicates whether the control socket for this session is secure, that is,
+ * running over SSL/TLS
+ *
+ * @return true if the control socket is secured
+ */
public boolean isSecure() {
return getFilterChain().contains(SslFilter.class);
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpServerContext.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpServerContext.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpServerContext.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpServerContext.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -27,33 +27,35 @@
import org.apache.ftpserver.listener.Listener;
/**
- * This is basically <code>org.apache.ftpserver.ftplet.FtpletContext</code> with added
- * connection manager, message resource functionalities.
+ * This is basically <code>org.apache.ftpserver.ftplet.FtpletContext</code> with
+ * added connection manager, message resource functionalities.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-interface FtpServerContext extends FtpletContext {
+public interface FtpServerContext extends FtpletContext {
+
+ ConnectionConfig getConnectionConfig();
- ConnectionConfig getConnectionConfig();
-
/**
* Get message resource.
*/
MessageResource getMessageResource();
-
+
/**
* Get ftplet container.
*/
FtpletContainer getFtpletContainer();
-
+
Listener getListener(String name);
Map<String, Listener> getListeners();
-
+
/**
* Get the command factory.
*/
CommandFactory getCommandFactory();
-
+
/**
* Release all components.
*/
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/MessageResource.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/MessageResource.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/MessageResource.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/MessageResource.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -25,27 +25,29 @@
/**
* This is message resource interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-interface MessageResource {
+public interface MessageResource {
/**
* Get all the available languages.
*/
String[] getAvailableLanguages();
-
+
/**
- * Get the message for the corresponding code and sub id.
- * If not found it will return null.
+ * Get the message for the corresponding code and sub id. If not found it
+ * will return null.
*/
String getMessage(int code, String subId, String language);
-
+
/**
- * Save properties. This properties object contain all the
- * available messages. Old properties will not be overwritten.
+ * Save properties. This properties object contain all the available
+ * messages. Old properties will not be overwritten.
*/
void save(Properties prop, String language) throws FtpException;
-
+
/**
* Get all the messages.
*/
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/ServerFtpStatistics.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/ServerFtpStatistics.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/ServerFtpStatistics.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/ServerFtpStatistics.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -23,75 +23,78 @@
import org.apache.ftpserver.ftplet.FtpStatistics;
/**
- * This is same as <code>org.apache.ftpserver.ftplet.FtpStatistics</code>
- * with added observer and setting values functionalities.
+ * This is same as <code>org.apache.ftpserver.ftplet.FtpStatistics</code> with
+ * added observer and setting values functionalities.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-interface ServerFtpStatistics extends FtpStatistics {
+public interface ServerFtpStatistics extends FtpStatistics {
/**
* Set statistics observer.
*/
void setObserver(StatisticsObserver observer);
-
+
/**
* Set file observer.
*/
void setFileObserver(FileObserver observer);
-
+
/**
* Increment upload count.
*/
void setUpload(FtpIoSession session, FileObject file, long size);
-
+
/**
* Increment download count.
*/
void setDownload(FtpIoSession session, FileObject file, long size);
-
+
/**
* Increment make directory count.
*/
void setMkdir(FtpIoSession session, FileObject dir);
-
+
/**
* Decrement remove directory count.
*/
- void setRmdir(FtpIoSession session, FileObject dir) ;
-
+ void setRmdir(FtpIoSession session, FileObject dir);
+
/**
* Increment delete count.
*/
void setDelete(FtpIoSession session, FileObject file);
-
+
/**
* Increment current connection count.
*/
void setOpenConnection(FtpIoSession session);
-
+
/**
* Decrement close connection count.
*/
void setCloseConnection(FtpIoSession session);
-
+
/**
* Increment current login count.
*/
void setLogin(FtpIoSession session);
-
+
/**
* Increment failed login count.
*/
void setLoginFail(FtpIoSession session);
-
+
/**
* Decrement current login count.
*/
void setLogout(FtpIoSession session);
-
+
/**
- * Reset all cumulative total counters. Do not reset current counters, like
- * current logins, otherwise these will become negative when someone disconnects.
+ * Reset all cumulative total counters. Do not reset current counters, like
+ * current logins, otherwise these will become negative when someone
+ * disconnects.
*/
void resetStatisticsCounters();
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/SocketFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/SocketFactory.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/SocketFactory.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/SocketFactory.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -24,32 +24,33 @@
import org.apache.ftpserver.ssl.SslConfiguration;
-
/**
* This interface is responsible to create appropriate server socket.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-interface SocketFactory {
-
+public interface SocketFactory {
+
/**
- * Create the server socket.
+ * Create the server socket.
*/
ServerSocket createServerSocket() throws Exception;
-
+
/**
* Get server address.
*
* @return {@link InetAddress} obtained from host address from
- * {@link SocketFactory} configuration, or <code>null</code> if
- * not specified.
+ * {@link SocketFactory} configuration, or <code>null</code> if not
+ * specified.
*/
InetAddress getServerAddress();
-
+
/**
* Get server port.
*/
int getPort();
-
+
/**
* Get SSL component.
*/
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/StatisticsObserver.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/StatisticsObserver.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/StatisticsObserver.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/StatisticsObserver.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -23,59 +23,63 @@
/**
* Ftp statistics observer interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-interface StatisticsObserver {
-
+public interface StatisticsObserver {
+
/**
* User file upload notification.
*/
void notifyUpload();
-
+
/**
* User file download notification.
*/
void notifyDownload();
-
+
/**
* User file delete notification.
*/
void notifyDelete();
-
+
/**
* User make directory notification.
*/
void notifyMkdir();
-
+
/**
* User remove directory notification.
*/
void notifyRmdir();
-
+
/**
* New user login notification.
*/
void notifyLogin(boolean anonymous);
-
+
/**
* Failed user login notification.
- * @param address Remote address that the failure came from
+ *
+ * @param address
+ * Remote address that the failure came from
*/
void notifyLoginFail(InetAddress address);
-
+
/**
* User logout notification.
*/
void notifyLogout(boolean anonymous);
-
+
/**
* Connection open notification
*/
- void notifyOpenConnection();
-
+ void notifyOpenConnection();
+
/**
* Connection close notification
*/
void notifyCloseConnection();
-}
+}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/AbstractListener.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/AbstractListener.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/AbstractListener.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/AbstractListener.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listener;
@@ -25,18 +25,24 @@
import org.apache.ftpserver.interfaces.DataConnectionConfiguration;
import org.apache.ftpserver.ssl.SslConfiguration;
-
/**
* Common base class for listener implementations
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public abstract class AbstractListener implements Listener {
-
+
private InetAddress serverAddress;
+
private int port = 21;
+
private SslConfiguration ssl;
+
private boolean implicitSsl = false;
+
private DataConnectionConfiguration dataConnectionConfig = new DefaultDataConnectionConfiguration();
-
+
/**
* {@inheritDoc}
*/
@@ -64,14 +70,14 @@
public void setPort(int port) {
this.port = port;
}
-
+
/**
* {@inheritDoc}
*/
public InetAddress getServerAddress() {
return serverAddress;
}
-
+
/**
* {@inheritDoc}
*/
@@ -85,7 +91,7 @@
public SslConfiguration getSslConfiguration() {
return ssl;
}
-
+
/**
* {@inheritDoc}
*/
@@ -99,11 +105,12 @@
public DataConnectionConfiguration getDataConnectionConfiguration() {
return dataConnectionConfig;
}
-
+
/**
* {@inheritDoc}
*/
- public void setDataConnectionConfiguration(DataConnectionConfiguration dataConnectionConfig) {
+ public void setDataConnectionConfiguration(
+ DataConnectionConfiguration dataConnectionConfig) {
this.dataConnectionConfig = dataConnectionConfig;
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/Listener.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/Listener.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/Listener.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/Listener.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listener;
@@ -27,28 +27,29 @@
import org.apache.ftpserver.interfaces.FtpServerContext;
import org.apache.ftpserver.ssl.SslConfiguration;
-
/**
- * Interface for the component responsible for waiting for incoming
- * socket requests and kicking off {@link FtpIoSession}s
+ * Interface for the component responsible for waiting for incoming socket
+ * requests and kicking off {@link FtpIoSession}s
*
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface Listener {
-
+
/**
- * Start the listener, will initiate the listener waiting
- * on the socket.
- * The method should not return until the listener has
- * started accepting socket requests.
+ * Start the listener, will initiate the listener waiting on the socket. The
+ * method should not return until the listener has started accepting socket
+ * requests.
*
- * @throws Exception On error during start up
+ * @throws Exception
+ * On error during start up
*/
void start(FtpServerContext serverContext) throws Exception;
/**
- * Stop the listener, it should no longer except socket requests.
- * The method should not return until the listener has stopped
- * accepting socket requests.
+ * Stop the listener, it should no longer except socket requests. The method
+ * should not return until the listener has stopped accepting socket
+ * requests.
*/
void stop();
@@ -60,77 +61,89 @@
boolean isStopped();
/**
- * Temporarily stops the listener from accepting socket requests.
- * Resume the listener by using the {@link #resume()} method.
- * The method should not return until the listener has stopped
- * accepting socket requests.
+ * Temporarily stops the listener from accepting socket requests. Resume the
+ * listener by using the {@link #resume()} method. The method should not
+ * return until the listener has stopped accepting socket requests.
*/
void suspend();
/**
- * Resumes a suspended listener.
- * The method should not return until the listener has
- * started accepting socket requests.
+ * Resumes a suspended listener. The method should not return until the
+ * listener has started accepting socket requests.
*/
void resume();
/**
* Checks if the listener is currently suspended
+ *
* @return True if the listener is suspended
*/
boolean isSuspended();
-
+
/**
- * Returns the currently active sessions for this listener.
- * If no sessions are active, an empty {@link Set} would be returned.
+ * Returns the currently active sessions for this listener. If no sessions
+ * are active, an empty {@link Set} would be returned.
+ *
* @return The currently active sessions
*/
Set<FtpIoSession> getActiveSessions();
/**
- * Is this listener in SSL mode automatically or must
- * the client explicitly request to use SSL
- * @return true is the listener is automatically in SSL mode, false otherwise
+ * Is this listener in SSL mode automatically or must the client explicitly
+ * request to use SSL
+ *
+ * @return true is the listener is automatically in SSL mode, false
+ * otherwise
*/
boolean isImplicitSsl();
/**
- * Should this listener be in SSL mode automatically or must
- * the client explicitly request to use SSL
- * @param implicitSsl true is the listener should automatically be in SSL mode, false otherwise
+ * Should this listener be in SSL mode automatically or must the client
+ * explicitly request to use SSL
+ *
+ * @param implicitSsl
+ * true is the listener should automatically be in SSL mode,
+ * false otherwise
*/
void setImplicitSsl(boolean implicitSsl);
/**
* Get the {@link SslConfiguration} used for this listener
+ *
* @return The current {@link SslConfiguration}
*/
SslConfiguration getSslConfiguration();
-
+
/**
* Set the {@link SslConfiguration} used for this listener
- * @param sslConfiguration The {@link SslConfiguration}
+ *
+ * @param sslConfiguration
+ * The {@link SslConfiguration}
*/
void setSslConfiguration(SslConfiguration sslConfiguration);
-
+
/**
- * Get the port on which this listener is waiting for requests.
- * For listeners where the port is automatically assigned, this
- * will return the bound port.
+ * Get the port on which this listener is waiting for requests. For
+ * listeners where the port is automatically assigned, this will return the
+ * bound port.
+ *
* @return The port
*/
int getPort();
/**
- * Set the port on which this listener will accept requests. Or set to
- * 0 (zero) is the port should be automatically assigned
- * @param port The port to use.
+ * Set the port on which this listener will accept requests. Or set to 0
+ * (zero) is the port should be automatically assigned
+ *
+ * @param port
+ * The port to use.
*/
void setPort(int port);
/**
* Get the {@link InetAddress} used for binding the local socket. Defaults
* to null, that is, the server binds to all available network interfaces
+ *
* @return The local socket {@link InetAddress}, if set
*/
InetAddress getServerAddress();
@@ -138,19 +151,25 @@
/**
* Set the {@link InetAddress} used for binding the local socket. Defaults
* to null, that is, the server binds to all available network interfaces
- * @param serverAddress The local socket {@link InetAddress}
+ *
+ * @param serverAddress
+ * The local socket {@link InetAddress}
*/
void setServerAddress(InetAddress serverAddress);
/**
* Get configuration for data connections made within this listener
+ *
* @return The data connection configuration
*/
DataConnectionConfiguration getDataConnectionConfiguration();
/**
* Set configuration for data connections made within this listener
- * @param dataConnectionConfig The data connection configuration
+ *
+ * @param dataConnectionConfig
+ * The data connection configuration
*/
- void setDataConnectionConfiguration(DataConnectionConfiguration dataConnectionConfig);
+ void setDataConnectionConfiguration(
+ DataConnectionConfiguration dataConnectionConfig);
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpHandlerAdapter.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpHandlerAdapter.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpHandlerAdapter.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpHandlerAdapter.java Sun Aug 17 12:52:42 2008
@@ -29,65 +29,70 @@
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
-public class FtpHandlerAdapter implements IoHandler
-{
- private FtpServerContext context;
- private FtpHandler ftpHandler;
-
- public FtpHandlerAdapter(FtpServerContext context,
- FtpHandler ftpHandler) {
- this.context = context;
- this.ftpHandler = ftpHandler;
- }
-
- public void exceptionCaught(IoSession session, Throwable cause)
- throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.exceptionCaught(ftpSession, cause);
- }
-
- public void messageReceived(IoSession session, Object message)
- throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- FtpRequest request = new FtpRequestImpl(message.toString());
-
- ftpHandler.messageReceived(ftpSession, request);
- }
-
- public void messageSent(IoSession session, Object message) throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.messageSent(ftpSession, (FtpReply)message);
- }
-
- public void sessionClosed(IoSession session) throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.sessionClosed(ftpSession);
- }
-
- public void sessionCreated(IoSession session) throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.sessionCreated(ftpSession);
- }
-
- public void sessionIdle(IoSession session, IdleStatus status)
- throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.sessionIdle(ftpSession, status);
- }
-
- public void sessionOpened(IoSession session) throws Exception {
- FtpIoSession ftpSession = new FtpIoSession(session, context);
- ftpHandler.sessionOpened(ftpSession);
- }
-
- public FtpHandler getFtpHandler() {
- return ftpHandler;
- }
-
- public void setFtpHandler(FtpHandler handler) {
- this.ftpHandler = handler;
-
- }
-
+/**
+ *
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
+public class FtpHandlerAdapter implements IoHandler {
+ private FtpServerContext context;
+
+ private FtpHandler ftpHandler;
+
+ public FtpHandlerAdapter(FtpServerContext context, FtpHandler ftpHandler) {
+ this.context = context;
+ this.ftpHandler = ftpHandler;
+ }
+
+ public void exceptionCaught(IoSession session, Throwable cause)
+ throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.exceptionCaught(ftpSession, cause);
+ }
+
+ public void messageReceived(IoSession session, Object message)
+ throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ FtpRequest request = new FtpRequestImpl(message.toString());
+
+ ftpHandler.messageReceived(ftpSession, request);
+ }
+
+ public void messageSent(IoSession session, Object message) throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.messageSent(ftpSession, (FtpReply) message);
+ }
+
+ public void sessionClosed(IoSession session) throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.sessionClosed(ftpSession);
+ }
+
+ public void sessionCreated(IoSession session) throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.sessionCreated(ftpSession);
+ }
+
+ public void sessionIdle(IoSession session, IdleStatus status)
+ throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.sessionIdle(ftpSession, status);
+ }
+
+ public void sessionOpened(IoSession session) throws Exception {
+ FtpIoSession ftpSession = new FtpIoSession(session, context);
+ ftpHandler.sessionOpened(ftpSession);
+ }
+
+ public FtpHandler getFtpHandler() {
+ return ftpHandler;
+ }
+
+ public void setFtpHandler(FtpHandler handler) {
+ this.ftpHandler = handler;
+
+ }
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java Sun Aug 17 12:52:42 2008
@@ -31,20 +31,22 @@
/**
* A {@link MessageEncoder} that encodes {@link FtpReply}.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public class FtpResponseEncoder extends ProtocolEncoderAdapter
-{
- private static final CharsetEncoder ENCODER = Charset.forName("UTF-8").newEncoder();
+public class FtpResponseEncoder extends ProtocolEncoderAdapter {
+ private static final CharsetEncoder ENCODER = Charset.forName("UTF-8")
+ .newEncoder();
- public void encode( IoSession session, Object message,
- ProtocolEncoderOutput out ) throws Exception
- {
+ public void encode(IoSession session, Object message,
+ ProtocolEncoderOutput out) throws Exception {
String value = message.toString();
-
- IoBuffer buf = IoBuffer.allocate( value.length() ).setAutoExpand( true );
- buf.putString( value, ENCODER );
-
+ IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
+
+ buf.putString(value, ENCODER);
+
buf.flip();
out.write(buf);
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpServerProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpServerProtocolCodecFactory.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpServerProtocolCodecFactory.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/FtpServerProtocolCodecFactory.java Sun Aug 17 12:52:42 2008
@@ -29,17 +29,21 @@
/**
* Factory for creating decoders and encoders
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public class FtpServerProtocolCodecFactory implements ProtocolCodecFactory
-{
- private ProtocolDecoder decoder = new TextLineDecoder(Charset.forName("UTF-8"));
+public class FtpServerProtocolCodecFactory implements ProtocolCodecFactory {
+ private ProtocolDecoder decoder = new TextLineDecoder(Charset
+ .forName("UTF-8"));
+
private ProtocolEncoder encoder = new FtpResponseEncoder();
- public ProtocolDecoder getDecoder(IoSession session) throws Exception {
- return decoder;
- }
+ public ProtocolDecoder getDecoder(IoSession session) throws Exception {
+ return decoder;
+ }
- public ProtocolEncoder getEncoder(IoSession session) throws Exception {
+ public ProtocolEncoder getEncoder(IoSession session) throws Exception {
return encoder;
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listener.nio;
@@ -57,116 +57,118 @@
/**
* The default {@link Listener} implementation.
*
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class NioListener extends AbstractListener {
private final Logger LOG = LoggerFactory.getLogger(NioListener.class);
private SocketAcceptor acceptor;
-
+
private InetSocketAddress address;
-
+
boolean suspended = false;
-
+
private ExecutorService filterExecutor = new OrderedThreadPoolExecutor();
- private FtpHandler handler = new DefaultFtpHandler();
-
- private int idleTimeout = 300;
-
- private List<InetAddress> blockedAddresses;
- private List<Subnet> blockedSubnets;
+ private FtpHandler handler = new DefaultFtpHandler();
+
+ private int idleTimeout = 300;
+
+ private List<InetAddress> blockedAddresses;
+
+ private List<Subnet> blockedSubnets;
private FtpServerContext context;
+ public int getIdleTimeout() {
+ return idleTimeout;
+ }
+
+ public void setIdleTimeout(int idleTimeout) {
+ this.idleTimeout = idleTimeout;
+ }
+
+ private void updateBlacklistFilter() {
+ if (acceptor != null) {
+ BlacklistFilter filter = (BlacklistFilter) acceptor
+ .getFilterChain().get("ipFilter");
- public int getIdleTimeout() {
- return idleTimeout;
- }
-
- public void setIdleTimeout(int idleTimeout) {
- this.idleTimeout = idleTimeout;
- }
-
- private void updateBlacklistFilter() {
- if(acceptor != null) {
- BlacklistFilter filter = (BlacklistFilter) acceptor.getFilterChain().get("ipFilter");
-
- if(filter != null) {
- if(blockedAddresses != null) {
- filter.setBlacklist(blockedAddresses);
- } else if(blockedSubnets != null) {
- filter.setSubnetBlacklist(blockedSubnets);
- } else {
- // an empty list clears the blocked addresses
+ if (filter != null) {
+ if (blockedAddresses != null) {
+ filter.setBlacklist(blockedAddresses);
+ } else if (blockedSubnets != null) {
+ filter.setSubnetBlacklist(blockedSubnets);
+ } else {
+ // an empty list clears the blocked addresses
filter.setSubnetBlacklist(new ArrayList<Subnet>());
- }
-
- }
- }
- }
-
- /**
+ }
+
+ }
+ }
+ }
+
+ /**
* @see Listener#start(FtpServerContext)
*/
public void start(FtpServerContext context) throws Exception {
this.context = context;
-
-
- acceptor = new NioSocketAcceptor(Runtime.getRuntime().availableProcessors());
-
- if(getServerAddress() != null) {
- address = new InetSocketAddress(getServerAddress(), getPort() );
+
+ acceptor = new NioSocketAcceptor(Runtime.getRuntime()
+ .availableProcessors());
+
+ if (getServerAddress() != null) {
+ address = new InetSocketAddress(getServerAddress(), getPort());
} else {
- address = new InetSocketAddress( getPort() );
+ address = new InetSocketAddress(getPort());
}
-
+
acceptor.setReuseAddress(true);
- acceptor.getSessionConfig().setReadBufferSize( 2048 );
- acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, idleTimeout );
+ acceptor.getSessionConfig().setReadBufferSize(2048);
+ acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,
+ idleTimeout);
// Decrease the default receiver buffer size
- ((SocketSessionConfig) acceptor.getSessionConfig()).setReceiveBufferSize(512);
+ ((SocketSessionConfig) acceptor.getSessionConfig())
+ .setReceiveBufferSize(512);
MdcInjectionFilter mdcFilter = new MdcInjectionFilter();
acceptor.getFilterChain().addLast("mdcFilter", mdcFilter);
-
+
// add and update the blacklist filter
acceptor.getFilterChain().addLast("ipFilter", new BlacklistFilter());
updateBlacklistFilter();
-
- acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(filterExecutor));
- acceptor.getFilterChain().addLast(
- "codec",
- new ProtocolCodecFilter( new FtpServerProtocolCodecFactory() ) );
+
+ acceptor.getFilterChain().addLast("threadPool",
+ new ExecutorFilter(filterExecutor));
+ acceptor.getFilterChain().addLast("codec",
+ new ProtocolCodecFilter(new FtpServerProtocolCodecFactory()));
acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
- acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter() );
-
+ acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter());
-
- if(isImplicitSsl()) {
+ if (isImplicitSsl()) {
SslConfiguration ssl = getSslConfiguration();
- SslFilter sslFilter = new SslFilter( ssl.getSSLContext() );
-
- if(ssl.getClientAuth() == ClientAuth.NEED) {
+ SslFilter sslFilter = new SslFilter(ssl.getSSLContext());
+
+ if (ssl.getClientAuth() == ClientAuth.NEED) {
sslFilter.setNeedClientAuth(true);
- } else if(ssl.getClientAuth() == ClientAuth.WANT) {
+ } else if (ssl.getClientAuth() == ClientAuth.WANT) {
sslFilter.setWantClientAuth(true);
}
- if(ssl.getEnabledCipherSuites() != null) {
+ if (ssl.getEnabledCipherSuites() != null) {
sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
}
-
+
acceptor.getFilterChain().addFirst("sslFilter", sslFilter);
}
-
- handler.init(context, this);
+ handler.init(context, this);
acceptor.setHandler(new FtpHandlerAdapter(context, handler));
-
+
acceptor.bind(address);
-
+
// update the port to the real port bound by the listener
setPort(acceptor.getLocalAddress().getPort());
}
@@ -181,14 +183,14 @@
acceptor.dispose();
acceptor = null;
}
-
- if(filterExecutor != null) {
+
+ if (filterExecutor != null) {
filterExecutor.shutdown();
try {
filterExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
} finally {
-// TODO: how to handle?
+ // TODO: how to handle?
}
}
}
@@ -205,14 +207,14 @@
*/
public boolean isSuspended() {
return suspended;
-
+
}
/**
* @see Listener#resume()
*/
public void resume() {
- if(acceptor != null && suspended) {
+ if (acceptor != null && suspended) {
try {
acceptor.bind(address);
} catch (IOException e) {
@@ -225,7 +227,7 @@
* @see Listener#suspend()
*/
public void suspend() {
- if(acceptor != null && !suspended) {
+ if (acceptor != null && !suspended) {
acceptor.unbind(address);
}
}
@@ -233,6 +235,7 @@
/**
* Get the {@link ExecutorService} used for processing requests. The default
* value is a cached thread pool.
+ *
* @return The {@link ExecutorService}
*/
public ExecutorService getFilterExecutor() {
@@ -241,44 +244,52 @@
/**
* Set the {@link ExecutorService} used for processing requests
- * @param filterExecutor The {@link ExecutorService}
+ *
+ * @param filterExecutor
+ * The {@link ExecutorService}
*/
public void setFilterExecutor(ExecutorService filterExecutor) {
this.filterExecutor = filterExecutor;
}
-
public FtpHandler getHandler() {
- return handler;
- }
+ return handler;
+ }
+
+ public void setHandler(FtpHandler handler) {
+ this.handler = handler;
- public void setHandler(FtpHandler handler) {
- this.handler = handler;
-
- if(acceptor != null) {
- ((FtpHandlerAdapter)acceptor.getHandler()).setFtpHandler(handler);
- }
- }
-
- /**
- * Retrives the {@link InetAddress} for which this listener blocks connections
- * @return The list of {@link InetAddress}es
- */
+ if (acceptor != null) {
+ ((FtpHandlerAdapter) acceptor.getHandler()).setFtpHandler(handler);
+ }
+ }
+
+ /**
+ * Retrives the {@link InetAddress} for which this listener blocks
+ * connections
+ *
+ * @return The list of {@link InetAddress}es
+ */
public synchronized List<InetAddress> getBlockedAddresses() {
return blockedAddresses;
}
/**
- * Sets the {@link InetAddress} that this listener will block from connecting
- * @param blockedAddresses The list of {@link InetAddress}es
+ * Sets the {@link InetAddress} that this listener will block from
+ * connecting
+ *
+ * @param blockedAddresses
+ * The list of {@link InetAddress}es
*/
- public synchronized void setBlockedAddresses(List<InetAddress> blockedAddresses) {
+ public synchronized void setBlockedAddresses(
+ List<InetAddress> blockedAddresses) {
this.blockedAddresses = blockedAddresses;
updateBlacklistFilter();
}
/**
* Retrives the {@link Subnet}s for which this acceptor blocks connections
+ *
* @return The list of {@link Subnet}s
*/
public synchronized List<Subnet> getBlockedSubnets() {
@@ -287,7 +298,9 @@
/**
* Sets the {@link Subnet}s that this listener will block from connecting
- * @param blockedAddresses The list of {@link Subnet}s
+ *
+ * @param blockedAddresses
+ * The list of {@link Subnet}s
*/
public synchronized void setBlockedSubnets(List<Subnet> blockedSubnets) {
this.blockedSubnets = blockedSubnets;
@@ -298,10 +311,10 @@
* @see Listener#getActiveSessions()
*/
public Set<FtpIoSession> getActiveSessions() {
- Map<Long,IoSession> sessions = acceptor.getManagedSessions();
-
+ Map<Long, IoSession> sessions = acceptor.getManagedSessions();
+
Set<FtpIoSession> ftpSessions = new HashSet<FtpIoSession>();
- for(IoSession session : sessions.values()) {
+ for (IoSession session : sessions.values()) {
ftpSessions.add(new FtpIoSession(session, context));
}
return ftpSessions;
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/DirectoryLister.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/DirectoryLister.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/DirectoryLister.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/DirectoryLister.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -27,73 +27,78 @@
/**
* This class prints file listing.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class DirectoryLister {
+public class DirectoryLister {
-
- private String traverseFiles(final FileObject[] files, final FileFilter filter, final FileFormater formater) {
- StringBuffer sb = new StringBuffer();
-
- sb.append(traverseFiles(files, filter, formater, true));
- sb.append(traverseFiles(files, filter, formater, false));
-
- return sb.toString();
- }
- private String traverseFiles(final FileObject[] files, final FileFilter filter, final FileFormater formater, boolean matchDirs) {
+ private String traverseFiles(final FileObject[] files,
+ final FileFilter filter, final FileFormater formater) {
StringBuffer sb = new StringBuffer();
- for(int i=0; i<files.length; i++) {
- if(files[i] == null) {
+
+ sb.append(traverseFiles(files, filter, formater, true));
+ sb.append(traverseFiles(files, filter, formater, false));
+
+ return sb.toString();
+ }
+
+ private String traverseFiles(final FileObject[] files,
+ final FileFilter filter, final FileFormater formater,
+ boolean matchDirs) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i] == null) {
continue;
}
-
- if(filter == null || filter.accept(files[i])) {
- if(files[i].isDirectory() == matchDirs) {
- sb.append(formater.format(files[i]));
- }
+
+ if (filter == null || filter.accept(files[i])) {
+ if (files[i].isDirectory() == matchDirs) {
+ sb.append(formater.format(files[i]));
+ }
}
- }
-
+ }
+
return sb.toString();
}
-
- public String listFiles(final ListArgument argument, final FileSystemView fileSystemView, final FileFormater formater) throws IOException {
-
+
+ public String listFiles(final ListArgument argument,
+ final FileSystemView fileSystemView, final FileFormater formater)
+ throws IOException {
+
StringBuffer sb = new StringBuffer();
-
+
// get all the file objects
FileObject[] files = listFiles(fileSystemView, argument.getFile());
- if(files != null) {
+ if (files != null) {
FileFilter filter = null;
- if ( (argument.hasOption('a'))) {
+ if ((argument.hasOption('a'))) {
filter = new VisibleFileFilter();
}
- if(argument.getPattern() != null) {
+ if (argument.getPattern() != null) {
filter = new RegexFileFilter(argument.getPattern(), filter);
}
-
+
sb.append(traverseFiles(files, filter, formater));
}
-
+
return sb.toString();
}
-
+
/**
* Get the file list. Files will be listed in alphabetlical order.
*/
private FileObject[] listFiles(FileSystemView fileSystemView, String file) {
- FileObject[] files = null;
- try {
- FileObject virtualFile = fileSystemView.getFileObject(file);
- if(virtualFile.isFile()) {
- files = new FileObject[] {virtualFile};
- }
- else {
- files = virtualFile.listFiles();
- }
- }
- catch(FtpException ex) {
- }
- return files;
+ FileObject[] files = null;
+ try {
+ FileObject virtualFile = fileSystemView.getFileObject(file);
+ if (virtualFile.isFile()) {
+ files = new FileObject[] { virtualFile };
+ } else {
+ files = virtualFile.listFiles();
+ }
+ } catch (FtpException ex) {
+ }
+ return files;
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFilter.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFilter.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFilter.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFilter.java Sun Aug 17 12:52:42 2008
@@ -15,20 +15,26 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
import org.apache.ftpserver.ftplet.FileObject;
/**
* Interface for selecting files based on some critera.
+ *
* @see java.io.FileFilter
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface FileFilter {
/**
* Decide if the {@link FileObject} should be selected
- * @param file The {@link FileObject}
+ *
+ * @param file
+ * The {@link FileObject}
* @return true if the {@link FileObject} was selected
*/
boolean accept(FileObject file);
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFormater.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFormater.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFormater.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/FileFormater.java Sun Aug 17 12:52:42 2008
@@ -15,19 +15,24 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
import org.apache.ftpserver.ftplet.FileObject;
/**
* Interface for formating output based on a {@link FileObject}
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface FileFormater {
/**
* Format the file
- * @param file The {@link FileObject}
+ *
+ * @param file
+ * The {@link FileObject}
* @return The formated string based on the {@link FileObject}
*/
String format(FileObject file);
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/LISTFileFormater.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/LISTFileFormater.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/LISTFileFormater.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/LISTFileFormater.java Sun Aug 17 12:52:42 2008
@@ -25,12 +25,16 @@
/**
* Formats files according to the LIST specification
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class LISTFileFormater implements FileFormater {
private final static char DELIM = ' ';
- private final static char[] NEWLINE = {'\r', '\n'};
-
+
+ private final static char[] NEWLINE = { '\r', '\n' };
+
/**
* @see FileFormater#format(FileObject)
*/
@@ -55,51 +59,49 @@
return sb.toString();
}
-
+
/**
* Get size
*/
private String getLength(FileObject file) {
String initStr = " ";
long sz = 0;
- if(file.isFile()) {
+ if (file.isFile()) {
sz = file.getSize();
}
String szStr = String.valueOf(sz);
- if(szStr.length() > initStr.length()) {
+ if (szStr.length() > initStr.length()) {
return szStr;
}
return initStr.substring(0, initStr.length() - szStr.length()) + szStr;
}
-
+
/**
* Get last modified date string.
*/
private String getLastModified(FileObject file) {
- return DateUtils.getUnixDate( file.getLastModified() );
+ return DateUtils.getUnixDate(file.getLastModified());
}
-
+
/**
* Get permission string.
*/
private char[] getPermission(FileObject file) {
char permission[] = new char[10];
Arrays.fill(permission, '-');
-
+
permission[0] = file.isDirectory() ? 'd' : '-';
permission[1] = file.hasReadPermission() ? 'r' : '-';
permission[2] = file.hasWritePermission() ? 'w' : '-';
return permission;
}
- /*public String format(FileObject[] files) {
- StringBuffer sb = new StringBuffer();
-
- for (int i = 0; i < files.length; i++) {
- sb.append(format(files[i]));
- sb.append(NEWLINE);
- }
- return sb.toString();
- }*/
+ /*
+ * public String format(FileObject[] files) { StringBuffer sb = new
+ * StringBuffer();
+ *
+ * for (int i = 0; i < files.length; i++) { sb.append(format(files[i]));
+ * sb.append(NEWLINE); } return sb.toString(); }
+ */
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java Sun Aug 17 12:52:42 2008
@@ -15,72 +15,83 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
/**
* Contains the parsed argument for a list command (e.g. LIST or NLST)
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class ListArgument {
private String file;
+
private String pattern;
+
private char[] options;
-
+
/**
- * @param file The file path including the directory
- * @param pattern A regular expression pattern that files must match
- * @param options List options, such as -la
+ * @param file
+ * The file path including the directory
+ * @param pattern
+ * A regular expression pattern that files must match
+ * @param options
+ * List options, such as -la
*/
public ListArgument(String file, String pattern, char[] options) {
this.file = file;
this.pattern = pattern;
- if(options == null) {
+ if (options == null) {
this.options = new char[0];
} else {
this.options = options.clone();
}
}
-
+
/**
- * The listing options,
+ * The listing options,
+ *
* @return All options
*/
public char[] getOptions() {
return options.clone();
}
-
+
/**
* The regular expression pattern that files must match
+ *
* @return The regular expression
*/
public String getPattern() {
return pattern;
}
-
+
/**
* Checks if a certain option is set
- * @param option The option to check
+ *
+ * @param option
+ * The option to check
* @return true if the option is set
*/
public boolean hasOption(char option) {
for (int i = 0; i < options.length; i++) {
- if(option == options[i]) {
+ if (option == options[i]) {
return true;
}
}
-
+
return false;
}
/**
* The file path including the directory
+ *
* @return The file path
*/
public String getFile() {
return file;
}
-
-
}