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); } }
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) )); }
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()); }
public void WithCredential_ResolveUserName_ReturnsCredentialUserName() { FavoriteConfigurationSecurity favoriteSecurity = this.CreateFavoriteConfigurationSecurity(); Assert.AreEqual(EXPECTED_USER, favoriteSecurity.ResolveUserName(), "UserName is primary resolved from Credential."); }