Пример #1
0
        private int CreateUrisHashCode()
        {
            var uriStrings     = Uris.Select(uri => uri.UrlString).ToArray();
            var hashCodeString = string.Join(string.Empty, uriStrings);

            return(hashCodeString.GetHashCode());
        }
Пример #2
0
 public override BitwardenItemLogin ConvertBack()
 {
     return(new BitwardenItemLogin
     {
         Uris = Uris.Select(x => x.ConvertBack()).ToList(),
         Username = Username,
         Password = Password,
     });
 }
Пример #3
0
        public LoginData ToLoginData()
        {
            var l = new LoginData();

            l.PasswordRevisionDate = PasswordRevisionDate;
            BuildDataModel(this, l, new HashSet <string>
            {
                "Username",
                "Password",
                "Totp"
            });
            if (Uris?.Any() ?? false)
            {
                l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
            }
            return(l);
        }
Пример #4
0
        public override bool Execute()
        {
            if (Retries < 0)
            {
                Log.LogError($"Invalid task parameter value: Retries={Retries}");
                return(false);
            }

            if (RetryDelayMilliseconds < 0)
            {
                Log.LogError($"Invalid task parameter value: RetryDelayMilliseconds={RetryDelayMilliseconds}");
                return(false);
            }

            if (File.Exists(DestinationPath) && !Overwrite)
            {
                return(true);
            }

            if (string.IsNullOrWhiteSpace(Uri) && (Uris == null || Uris.Count() == 0))
            {
                Log.LogError($"Invalid task parameter value: {nameof(Uri)} and {nameof(Uris)} are empty.");
                return(false);
            }

            Directory.CreateDirectory(Path.GetDirectoryName(DestinationPath));

            if (!string.IsNullOrWhiteSpace(Uri))
            {
                return(DownloadFromUriAsync(Uri).Result);
            }

            if (Uris != null)
            {
                foreach (var uriConfig in Uris)
                {
                    var uri          = uriConfig.ItemSpec;
                    var encodedToken = uriConfig.GetMetadata("token");

                    if (!string.IsNullOrWhiteSpace(encodedToken))
                    {
                        var encodedTokenBytes = System.Convert.FromBase64String(encodedToken);
                        var decodedToken      = System.Text.Encoding.UTF8.GetString(encodedTokenBytes);
                        uri = $"{uri}{decodedToken}";
                    }

                    if (DownloadFromUriAsync(uri).Result)
                    {
                        return(true);
                    }
                }

                Log.LogError($"Download from all targets failed. List of attempted targets: {string.Join(", ", Uris.Select(m => m.ItemSpec))}");
            }

            Log.LogError($"Failed to download file using addresses in {nameof(Uri)} and/or {nameof(Uris)}.");

            return(false);
        }
Пример #5
0
 public IList <IChannelDescribeSubscription> GetSubscriptions(Guid sessionId)
 => new List <IChannelDescribeSubscription>(Uris?.Select(uri => new Datatypes.ChannelData.ChannelDescribeSubscription(sessionId)
 {
     Uri = uri
 }));