ftpiosession.java
来自「JAVA FTP 上传下载 的源文件」· Java 代码 · 共 852 行 · 第 1/2 页
JAVA
852 行
*/ 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#suspendRead() */ public void suspendRead() { wrappedSession.suspendRead(); } /** * @see IoSession#suspendWrite() */ public void suspendWrite() { wrappedSession.suspendWrite(); } /** * @see IoSession#write(Object) */ public WriteFuture write(Object message) { WriteFuture future = wrappedSession.write(message); this.lastReply = (FtpReply) message; return future; } /** * @see IoSession#write(Object, SocketAddress) */ public WriteFuture write(Object message, SocketAddress destination) { WriteFuture future = wrappedSession.write(message, destination); this.lastReply = (FtpReply) message; return future; } /* 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 */ public boolean isLoggedIn() { 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 DefaultFtpSession(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); int listenerTimeout = getListener().getIdleTimeout(); // the listener timeout should be the upper limit, unless set to unlimited if(listenerTimeout <= 0 || maxIdleTime < listenerTimeout) { wrappedSession.getConfig().setBothIdleTime(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(FtpFile renFr) { setAttribute(ATTRIBUTE_RENAME_FROM, renFr); } public FtpFile getRenameFrom() { return (FtpFile) 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); } /** * @see FtpSession#getSessionId() */ public UUID getSessionId() { synchronized (wrappedSession) { if(!wrappedSession.containsAttribute(ATTRIBUTE_SESSION_ID)) { wrappedSession.setAttribute(ATTRIBUTE_SESSION_ID, UUID.randomUUID()); } return (UUID) wrappedSession.getAttribute(ATTRIBUTE_SESSION_ID); } } 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); SSLSession sslSession = sslFilter.getSslSession(this); if (sslSession != null) { try { return sslSession.getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { // ignore, certificate will not be available to the session } } } // no certificates available return null; } 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); } /** * Increase the number of bytes written on the data connection * @param increment The number of bytes written */ public void increaseWrittenDataBytes(int increment) { if (wrappedSession instanceof AbstractIoSession) { ((AbstractIoSession) wrappedSession) .increaseScheduledWriteBytes(increment); ((AbstractIoSession) wrappedSession).increaseWrittenBytes( increment, System.currentTimeMillis()); } } /** * Increase the number of bytes read on the data connection * @param increment The number of bytes written */ public void increaseReadDataBytes(int increment) { if (wrappedSession instanceof AbstractIoSession) { ((AbstractIoSession) wrappedSession).increaseReadBytes(increment, System.currentTimeMillis()); } } /** * Returns the last reply that was sent to the client. * @return the last reply that was sent to the client. */ public FtpReply getLastReply() { return lastReply; } /** * @see IoSession#getWriteRequestQueue() */ public WriteRequestQueue getWriteRequestQueue() { return wrappedSession.getWriteRequestQueue(); } /** * @see IoSession#isReadSuspended() */ public boolean isReadSuspended() { return wrappedSession.isReadSuspended(); } /** * @see IoSession#isWriteSuspended() */ public boolean isWriteSuspended() { return wrappedSession.isWriteSuspended(); } /** * @see IoSession#setCurrentWriteRequest(WriteRequest) */ public void setCurrentWriteRequest(WriteRequest currentWriteRequest) { wrappedSession.setCurrentWriteRequest(currentWriteRequest); } /** * @see IoSession#updateThroughput(long, boolean) */ public void updateThroughput(long currentTime, boolean force) { wrappedSession.updateThroughput(currentTime, force); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?