예제 #1
0
        public static bool Load(SecureString pasword)
        {
            try
            {
                byte[] xml = null;

                // Decrypt file
                if (File.Exists(GetCredentialsFilePath()))
                {
                    var cipherWithSaltAndIv = File.ReadAllBytes(GetCredentialsFilePath());

                    xml = Decrypt(cipherWithSaltAndIv, SecureStringHelper.ConvertToString(pasword));
                }

                // Save master pw for encryption
                SetMasterPassword(pasword);

                // Check if array is empty...
                if (xml != null && xml.Length > 0)
                {
                    DeserializeFromByteArray(xml);
                }

                Credentials.CollectionChanged += Credentials_CollectionChanged;

                IsLoaded = true;

                return(true);
            }
            catch (CryptographicException)
            {
                return(false);
            }
        }
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            string license = SecureStringHelper.ConvertToString((SecureString)value);

            if (!string.IsNullOrEmpty(license) && (Regex.IsMatch((string)license, LicenseManager.FormatCheck.ToString())))
            {
                return(ValidationResult.ValidResult);
            }

            return(new ValidationResult(false, Resources.Localization.Strings.EnterValidRepetierApiKey));
        }
예제 #3
0
        public static void Save()
        {
            // Serialize as xml (utf-8)
            byte[] credentials = SerializeToByteArray();

            // Encrypt with master pw and save file
            byte[] encrypted = Encrypt(credentials, SecureStringHelper.ConvertToString(_masterPassword));

            // Check if the path exists, create if not
            File.WriteAllBytes(GetCredentialsFilePath(), encrypted);

            CredentialsChanged = false;
        }
예제 #4
0
        public void WalkV3Async(IPAddress ipAddress, string oid, SNMPV3Security security, string username, SNMPV3AuthenticationProvider authProvider, SecureString auth, SNMPV3PrivacyProvider privProvider, SecureString priv, WalkMode walkMode)
        {
            Task.Run(() =>
            {
                try
                {
                    var ipEndpoint = new IPEndPoint(ipAddress, Port);

                    // Discovery
                    var discovery = Messenger.GetNextDiscovery(SnmpType.GetRequestPdu);
                    var report    = discovery.GetResponse(Timeout, ipEndpoint);

                    IPrivacyProvider privacy;

                    switch (security)
                    {
                    case SNMPV3Security.AuthPriv:
                        privacy = GetPrivacy(authProvider, SecureStringHelper.ConvertToString(auth), privProvider, SecureStringHelper.ConvertToString(priv));
                        break;

                    // noAuthNoPriv
                    case SNMPV3Security.AuthNoPriv:
                        privacy = GetPrivacy(authProvider, SecureStringHelper.ConvertToString(auth));
                        break;

                    default:
                        privacy = GetPrivacy();
                        break;
                    }

                    var results = new List <Variable>();

                    Messenger.BulkWalk(VersionCode.V3, ipEndpoint, new OctetString(username), OctetString.Empty, new ObjectIdentifier(oid), results, Timeout, 10, walkMode, privacy, report);

                    foreach (var result in results)
                    {
                        OnReceived(new SNMPReceivedArgs(result.Id, result.Data));
                    }

                    OnComplete();
                }
                catch (Lextm.SharpSnmpLib.Messaging.TimeoutException)
                {
                    OnTimeoutReached();
                }
                catch (ErrorException)
                {
                    OnError();
                }
            });
        }
예제 #5
0
        public void Getv3Async(IPAddress ipAddress, string oid, SNMPV3Security security, string username, SNMPV3AuthenticationProvider authProvider, SecureString auth, SNMPV3PrivacyProvider privProvider, SecureString priv)
        {
            Task.Run(() =>
            {
                try
                {
                    var ipEndpoint = new IPEndPoint(ipAddress, Port);

                    // Discovery
                    var discovery = Messenger.GetNextDiscovery(SnmpType.GetRequestPdu);
                    var report    = discovery.GetResponse(Timeout, ipEndpoint);

                    IPrivacyProvider privacy;

                    switch (security)
                    {
                    case SNMPV3Security.AuthPriv:
                        privacy = GetPrivacy(authProvider, SecureStringHelper.ConvertToString(auth), privProvider, SecureStringHelper.ConvertToString(priv));
                        break;

                    // noAuthNoPriv
                    case SNMPV3Security.AuthNoPriv:
                        privacy = GetPrivacy(authProvider, SecureStringHelper.ConvertToString(auth));
                        break;

                    default:
                        privacy = GetPrivacy();
                        break;
                    }

                    var request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString(username), new List <Variable> {
                        new Variable(new ObjectIdentifier(oid))
                    }, privacy, Messenger.MaxMessageSize, report);
                    var reply = request.GetResponse(Timeout, ipEndpoint);

                    var result = reply.Pdu().Variables[0];

                    OnReceived(new SNMPReceivedArgs(result.Id, result.Data));

                    OnComplete();
                }
                catch (Lextm.SharpSnmpLib.Messaging.TimeoutException)
                {
                    OnTimeoutReached();
                }
                catch (ErrorException)
                {
                    OnError();
                }
            });
        }
예제 #6
0
        private void Connect()
        {
            rdpClient.Server = _rdpSessionInfo.Hostname;
            rdpClient.AdvancedSettings9.RDPPort = _rdpSessionInfo.Port;

            if (_rdpSessionInfo.CustomCredentials)
            {
                rdpClient.UserName = _rdpSessionInfo.Username;
                rdpClient.AdvancedSettings9.ClearTextPassword = SecureStringHelper.ConvertToString(_rdpSessionInfo.Password);
            }

            // AdvancedSettings
            rdpClient.AdvancedSettings9.AuthenticationLevel  = _rdpSessionInfo.AuthenticationLevel;
            rdpClient.AdvancedSettings9.EnableCredSspSupport = _rdpSessionInfo.EnableCredSspSupport;

            // Devices and resources
            rdpClient.AdvancedSettings9.RedirectClipboard  = _rdpSessionInfo.RedirectClipboard;
            rdpClient.AdvancedSettings9.RedirectDevices    = _rdpSessionInfo.RedirectDevices;
            rdpClient.AdvancedSettings9.RedirectDrives     = _rdpSessionInfo.RedirectDrives;
            rdpClient.AdvancedSettings9.RedirectPorts      = _rdpSessionInfo.RedirectPorts;
            rdpClient.AdvancedSettings9.RedirectSmartCards = _rdpSessionInfo.RedirectSmartCards;
            rdpClient.AdvancedSettings9.RedirectPrinters   = _rdpSessionInfo.RedirectPrinters;

            // Display
            rdpClient.ColorDepth = _rdpSessionInfo.ColorDepth;      // 8, 15, 16, 24

            if (_rdpSessionInfo.AdjustScreenAutomatically || _rdpSessionInfo.UseCurrentViewSize)
            {
                rdpClient.DesktopWidth  = (int)rdpGrid.ActualWidth;
                rdpClient.DesktopHeight = (int)rdpGrid.ActualHeight;
            }
            else
            {
                rdpClient.DesktopWidth  = _rdpSessionInfo.DesktopWidth;
                rdpClient.DesktopHeight = _rdpSessionInfo.DesktopHeight;
            }

            FixWindowsFormsHostSize();

            // Events
            rdpClient.OnConnected    += RdpClient_OnConnected;
            rdpClient.OnDisconnected += RdpClient_OnDisconnected;

            rdpClient.Connect();
        }
 public void HasCredentialInfoChanged()
 {
     CredentialInfoChanged = (_credentialInfo.Name != Name) || (_credentialInfo.Username != Username) || (SecureStringHelper.ConvertToString(_credentialInfo.Password) != SecureStringHelper.ConvertToString(Password));
 }
예제 #8
0
        private static Dictionary <string, string> InitializeHeaders(Provider provider, bool isPostOrPut)
        {
            Dictionary <string, string> headers = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            if (provider.PSVstsDriveInfo.UsePersonalAccessToken)
            {
                headers["Authorization"] = string.Format(
                    "Basic {0}",
                    Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format(":{0}", SecureStringHelper.ConvertToString(provider.PSVstsDriveInfo.PersonalAccessToken)))));
            }

            if (isPostOrPut)
            {
                headers["Content-Type"] = "application/json";
            }

            return(headers);
        }
예제 #9
0
 public static bool VerifyMasterPasword(SecureString password)
 {
     return(SecureStringHelper.ConvertToString(_masterPassword).Equals(SecureStringHelper.ConvertToString(password)));
 }
예제 #10
0
        private static byte[] SerializeToByteArray()
        {
            // Convert CredentialInfo to CredentialInfoSerializable
            var list = new List <CredentialInfoSerializable>();

            foreach (var info in Credentials)
            {
                list.Add(new CredentialInfoSerializable(info.ID, info.Name, info.Username, SecureStringHelper.ConvertToString(info.Password)));
            }

            var xmlSerializer = new XmlSerializer(typeof(List <CredentialInfoSerializable>));

            using (var memoryStream = new MemoryStream())
            {
                using (var streamWriter = new StreamWriter(memoryStream, Encoding.UTF8))
                {
                    xmlSerializer.Serialize(streamWriter, list);
                    return(memoryStream.ToArray());
                }
            }
        }
예제 #11
0
        private void ValidatePassword()
        {
            PasswordIsEmpty = ((Password == null || Password.Length == 0) || (PasswordRepeat == null || PasswordRepeat.Length == 0));

            PasswordsMatch = PasswordIsEmpty ? false : SecureStringHelper.ConvertToString(Password).Equals(SecureStringHelper.ConvertToString(PasswordRepeat));
        }
예제 #12
0
        public void WalkV1V2CAsync(SNMPVersion version, IPAddress ipAddress, SecureString community, string oid, WalkMode walkMode)
        {
            Task.Run(() =>
            {
                try
                {
                    IList <Variable> results = new List <Variable>();

                    Messenger.Walk(version == SNMPVersion.V1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, Port), new OctetString(SecureStringHelper.ConvertToString(community)), new ObjectIdentifier(oid), results, Timeout, walkMode);

                    foreach (var result in results)
                    {
                        OnReceived(new SNMPReceivedArgs(result.Id, result.Data));
                    }

                    OnComplete();
                }
                catch (Lextm.SharpSnmpLib.Messaging.TimeoutException)
                {
                    OnTimeoutReached();
                }
                catch (ErrorException)
                {
                    OnError();
                }
            });
        }
예제 #13
0
        public void SetV1V2CAsync(SNMPVersion version, IPAddress ipAddress, SecureString communtiy, string oid, string data)
        {
            Task.Run(() =>
            {
                try
                {
                    Messenger.Set(version == SNMPVersion.V1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, Port), new OctetString(SecureStringHelper.ConvertToString(communtiy)), new List <Variable> {
                        new Variable(new ObjectIdentifier(oid), new OctetString(data))
                    }, Timeout);

                    OnComplete();
                }
                catch (Lextm.SharpSnmpLib.Messaging.TimeoutException)
                {
                    OnTimeoutReached();
                }
                catch (ErrorException)
                {
                    OnError();
                }
            });
        }