public void NewValue_SetGetTsgwPassword_ReturnsSavedValue()
        {
            FavoriteConfigurationSecurity favoriteSecurity = this.CreateFavoriteConfigurationSecurity();

            favoriteSecurity.TsgwPassword = EXPECTEDPASSWORD;
            Assert.AreEqual(EXPECTEDPASSWORD, favoriteSecurity.TsgwPassword, MESSAGE);
        }
        public void WithCredential_ResolveDomain_ReturnsCredentialDomain()
        {
            FavoriteConfigurationSecurity favoriteSecurity = this.CreateFavoriteConfigurationSecurity();
            string resolved = favoriteSecurity.ResolveDomainName();

            Assert.AreEqual(EXPECTED_DOMAIN, resolved, "Domain is primary resolved from Credential.");
        }
示例#3
0
 public void Export(ExportOptions options)
 {
     try
     {
         using (var w = new XmlTextWriter(options.FileName, Encoding.UTF8))
         {
             w.Formatting = Formatting.Indented;
             w.WriteStartDocument();
             w.WriteStartElement("favorites");
             foreach (FavoriteConfigurationElement favorite in options.Favorites)
             {
                 var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite);
                 var context          = new ExportOptionsContext(w, favoriteSecurity, options.IncludePasswords, favorite);
                 WriteFavorite(context);
             }
             w.WriteEndElement();
             w.WriteEndDocument();
             w.Flush();
             w.Close();
         }
     }
     catch (Exception ex)
     {
         Logging.Error("Export XML Failed", ex);
     }
 }
示例#4
0
        internal static SharedFavorite ConvertFromFavorite(IPersistence persistence, FavoriteConfigurationElement Favorite)
        {
            var            favoriteSecurity = new FavoriteConfigurationSecurity(persistence, Favorite);
            SharedFavorite fav = new SharedFavorite();

            fav.Colors             = Favorite.Colors;
            fav.ConnectToConsole   = Favorite.ConnectToConsole;
            fav.DesktopShare       = Favorite.DesktopShare;
            fav.DesktopSize        = Favorite.DesktopSize;
            fav.DomainName         = favoriteSecurity.ResolveDomainName();
            fav.Name               = Favorite.Name;
            fav.Port               = Favorite.Port;
            fav.Protocol           = Favorite.Protocol;
            fav.RedirectClipboard  = Favorite.RedirectClipboard;
            fav.RedirectDevices    = Favorite.RedirectDevices;
            fav.RedirectedDrives   = Favorite.RedirectedDrives;
            fav.RedirectPorts      = Favorite.RedirectPorts;
            fav.RedirectPrinters   = Favorite.RedirectPrinters;
            fav.RedirectSmartCards = Favorite.RedirectSmartCards;
            fav.ServerName         = Favorite.ServerName;
            fav.DisableWallPaper   = Favorite.DisableWallPaper;
            fav.Sounds             = Favorite.Sounds;
            var tagsConverter = new TagsConverter();

            fav.Tags                  = tagsConverter.ResolveTags(Favorite);
            fav.ConsoleBackColor      = Favorite.ConsoleBackColor;
            fav.ConsoleCols           = Favorite.ConsoleCols;
            fav.ConsoleCursorColor    = Favorite.ConsoleCursorColor;
            fav.ConsoleFont           = Favorite.ConsoleFont;
            fav.ConsoleRows           = Favorite.ConsoleRows;
            fav.ConsoleTextColor      = Favorite.ConsoleTextColor;
            fav.VMRCAdministratorMode = Favorite.VMRCAdministratorMode;
            fav.VMRCReducedColorsMode = Favorite.VMRCReducedColorsMode;
            return(fav);
        }
示例#5
0
 internal ExportOptionsContext(XmlTextWriter writer, FavoriteConfigurationSecurity favoriteSecurity,
                               bool includePasswords, FavoriteConfigurationElement favorite)
 {
     this.favoriteSecurity = favoriteSecurity;
     this.Writer           = writer;
     this.IncludePasswords = includePasswords;
     this.Favorite         = favorite;
 }
示例#6
0
        public void ImportFullFile_Server2_ImportsEmptyPassword()
        {
            FavoriteConfigurationElement server2 = this.ImportServer(1);
            var          security = new FavoriteConfigurationSecurity(this.Persistence, server2);
            const string MESSAGE  = "Imported password of server2 should be empty string," +
                                    " because we cant import encrypted paswords";

            Assert.AreEqual(string.Empty, security.Password, MESSAGE);
        }
示例#7
0
        private void ImportCredentials()
        {
            LogonCredentials credentials = this.server.LogonCredentials;

            this.favorite.DomainName = credentials.Domain;
            this.favorite.UserName   = credentials.UserName;
            var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, this.favorite);

            favoriteSecurity.Password = credentials.Password;
        }
示例#8
0
        private void ExportCredentials(ExportOptionsContext context)
        {
            FavoriteConfigurationElement favorite = context.Favorite;

            var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite);

            context.WriteElementString("credential", favorite.Credential);
            context.WriteElementString("domainName", favoriteSecurity.ResolveDomainName());

            if (context.IncludePasswords)
            {
                context.WriteElementString("userName", favoriteSecurity.ResolveUserName());
                context.WriteElementString("password", favoriteSecurity.Password);
            }
        }
示例#9
0
        private void ConvertSecurity(FavoriteConfigurationElement result, IFavorite sourceFavorite)
        {
            var security = sourceFavorite.Security;
            var guarded  = new GuardedSecurity(this.Persistence, security);

            result.DomainName = guarded.Domain;
            result.UserName   = guarded.UserName;
            // because persistence and application masterpassword may differ, we have to go through encryption
            var resultSecurity = new FavoriteConfigurationSecurity(this.Persistence, result);

            resultSecurity.Password = guarded.Password;

            ICredentialSet credential = this.Persistence.Credentials[security.Credential];

            if (credential != null)
            {
                result.Credential = credential.Name;
            }
        }
示例#10
0
        private XElement ExportFavorite(FavoriteConfigurationElement favorite)
        {
            var favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite);
            int audioMode        = ExportRdp.ConvertFromSounds(favorite.Sounds);
            int colorBits        = ExportRdp.ConvertToColorBits(favorite.Colors);

            return(new XElement("server",

                                // analogic to RDP
                                new XAttribute("full-address", favorite.ServerName),
                                new XAttribute("server-port", favorite.Port),
                                new XAttribute("username", favoriteSecurity.ResolveUserName()),
                                new XAttribute("domain", favoriteSecurity.ResolveDomainName()),
                                new XAttribute("desktopwidth", favorite.DesktopSizeWidth),
                                new XAttribute("desktopheight", favorite.DesktopSizeHeight),
                                new XAttribute("session-bpp", colorBits),
                                new XAttribute("audiomode", audioMode),
                                new XAttribute("connect-to-console", Convert.ToByte(favorite.ConnectToConsole)),
                                new XAttribute("compression", Convert.ToByte(favorite.EnableCompression)),
                                new XAttribute("disable-cursor-setting",
                                               Convert.ToByte(favorite.DisableCursorBlinking && favorite.DisableCursorShadow)),
                                new XAttribute("disable-full-window-drag", Convert.ToByte(favorite.DisableFullWindowDrag)),
                                new XAttribute("disable-menu-anims", Convert.ToByte(favorite.DisableMenuAnimations)),
                                new XAttribute("disable-themes", Convert.ToByte(favorite.DisableTheming)),
                                new XAttribute("disable-wallpaper", Convert.ToByte(favorite.DisableWallPaper)),
                                new XAttribute("allow-font-smoothing", Convert.ToByte(favorite.EnableFontSmoothing)),
                                new XAttribute("redirectdrives", "1"),
                                new XAttribute("redirectclipboard", Convert.ToByte(favorite.RedirectClipboard)),
                                new XAttribute("alternate-shell", ""),
                                new XAttribute("shell-working-directory", ""),
                                new XAttribute("gatewayusagemethod", favorite.TsgwUsageMethod),
                                new XAttribute("gatewayhostname", favorite.TsgwHostname),

                                // application specific
                                new XAttribute("xtr-description", favorite.Notes),
                                new XAttribute("xtr-security-layer", 0),
                                new XAttribute("xtr-use-server-creds-for-gateway", Convert.ToByte(favorite.TsgwSeparateLogin)),
                                new XAttribute("xtr-input-locale", 1033),
                                new XAttribute("xtr-switch-mouse-buttons", 0)
                                ));
        }
示例#11
0
        private string ExportFileContent(FavoriteConfigurationElement favorite)
        {
            var           favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, favorite);
            StringBuilder fileContent      = new StringBuilder();

            AppendPropertyLine(fileContent, ImportRDP.FULLADDRES, favorite.ServerName);
            AppendPropertyLine(fileContent, ImportRDP.SERVERPORT, favorite.Port.ToString());
            AppendPropertyLine(fileContent, ImportRDP.USERNAME, favoriteSecurity.ResolveUserName());
            AppendPropertyLine(fileContent, ImportRDP.DOMAIN, favoriteSecurity.ResolveDomainName());
            AppendPropertyLine(fileContent, ImportRDP.COLORS, ConvertToColorBits(favorite.Colors).ToString());
            AppendPropertyLine(fileContent, ImportRDP.SCREENMODE, ConvertDesktopSize(favorite.DesktopSize));
            AppendPropertyLine(fileContent, ImportRDP.CONNECTTOCONSOLE, ConvertToString(favorite.ConnectToConsole));
            AppendPropertyLine(fileContent, ImportRDP.DISABLEWALLPAPER, ConvertToString(favorite.DisableWallPaper));
            AppendPropertyLine(fileContent, ImportRDP.REDIRECTSMARTCARDS, ConvertToString(favorite.RedirectSmartCards));
            AppendPropertyLine(fileContent, ImportRDP.REDIRECTCOMPORTS, ConvertToString(favorite.RedirectPorts));
            AppendPropertyLine(fileContent, ImportRDP.REDIRECTPRINTERS, ConvertToString(favorite.RedirectPrinters));
            AppendPropertyLine(fileContent, ImportRDP.TSGHOSTNAME, favorite.TsgwHostname);
            AppendPropertyLine(fileContent, ImportRDP.TSGUSAGEMETHOD, favorite.TsgwUsageMethod.ToString());
            AppendPropertyLine(fileContent, ImportRDP.AUDIOMODE, ConvertFromSounds(favorite.Sounds).ToString());
            AppendPropertyLine(fileContent, ImportRDP.ENABLECOMPRESSION, ConvertToString(favorite.EnableCompression));
            AppendPropertyLine(fileContent, ImportRDP.ENABLEFONTSMOOTHING, ConvertToString(favorite.EnableFontSmoothing));
            AppendPropertyLine(fileContent, ImportRDP.REDIRECTCLIPBOARD, ConvertToString(favorite.RedirectClipboard));
            AppendPropertyLine(fileContent, ImportRDP.DISABLEWINDOWSKEY, ConvertToString(favorite.DisableWindowsKey));
            AppendPropertyLine(fileContent, ImportRDP.DISPLAYCONNECTIONBAR, ConvertToString(favorite.DisplayConnectionBar));
            AppendPropertyLine(fileContent, ImportRDP.DISABLEMENUANIMATIONS, ConvertToString(favorite.DisableMenuAnimations));
            AppendPropertyLine(fileContent, ImportRDP.DISABLETHEMING, ConvertToString(favorite.DisableTheming));
            AppendPropertyLine(fileContent, ImportRDP.DISABLEFULLWINDOWDRAG, ConvertToString(favorite.DisableFullWindowDrag));
            AppendPropertyLine(fileContent, ImportRDP.ENABLEDESKTOPCOMPOSITION, ConvertToString(favorite.EnableDesktopComposition));
            bool disablecursorsettings = favorite.DisableCursorBlinking && favorite.DisableCursorShadow;

            AppendPropertyLine(fileContent, ImportRDP.DISABLECURSORSETTING, ConvertToString(disablecursorsettings));
            AppendPropertyLine(fileContent, ImportRDP.BITMAPPERISTENCE, ConvertToString(favorite.BitmapPeristence));
            AppendPropertyLine(fileContent, ImportRDP.REDIRECTDEVICES, ConvertToString(favorite.RedirectDevices));
            AppendPropertyLine(fileContent, ImportRDP.TSGWCREDSSOURCE, favorite.TsgwCredsSource.ToString());
            AppendPropertyLine(fileContent, ImportRDP.LOADBALANCEINFO, favorite.LoadBalanceInfo);

            return(fileContent.ToString());
        }
示例#12
0
        private FavoriteConfigurationElement ConvertVRDConnectionToLocal(Dictionary <string, vRDConfigurationFileCredentialsFolderCredentials> credentials, vRdImport.Connection con)
        {
            FavoriteConfigurationElement fav = new FavoriteConfigurationElement();
            var security = new FavoriteConfigurationSecurity(this.persistence, fav);

            fav.ServerName = con.ServerName;

            int p = 3389;

            int.TryParse(con.Port, out p);
            fav.Port = p;

            if (credentials.ContainsKey(con.Credentials))
            {
                fav.Credential    = credentials[con.Credentials].Name;
                fav.UserName      = credentials[con.Credentials].UserName;
                fav.DomainName    = credentials[con.Credentials].Domain;
                security.Password = credentials[con.Credentials].Password;
            }

            switch (con.ColorDepth)
            {
            case "8":
                fav.Colors = Colors.Bits8;
                break;

            case "16":
                fav.Colors = Colors.Bit16;
                break;

            case "24":
                fav.Colors = Colors.Bits24;
                break;

            case "32":
                fav.Colors = Colors.Bits32;
                break;

            default:
                fav.Colors = Colors.Bit16;
                break;
            }
            ;

            fav.DesktopSize = DesktopSize.AutoScale;
            if (con.SeparateWindow == "true")
            {
                fav.DesktopSize = DesktopSize.FullScreen;
            }

            fav.ConnectToConsole = false;
            if (con.Console == "true")
            {
                fav.ConnectToConsole = true;
            }

            fav.DisableWallPaper = false;
            if (con.BitmapCaching == "false")
            {
                fav.DisableWallPaper = true;
            }

            fav.RedirectSmartCards = false;
            if (con.SmartCard == "true")
            {
                fav.RedirectSmartCards = true;
            }

            fav.RedirectPorts = false;
            //if (pValue == "1") fav.RedirectPorts = true;

            fav.RedirectPrinters = false;
            if (con.Printer == "true")
            {
                fav.RedirectPrinters = true;
            }

            fav.Sounds = ImportRDP.ConvertToSounds(con.Audio);
            fav.Name   = con.Name;

            return(fav);
        }
        public void WithCredential_ResolveUserName_ReturnsCredentialUserName()
        {
            FavoriteConfigurationSecurity favoriteSecurity = this.CreateFavoriteConfigurationSecurity();

            Assert.AreEqual(EXPECTED_USER, favoriteSecurity.ResolveUserName(), "UserName is primary resolved from Credential.");
        }
示例#14
0
 internal void SetNewCurrent()
 {
     this.Current = new FavoriteConfigurationElement();
     this.Favorites.Add(this.Current);
     this.favoriteSecurity = new FavoriteConfigurationSecurity(this.persistence, this.Current);
 }