private object SetKeys(PrivacyRoomModel model)
        {
            PermissionContext.DemandPermissions(new UserSecurityProvider(AuthContext.CurrentAccount.ID), Constants.Action_EditUser);

            if (!PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                throw new System.Security.SecurityException();
            }

            var keyPair = EncryptionKeyPairHelper.GetKeyPair();

            if (keyPair != null)
            {
                if (!string.IsNullOrEmpty(keyPair.PublicKey))
                {
                    return(new { isset = true });
                }

                Log.InfoFormat("User {0} updates address", AuthContext.CurrentAccount.ID);
            }

            EncryptionKeyPairHelper.SetKeyPair(model.PublicKey, model.PrivateKeyEnc);

            return(new
            {
                isset = true
            });
        }
        public Configuration <T> OpenEdit(T fileId, int version, string doc, bool view)
        {
            DocumentServiceHelper.GetParams(fileId, version, doc, true, !view, true, out var configuration);
            configuration.EditorType = EditorType.External;
            if (configuration.EditorConfig.ModeWrite)
            {
                configuration.EditorConfig.CallbackUrl = DocumentServiceTracker.GetCallbackUrl(configuration.Document.Info.GetFile().ID.ToString());
            }

            if (configuration.Document.Info.GetFile().RootFolderType == FolderType.Privacy && PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                var keyPair = EncryptionKeyPairHelper.GetKeyPair();
                if (keyPair != null)
                {
                    configuration.EditorConfig.EncryptionKeys = new EncryptionKeysConfig
                    {
                        PrivateKeyEnc = keyPair.PrivateKeyEnc,
                        PublicKey     = keyPair.PublicKey,
                    };
                }
            }

            if (!configuration.Document.Info.GetFile().Encrypted&& !configuration.Document.Info.GetFile().ProviderEntry)
            {
                EntryManager.MarkAsRecent(configuration.Document.Info.GetFile());
            }

            configuration.Token = DocumentServiceHelper.GetSignature(configuration);
            return(configuration);
        }
        public IEnumerable <EncryptionKeyPair> GetPublicKeysWithAccess(int fileId)
        {
            if (!PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                throw new System.Security.SecurityException();
            }

            return(EncryptionKeyPairHelper.GetKeyPair(fileId, FileStorageServiceInt));
        }
        public EncryptionKeyPair GetKeys()
        {
            PermissionContext.DemandPermissions(new UserSecurityProvider(AuthContext.CurrentAccount.ID), Constants.Action_EditUser);

            if (!PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                throw new System.Security.SecurityException();
            }

            return(EncryptionKeyPairHelper.GetKeyPair());
        }
 /// <summary>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="fileStorageService"></param>
 public FilesControllerHelper(
     ApiContext context,
     FileStorageService <T> fileStorageService,
     FileWrapperHelper fileWrapperHelper,
     FilesSettingsHelper filesSettingsHelper,
     FilesLinkUtility filesLinkUtility,
     FileUploader fileUploader,
     DocumentServiceHelper documentServiceHelper,
     TenantManager tenantManager,
     SecurityContext securityContext,
     FolderWrapperHelper folderWrapperHelper,
     FileOperationWraperHelper fileOperationWraperHelper,
     FileShareWrapperHelper fileShareWrapperHelper,
     FileShareParamsHelper fileShareParamsHelper,
     EntryManager entryManager,
     FolderContentWrapperHelper folderContentWrapperHelper,
     ChunkedUploadSessionHelper chunkedUploadSessionHelper,
     DocumentServiceTrackerHelper documentServiceTracker,
     IOptionsMonitor <ILog> optionMonitor,
     SettingsManager settingsManager,
     EncryptionKeyPairHelper encryptionKeyPairHelper,
     IHttpContextAccessor httpContextAccessor,
     FileConverter fileConverter,
     ApiDateTimeHelper apiDateTimeHelper,
     UserManager userManager,
     DisplayUserSettingsHelper displayUserSettingsHelper)
 {
     ApiContext                 = context;
     FileStorageService         = fileStorageService;
     FileWrapperHelper          = fileWrapperHelper;
     FilesSettingsHelper        = filesSettingsHelper;
     FilesLinkUtility           = filesLinkUtility;
     FileUploader               = fileUploader;
     DocumentServiceHelper      = documentServiceHelper;
     TenantManager              = tenantManager;
     SecurityContext            = securityContext;
     FolderWrapperHelper        = folderWrapperHelper;
     FileOperationWraperHelper  = fileOperationWraperHelper;
     FileShareWrapperHelper     = fileShareWrapperHelper;
     FileShareParamsHelper      = fileShareParamsHelper;
     EntryManager               = entryManager;
     FolderContentWrapperHelper = folderContentWrapperHelper;
     ChunkedUploadSessionHelper = chunkedUploadSessionHelper;
     DocumentServiceTracker     = documentServiceTracker;
     SettingsManager            = settingsManager;
     EncryptionKeyPairHelper    = encryptionKeyPairHelper;
     ApiDateTimeHelper          = apiDateTimeHelper;
     UserManager                = userManager;
     DisplayUserSettingsHelper  = displayUserSettingsHelper;
     HttpContextAccessor        = httpContextAccessor;
     FileConverter              = fileConverter;
     Logger = optionMonitor.Get("ASC.Files");
 }
 public PrivacyRoomController(
     AuthContext authContext,
     PermissionContext permissionContext,
     SettingsManager settingsManager,
     TenantManager tenantManager,
     EncryptionKeyPairHelper encryptionKeyPairHelper,
     FileStorageService <int> fileStorageServiceInt,
     FileStorageService <string> fileStorageService,
     MessageService messageService,
     IOptionsMonitor <ILog> option)
 {
     AuthContext             = authContext;
     PermissionContext       = permissionContext;
     SettingsManager         = settingsManager;
     TenantManager           = tenantManager;
     EncryptionKeyPairHelper = encryptionKeyPairHelper;
     FileStorageServiceInt   = fileStorageServiceInt;
     FileStorageService      = fileStorageService;
     MessageService          = messageService;
     Log = option.Get("ASC.Api.Documents");
 }
示例#7
0
        public Configuration <T> OpenEdit(T fileId, int version, string doc)
        {
            DocumentServiceHelper.GetParams(fileId, version, doc, true, true, true, out var configuration);
            configuration.EditorType = EditorType.External;
            configuration.EditorConfig.CallbackUrl = DocumentServiceTracker.GetCallbackUrl(configuration.Document.Info.File.ID.ToString());

            if (configuration.Document.Info.File.RootFolderType == FolderType.Privacy && PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                var keyPair = EncryptionKeyPairHelper.GetKeyPair();
                if (keyPair != null)
                {
                    configuration.EditorConfig.EncryptionKeys = new EncryptionKeysConfig
                    {
                        PrivateKeyEnc = keyPair.PrivateKeyEnc,
                        PublicKey     = keyPair.PublicKey,
                    };
                }
            }


            configuration.Token = DocumentServiceHelper.GetSignature(configuration);
            return(configuration);
        }