public static IEnumerable <string> GetAddresses(string fileId)
        {
            var fileShares = Global.FileStorageService.GetSharedInfo(new ItemList <string> {
                String.Format("file_{0}", fileId)
            }).ToList();

            fileShares = fileShares.Where(share => !share.SubjectGroup && !share.SubjectId.Equals(FileConstant.ShareLinkId) && share.Share == FileShare.ReadWrite).ToList();
            var accountsString = fileShares.Select(share => EncryptionLoginProvider.GetAddress(share.SubjectId)).Where(address => !string.IsNullOrEmpty(address));

            return(accountsString);
        }
Esempio n. 2
0
        public object UpdateAddress(string address, string publicKey)
        {
            SecurityContext.DemandPermissions(new UserSecurityProvider(SecurityContext.CurrentAccount.ID), Core.Users.Constants.Action_EditUser);

            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentNullException("address");
            }
            if (string.IsNullOrEmpty(publicKey))
            {
                throw new ArgumentNullException("publicKey");
            }

            var currentAddressString = EncryptionLoginProvider.GetAddress();

            if (!string.IsNullOrEmpty(currentAddressString))
            {
                var currentAddress = JsonConvert.DeserializeObject <EncryptionAddress>(currentAddressString);
                if (currentAddress != null &&
                    !string.IsNullOrEmpty(currentAddress.PublicKey) &&
                    currentAddress.PublicKey.Equals(publicKey))
                {
                    return(new { isset = true });
                }

                LogManager.GetLogger("ASC.Api.Documents").InfoFormat("User {0} updates address", SecurityContext.CurrentAccount.ID);
            }

            var account = new EncryptionAddress {
                Address = address, PublicKey = publicKey
            };
            var accountString = JsonConvert.SerializeObject(account);

            EncryptionLoginProvider.UpdateAddress(accountString);

            return(new
            {
                isset = !string.IsNullOrEmpty(EncryptionLoginProvider.GetAddress())
            });
        }