Esempio n. 1
0
        private async Task <UserModel> GenerateUser(RecipientRequestBase addRecipientRequest, string password)
        {
            await InitializePrivilegedConnectionAsync();

            var folderIdentifier = addRecipientRequest.FolderIdentifier;
            var userModel        = new UserModel
            {
                Identifier   = ModuleUtility.GetFolderScopedUserIdentifier(folderIdentifier, addRecipientRequest.RecipientEmail, "leo"),
                EmailAddress = addRecipientRequest.RecipientEmail,
                FirstName    = addRecipientRequest.FirstName,
                LastName     = addRecipientRequest.LastName,
            };

            userModel = await privilegedConnection.User.PostAsync(userModel);

            await privilegedConnection.User.PasswordPutAsync(userModel.Identifier, password);

            await privilegedConnection.User.AccessIdentifiersPutAsync(userModel.Identifier, new[] {
                "r:leoUpload",
                $"o:{folderIdentifier.OrganizationKey}",
                "x:pcms",
                "x:eDiscovery",
                $"u:{userModel.Identifier.UserKey.Replace(" ", "_")}"
            });

            return(userModel);
        }
Esempio n. 2
0
        public static string CreateMagicLink(RecipientRequestBase addRecipientRequest, string landingLocation, string passphrase, FolderIdentifier folderIdentifier, DateTime?expirationDate, UserIdentifier userIdentifier)
        {
            // Create the magic link object.
            var magicLink = new MagicLink()
            {
                RecipientEmail   = addRecipientRequest.RecipientEmail,
                ExipirationDate  = expirationDate.GetValueOrDefault(),
                FolderIdentifier = folderIdentifier,
                UserIdentifier   = userIdentifier
            };

            // Serialize and encrypt that magic link, which we'll turn into a token.  This is a touple, that will return the cipher, and IV.
            var cipherIV = TokenEncryption.Encrypt(JsonConvert.SerializeObject(magicLink, Formatting.None), passphrase);

            // Build the full landing url. Encrypted token, and plain IV
            return(String.Format($"{landingLocation}/{HttpUtility.UrlEncode(cipherIV)}"));
        }