FTP Session.
Inheritance: LumiSoft.Net.SocketServerSession
Exemplo n.º 1
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Reference to pop3 session.</param>
 /// <param name="userName">Username.</param>
 /// <param name="passwData">Password data.</param>
 /// <param name="data">Authentication specific data(as tag).</param>
 /// <param name="authType">Authentication type.</param>
 public AuthUser_EventArgs(FTP_Session session,string userName,string passwData,string data,AuthType authType)
 {
     m_pSession  = session;
     m_UserName  = userName;
     m_PasswData = passwData;
     m_Data      = data;
     m_AuthType  = authType;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Reference to pop3 session.</param>
 /// <param name="userName">Username.</param>
 /// <param name="passwData">Password data.</param>
 /// <param name="data">Authentication specific data(as tag).</param>
 /// <param name="authType">Authentication type.</param>
 public AuthUser_EventArgs(FTP_Session session, string userName, string passwData, string data, AuthType authType)
 {
     m_pSession  = session;
     m_UserName  = userName;
     m_PasswData = passwData;
     m_Data      = data;
     m_AuthType  = authType;
 }
Exemplo n.º 3
0
        internal FileSysEntry_EventArgs OnGetDirInfo(FTP_Session session, string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, dir, "");

            if (this.GetDirInfo != null)
            {
                this.GetDirInfo(this, oArg);
            }
            return(oArg);
        }
Exemplo n.º 4
0
        internal bool OnDeleteFile(FTP_Session session, string file)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.DeleteFile != null)
            {
                this.DeleteFile(this, oArg);
            }

            return(oArg.Validated);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Authenticates user.
        /// </summary>
        /// <param name="session">Reference to current pop3 session.</param>
        /// <param name="userName">User name.</param>
        /// <param name="passwData"></param>
        /// <param name="data"></param>
        /// <param name="authType"></param>
        /// <returns></returns>
        internal virtual bool OnAuthUser(FTP_Session session, string userName, string passwData, string data, AuthType authType)
        {
            AuthUser_EventArgs oArg = new AuthUser_EventArgs(session, userName, passwData, data, authType);

            if (this.AuthUser != null)
            {
                this.AuthUser(this, oArg);
            }

            return(oArg.Validated);
        }
Exemplo n.º 6
0
        internal bool OnDeleteDir(FTP_Session session, string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, dir, "");

            if (this.DeleteDir != null)
            {
                this.DeleteDir(this, oArg);
            }

            return(oArg.Validated);
        }
Exemplo n.º 7
0
        internal bool OnRenameDirFile(FTP_Session session, string from, string to)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, from, to);

            if (this.RenameDirFile != null)
            {
                this.RenameDirFile(this, oArg);
            }

            return(oArg.Validated);
        }
Exemplo n.º 8
0
        internal Stream OnStoreFile(FTP_Session session, string file)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.StoreFile != null)
            {
                this.StoreFile(this, oArg);
            }

            return(oArg.FileStream);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initialize and start new session here. Session isn't added to session list automatically,
        /// session must add itself to server session list by calling AddSession().
        /// </summary>
        /// <param name="socket">Connected client socket.</param>
        /// <param name="bindInfo">BindInfo what accepted socket.</param>
        protected override void InitNewSession(Socket socket, IPBindInfo bindInfo)
        {
            string   sessionID = Guid.NewGuid().ToString();
            SocketEx socketEx  = new SocketEx(socket);

            if (LogCommands)
            {
                socketEx.Logger           = new SocketLogger(socket, this.SessionLog);
                socketEx.Logger.SessionID = sessionID;
            }
            FTP_Session session = new FTP_Session(sessionID, socketEx, bindInfo, this);
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="newName"></param>
        /// <param name="session"></param>
        public FileSysEntry_EventArgs(FTP_Session session,string name,string newName)
        {
            m_Name    = name;
            m_NewName = newName;

            m_DsDirInfo  = new DataSet();
            DataTable dt = m_DsDirInfo.Tables.Add("DirInfo");
            dt.Columns.Add("Name");
            dt.Columns.Add("Date",typeof(DateTime));
            dt.Columns.Add("Size",typeof(long));
            dt.Columns.Add("IsDirectory",typeof(bool));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="newName"></param>
        /// <param name="session"></param>
        public FileSysEntry_EventArgs(FTP_Session session, string name, string newName)
        {
            m_Name    = name;
            m_NewName = newName;

            m_DsDirInfo = new DataSet();
            DataTable dt = m_DsDirInfo.Tables.Add("DirInfo");

            dt.Columns.Add("Name");
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Size", typeof(long));
            dt.Columns.Add("IsDirectory", typeof(bool));
        }
Exemplo n.º 12
0
            /// <summary>
            /// Default constructor.
            /// </summary>
            /// <param name="session">Owner FTP session.</param>
            /// <param name="stream">Data connection data stream.</param>
            /// <param name="read_write">Specifies if data read from remote endpoint or written to it.</param>
            /// <exception cref="ArgumentNullException">Is raised when <b>session</b> or <b>stream</b> is null reference.</exception>
            public DataConnection(FTP_Session session,Stream stream,bool read_write)
            {
                if(session == null){
                    throw new ArgumentNullException("session");
                }
                if(stream == null){
                    throw new ArgumentNullException("stream");
                }

                m_pSession   = session;
                m_pStream    = stream;
                m_Read_Write = read_write;
            }
Exemplo n.º 13
0
        internal bool OnFileExists(FTP_Session session, string file)
        {
            // Remove last /
            file = file.Substring(0, file.Length - 1);

            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.FileExists != null)
            {
                this.FileExists(this, oArg);
            }

            return(oArg.Validated);
        }
Exemplo n.º 14
0
            /// <summary>
            /// Cleans up any resources being used.
            /// </summary>
            public void Dispose()
            {
                if(m_IsDisposed){
                    return;
                }
                m_IsDisposed = true;

                // Reset session PASV cached data.
                if(m_pSession.m_pPassiveSocket != null){
                    m_pSession.m_pPassiveSocket.Close();
                    m_pSession.m_pPassiveSocket = null;
                }                
                m_pSession.m_PassiveMode = false;

                m_pSession = null;
                if(m_pStream != null){
                    m_pStream.Dispose();
                    m_pStream = null;
                }
                if(m_pSocket != null){
                    m_pSocket.Close();
                    m_pSocket = null;
                }
            }
Exemplo n.º 15
0
		internal bool OnDeleteFile(FTP_Session session,string file)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.DeleteFile != null){
				this.DeleteFile(this,oArg);
			}
			
			return oArg.Validated;
		}
Exemplo n.º 16
0
		internal Stream OnStoreFile(FTP_Session session,string file)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.StoreFile != null){
				this.StoreFile(this,oArg);
			}
			
			return oArg.FileStream;
		}
Exemplo n.º 17
0
		internal FileSysEntry_EventArgs OnGetDirInfo(FTP_Session session,string dir)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,dir,"");
			if(this.GetDirInfo != null){
				this.GetDirInfo(this,oArg);
			}
			return oArg;
		}
Exemplo n.º 18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="socket"></param>
 protected override void InitNewSession(Socket socket)
 {
     SocketLogger logger  = new SocketLogger(socket, this.SessionLog);
     FTP_Session  session = new FTP_Session(socket, this, Guid.NewGuid().ToString(), logger);
 }
Exemplo n.º 19
0
		/// <summary>
		/// Authenticates user.
		/// </summary>
		/// <param name="session">Reference to current pop3 session.</param>
		/// <param name="userName">User name.</param>
		/// <param name="passwData"></param>
		/// <param name="data"></param>
		/// <param name="authType"></param>
		/// <returns></returns>
		internal virtual bool OnAuthUser(FTP_Session session,string userName,string passwData,string data,AuthType authType) 
		{				
			AuthUser_EventArgs oArg = new AuthUser_EventArgs(session,userName,passwData,data,authType);
			if(this.AuthUser != null){
				this.AuthUser(this,oArg);
			}
			
			return oArg.Validated;
		}
Exemplo n.º 20
0
		internal bool OnDeleteDir(FTP_Session session,string dir)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,dir,"");
			if(this.DeleteDir != null){
				this.DeleteDir(this,oArg);
			}
			
			return oArg.Validated;
		}
Exemplo n.º 21
0
		internal bool OnFileExists(FTP_Session session,string file)
		{
			// Remove last /
			file = file.Substring(0,file.Length - 1);

			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.FileExists != null){
				this.FileExists(this,oArg);
			}
			
			return oArg.Validated;
		}
Exemplo n.º 22
0
		/// <summary>
		/// Initialize and start new session here. Session isn't added to session list automatically, 
		/// session must add itself to server session list by calling AddSession().
		/// </summary>
		/// <param name="socket">Connected client socket.</param>
        /// <param name="bindInfo">BindInfo what accepted socket.</param>
		protected override void InitNewSession(Socket socket,IPBindInfo bindInfo)
		{
            string   sessionID = Guid.NewGuid().ToString();
            SocketEx socketEx  = new SocketEx(socket);
            if(LogCommands){
                socketEx.Logger = new SocketLogger(socket,this.SessionLog);
				socketEx.Logger.SessionID = sessionID;
            }
			FTP_Session session = new FTP_Session(sessionID,socketEx,bindInfo,this);
		}
Exemplo n.º 23
0
		internal bool OnRenameDirFile(FTP_Session session,string from,string to)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,from,to);
			if(this.RenameDirFile != null){
				this.RenameDirFile(this,oArg);
			}
			
			return oArg.Validated;
		}