Example #1
0
        public async Task <RecipientResponse> RegenerateRecipientPasswordAsync(RegenerateRecipientPasswordRequest regenRequest)
        {
            var folder = await connection.Folder.GetAsync(regenRequest.FolderIdentifier);

            var recipients = folder.MetaEDiscoveryRecipientListRead();

            var password = ModuleUtility.GeneratePassword(folder, MetadataKeyConstants.E_DISCOVERY_RND_PASSWORD_LENGTH, EDiscoveryUtility.E_DISCOVERY_DEFAULT_PASSWORD_LENGTH, MetadataKeyConstants.E_DISCOVERY_RND_PASSWORD_CHARS);

            var recipient = recipients.Where(rec => rec.Email.ToLower() == regenRequest.RecipientEmail.ToLower()).FirstOrDefault();

            if (recipient != null)
            {
                // Using the special connection here to update their password.
                var userIdentifier = ModuleUtility.GetFolderScopedUserIdentifier(folder.Identifier, regenRequest.RecipientEmail);

                await InitializePrivilegedConnectionAsync();

                await privilegedConnection.User.PasswordPutAsync(userIdentifier, password.Plain);

                await this.auditLogStore.AddEntry(
                    new AuditLogEntry()
                {
                    EntryType  = AuditLogEntryType.eDiscoveryRecipientRegenerated,
                    Message    = $"An eDiscovery has had their password regenerated {recipient.Email}",
                    ModuleType = Modules.ModuleType.eDiscovery
                },
                    folder.Identifier
                    );

                recipient.PasswordHash   = password.Hashed;
                recipient.ExpirationDate = ModuleUtility.GetLinkExpirationDate(folder, MetadataKeyConstants.E_DISCOVERY_EXPIRATION_LENGTH_SECONDS).Value;
                recipient.MagicLink      = ModuleUtility.CreateMagicLink(regenRequest, managerConfiguration.EDiscoveryLandingLocation, managerConfiguration.EDiscoveryLinkEncryptionKey, regenRequest.FolderIdentifier, recipient.ExpirationDate, userIdentifier);

                await connection.ConcurrencyRetryBlock(async() =>
                {
                    folder = await connection.Folder.GetAsync(regenRequest.FolderIdentifier);

                    folder.MetaEDiscoveryRecipientListUpsert(recipient);
                    await connection.Folder.PutAsync(folder);
                });

                // now we also want to send back the magic link that we generated before.
                return(new RecipientResponse()
                {
                    Email = regenRequest.RecipientEmail,
                    FirstName = recipient.FirstName,
                    LastName = recipient.LastName,
                    Password = password.Plain,
                    MagicLink = recipient.MagicLink,
                    ExpirationDate = recipient.ExpirationDate,
                });
            }

            return(new RecipientResponse());
        }
Example #2
0
        public async Task <RecipientResponse> AddRecipientAsync(AddRecipientRequest addRecipientRequest, string landingLocation, string passphrase)
        {
            var folder = await connection.Folder.GetAsync(addRecipientRequest.FolderIdentifier);

            DateTime?expirationDate = ModuleUtility.GetLinkExpirationDate(folder, MetadataKeyConstants.E_DISCOVERY_EXPIRATION_LENGTH_SECONDS);

            var password = ModuleUtility.GeneratePassword(folder, MetadataKeyConstants.E_DISCOVERY_RND_PASSWORD_LENGTH, EDiscoveryUtility.E_DISCOVERY_DEFAULT_PASSWORD_LENGTH, MetadataKeyConstants.E_DISCOVERY_RND_PASSWORD_CHARS);

            // We're going to generate a user for eDicsovery.  This user will have restricted priveleges.
            var user = await GenerateUserForEDiscovery(addRecipientRequest, password.Plain);

            string completeUrl = ModuleUtility.CreateMagicLink(addRecipientRequest, landingLocation, passphrase, folder.Identifier, expirationDate, user.Identifier);

            folder.MetaEDiscoveryRecipientListUpsert(new ExternalUser()
            {
                Email          = addRecipientRequest.RecipientEmail,
                FirstName      = addRecipientRequest.FirstName,
                LastName       = addRecipientRequest.LastName,
                PasswordHash   = password.Hashed,
                MagicLink      = completeUrl,
                ExpirationDate = expirationDate.GetValueOrDefault()
            });
            await connection.Folder.PutAsync(folder);

            await EnsureFolderSecurityConfiguration(folder.Identifier);

            await this.auditLogStore.AddEntry(
                new AuditLogEntry()
            {
                EntryType  = AuditLogEntryType.eDiscoveryRecipientAdded,
                Message    = $"An eDiscovery User has been added. {addRecipientRequest.RecipientEmail}",
                ModuleType = Modules.ModuleType.eDiscovery
            },
                folder.Identifier
                );

            // build up the response
            return(new RecipientResponse()
            {
                Email = addRecipientRequest.RecipientEmail,
                ExpirationDate = expirationDate.GetValueOrDefault(),
                MagicLink = completeUrl,
                Password = password.Plain,
                FirstName = addRecipientRequest.FirstName,
                LastName = addRecipientRequest.LastName,
            });
        }
Example #3
0
        public async Task <RecipientResponse> AddRecipientAsync(AddOfficerRequest addOfficerRequest, string landingLocation, string passphrase)
        {
            var folder = await connection.Folder.GetAsync(addOfficerRequest.FolderIdentifier);

            DateTime?expirationDate = ModuleUtility.GetLinkExpirationDate(folder, MetadataKeyConstants.LEO_UPLOAD_EXPIRATION_LENGTH_SECONDS);

            var password = ModuleUtility.GeneratePassword(
                folder,
                MetadataKeyConstants.LEO_UPLOAD_RND_PASSWORD_LENGTH,
                LEOUploadUtility.LEO_UPLOAD_DEFAULT_PASSWORD_LENGTH,
                MetadataKeyConstants.LEO_UPLOAD_RND_PASSWORD_CHARS);

            // We're going to generate a user for eDicsovery.  This user will have restricted priveleges.
            var user = await GenerateUser(addOfficerRequest, password.Plain);

            string completeUrl = ModuleUtility.CreateMagicLink(addOfficerRequest, landingLocation, passphrase, folder.Identifier, expirationDate, user.Identifier);

            await connection.ConcurrencyRetryBlock(async() =>
            {
                folder = await connection.Folder.GetAsync(addOfficerRequest.FolderIdentifier);

                folder.MetaLEOUploadOfficerListUpsert(new ExternalUser()
                {
                    Email          = addOfficerRequest.RecipientEmail,
                    FirstName      = addOfficerRequest.FirstName,
                    LastName       = addOfficerRequest.LastName,
                    PasswordHash   = password.Hashed,
                    MagicLink      = completeUrl,
                    ExpirationDate = expirationDate.GetValueOrDefault()
                });

                var childPath = GetOfficerPath(addOfficerRequest.FolderIdentifier, addOfficerRequest.FirstName, addOfficerRequest.LastName);

                var allPaths = folder.Read("_paths", defaultValue: new List <string>());

                allPaths.Add(childPath.FullName);

                folder.Write("_paths", allPaths);

                await connection.Folder.PutAsync(folder);
            });

            await this.auditLogStore.AddEntry(
                new AuditLogEntry()
            {
                EntryType  = AuditLogEntryType.LEOUploadOfficerAdded,
                Message    = $"A LEO officer has been added. {addOfficerRequest.RecipientEmail}",
                ModuleType = Modules.ModuleType.LEOUpload
            },
                folder.Identifier
                );

            // build up the response
            return(new RecipientResponse()
            {
                Email = addOfficerRequest.RecipientEmail,
                ExpirationDate = expirationDate.GetValueOrDefault(),
                MagicLink = completeUrl,
                Password = password.Plain,
                FirstName = addOfficerRequest.FirstName,
                LastName = addOfficerRequest.LastName,
            });
        }