예제 #1
0
        public FileTransferMethod GetFileTransferMethod(long submittedJobInfoId, AdaptorUser loggedUser)
        {
            log.Info("Getting file transfer method for submitted job info ID " + submittedJobInfoId + " with user " + loggedUser.GetLogIdentification());
            SubmittedJobInfo jobInfo = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).GetSubmittedJobInfoById(submittedJobInfoId, loggedUser);
            var certificateGenerator = new CertificateGenerator.CertificateGenerator();

            certificateGenerator.GenerateKey(2048);
            string publicKey      = certificateGenerator.DhiPublicKey();
            string jobDir         = FileSystemUtils.GetJobClusterDirectoryPath(jobInfo.Specification.FileTransferMethod.Cluster.LocalBasepath, jobInfo.Specification);
            var    transferMethod = new FileTransferMethod
            {
                Protocol       = jobInfo.Specification.FileTransferMethod.Protocol,
                ServerHostname = jobInfo.Specification.FileTransferMethod.ServerHostname,
                SharedBasePath = jobDir,
                Credentials    = new AsymmetricKeyCredentials
                {
                    Username   = jobInfo.Specification.ClusterUser.Username,
                    PrivateKey = certificateGenerator.DhiPrivateKey(),
                    PublicKey  = publicKey
                }
            };

            SchedulerFactory.GetInstance(jobInfo.Specification.Cluster.SchedulerType).CreateScheduler(jobInfo.Specification.Cluster).AllowDirectFileTransferAccessForUserToJob(publicKey, jobInfo);
            return(transferMethod);
        }
예제 #2
0
 public AbstractFileSystemManager(ILogger logger, FileTransferMethod configuration, FileSystemFactory synchronizerFactory)
 {
     _logger              = logger;
     _fileSystem          = configuration;
     _synchronizerFactory = synchronizerFactory;
     _fileSynchronizers   = new Dictionary <SynchronizableFiles, Dictionary <string, IFileSynchronizer> >();
 }
 public override IRexFileSystemManager CreateFileSystemManager(FileTransferMethod configuration)
 {
     if (!_managerSingletons.TryGetValue(configuration.ServerHostname, out IRexFileSystemManager fileManager))
     {
         fileManager = new SftpFileSystemManager(_logger, configuration, this, GetSchedulerConnectionPool(configuration));
         _managerSingletons.Add(configuration.ServerHostname, fileManager);
     }
     return(fileManager);
 }
예제 #4
0
        public virtual FileTransferMethod GetFileTransferMethodById(long fileTransferMethodById)
        {
            FileTransferMethod fileTransferMethod = unitOfWork.FileTransferMethodRepository.GetById(fileTransferMethodById);

            if (fileTransferMethod == null)
            {
                log.Error("Requested FileTransferMethod with Id=" + fileTransferMethodById + " does not exist in the system.");
                throw new RequestedObjectDoesNotExistException("Requested FileTransferMethod with Id=" + fileTransferMethodById + " does not exist in the system.");
            }
            return(fileTransferMethod);
        }
예제 #5
0
        public static FileTransferMethod ConvertFileTransferMethodExtToIn(FileTransferMethodExt usedTransferMethod)
        {
            FileTransferMethod convert = new FileTransferMethod
            {
                Credentials    = usedTransferMethod.Credentials.ConvertExtToInt(),
                Protocol       = ConvertFileTransferProtocolExtToIn(usedTransferMethod.Protocol),
                ServerHostname = usedTransferMethod.ServerHostname,
                SharedBasePath = usedTransferMethod.SharedBasepath
            };

            return(convert);
        }
예제 #6
0
        public static FileTransferMethodExt ConvertIntToExt(this FileTransferMethod fileTransferMethod)
        {
            FileTransferMethodExt convert = new FileTransferMethodExt()
            {
                ServerHostname = fileTransferMethod.ServerHostname,
                SharedBasepath = fileTransferMethod.SharedBasePath,
                Protocol       = ConvertFileTransferProtocolIntToExt(fileTransferMethod.Protocol),
                Credentials    = fileTransferMethod.Credentials.ConvertIntToExt()
            };

            return(convert);
        }
예제 #7
0
 public FileTransferMethodExt GetFileTransferMethod(long submittedJobInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser         = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic fileTransferLogic  = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             FileTransferMethod fileTransferMethod = fileTransferLogic.GetFileTransferMethod(submittedJobInfoId, loggedUser);
             return(fileTransferMethod.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
예제 #8
0
        public void EndFileTransfer(long submittedJobInfoId, FileTransferMethod transferMethod, AdaptorUser loggedUser)
        {
            log.Info("Removing file transfer method for submitted job info ID " + submittedJobInfoId + " with user " + loggedUser.GetLogIdentification());
            SubmittedJobInfo         jobInfo = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).GetSubmittedJobInfoById(submittedJobInfoId, loggedUser);
            AsymmetricKeyCredentials asymmetricKeyCredentials = transferMethod.Credentials as AsymmetricKeyCredentials;

            if (asymmetricKeyCredentials != null)
            {
                SchedulerFactory.GetInstance(jobInfo.Specification.Cluster.SchedulerType).CreateScheduler(jobInfo.Specification.Cluster).
                RemoveDirectFileTransferAccessForUserToJob(asymmetricKeyCredentials.PublicKey, jobInfo);
            }
            else
            {
                log.Error("Credentials of class " + transferMethod.Credentials.GetType().Name +
                          " are not supported. Change the HaaSMiddleware.BusinessLogicTier.FileTransfer.FileTransferLogic.EndFileTransfer() method to add support for additional credential types.");
                throw new ArgumentException("Credentials of class " + transferMethod.Credentials.GetType().Name +
                                            " are not supported. Change the HaaSMiddleware.BusinessLogicTier.FileTransfer.FileTransferLogic.EndFileTransfer() method to add support for additional credential types.");
            }
        }
 public override IRexFileSystemManager CreateFileSystemManager(FileTransferMethod configuration)
 {
     return(new NetworkShareFileSystemManager(_logger, configuration, this));
 }
예제 #10
0
 protected abstract IPoolableAdapter CreateFileSystemConnector(FileTransferMethod configuration);
예제 #11
0
 public abstract IRexFileSystemManager CreateFileSystemManager(FileTransferMethod configuration);
예제 #12
0
 public SftpFileSystemManager(ILogger logger, FileTransferMethod configuration, FileSystemFactory synchronizerFactory, IConnectionPool connectionPool)
     : base(logger, configuration, synchronizerFactory)
 {
     _connectionPool = connectionPool;
 }
예제 #13
0
 public NetworkShareFileSystemManager(ILogger logger, FileTransferMethod configuration, FileSystemFactory synchronizerFactory)
     : base(logger, configuration, synchronizerFactory)
 {
 }