Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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
            });
        }
Exemplo n.º 3
0
        public IEnumerable <EncryptionKeyPair> GetPublicKeysWithAccess(int fileId)
        {
            if (!PrivacyRoomSettings.GetEnabled(SettingsManager))
            {
                throw new System.Security.SecurityException();
            }

            return(EncryptionKeyPairHelper.GetKeyPair(fileId, FileStorageServiceInt));
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
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);
        }