EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Virtual File System

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#35860
Posted: 02/10/2016 09:14:09
by Frank Hommers (Basic support level)
Joined: 02/10/2016
Posts: 4

I am currently evaluating SecureBlackbox. (.NET) I am wondering how to achieve the following:

I want to implement a TElCustomFileSystemAdapter. Inside it I want to read entries from a database based filtered on by the ones that are accessible to the user.

But inside the TElCustomFileSystemAdapter I don't know how to get to the details of the FTP user that is logged in.

Can someone give my some pointers on how to achieve my goal?
#35861
Posted: 02/10/2016 10:38:18
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

Could you please elaborate on how is the adapter related to the FTP? Are you creating an FTP/FTPS server and want to use custom filesystem adapter in it?


Sincerely yours
Eugene Mayevski
#35862
Posted: 02/10/2016 10:49:04
by Frank Hommers (Basic support level)
Joined: 02/10/2016
Posts: 4

Yes, I am creating an FTP(S) server. With a custom (database based) file system in it.

Currently I found this to be working, but I am not confident that this will work correctly. Can you validate and/or correct this?

Code
    static void Main(string[] args)
    {
      TElSimpleFTPSServer elFtpServer = new TElSimpleFTPSServer();
      elFtpServer.FileSystemAdapter = null;  // Unassign filesystem adapter here
      elFtpServer.Start();
      elFtpServer.OnAuthAttempt += ElSimpleFtpsServerOnOnAuthAttempt;
      while (true)
      {
        Thread.Sleep(1000);
      }
    }
    
    private static void ElSimpleFtpsServerOnOnAuthAttempt(object sender, string username, string password, ref bool allow)
    {
      allow = false;

      SBSimpleFTPSServer.TElSimpleFTPSServerSessionThread Sender = sender as TElSimpleFTPSServerSessionThread;
      try
      {
        User user = UserRepository.Login(username, password);
        allow = true;
        Sender.FileSystemAdapter = new CustomDatabaseFileSystemAdapter(user); // Assign new filesystem adapter with user context to the thread.
        return;
      }
      catch
      {
      }
    }
#35863
Posted: 02/10/2016 11:05:19
by Eugene Mayevski (EldoS Corp.)

Yes, what you have found is the exact approach that I was going to recommend. There's one thing to add (optional but recommended) -- set Sender.ReleaseFileSystemAdapter property to true, so that once the thread is finished, your adapter is explicitly released and so gets the chance to deallocate the allocated resources (including unmanaged ones like connection to the server).


Sincerely yours
Eugene Mayevski
#35864
Posted: 02/10/2016 11:13:25
by Frank Hommers (Basic support level)
Joined: 02/10/2016
Posts: 4

OK I will add that property. It would be even nicer if the TElSimpleFTPSServerSessionThread would have had a property called "Tag" where you can add custom data. And also that the filesystemadapter would know the session.

At least that was what I was expecting. This feels a bit workaroundish ;-)
#35866
Posted: 02/10/2016 11:57:24
by Eugene Mayevski (EldoS Corp.)

FileSystem adapters are too abstract to know about sessions. As for the Tag property - we'll add one, thank you for the suggestion.

And the code was actually designed to create a custom adapter in OnAuthAttempt (we have special checks for a filesystem adapter in the code that fires an event).


Sincerely yours
Eugene Mayevski
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

Topic viewed 1023 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!