public ConfigOverlayEventArgs(PublicConfiguration config, Overlay overlay) : base(overlay) { this.MinPasswordLength = config.MinPasswordLength; this.ForceSymbols = config.ForceSymbols; this.ForceDigits = config.ForceDigits; this.ForceMixCase = config.ForceMixCase; }
public Extension(XElement xml, CloudService parent) { Contract.Requires(parent != null); xml.HydrateObject(XmlNamespaces.WindowsAzure, this); PublicConfiguration = PublicConfiguration.FromBase64String(); PrivateConfiguration = PrivateConfiguration.FromBase64String(); Parent = parent; }
private void AreEqual(PublicConfiguration exp, PublicConfiguration act) { if (exp is PublicMonitoringConfiguration) { var expMonConfig = exp as PublicMonitoringConfiguration; var actMonConfig = act as PublicMonitoringConfiguration; AreEqual(expMonConfig.DiagnosticMonitorConfiguration, actMonConfig.DiagnosticMonitorConfiguration); AreEqual(expMonConfig.LocalResourceDirectory, actMonConfig.LocalResourceDirectory); Assert.Equal(expMonConfig.StorageAccount, actMonConfig.StorageAccount); } }
protected override void ValidateConfiguration() { using (StreamReader sr = new StreamReader(DiagnosticsConfigurationPath)) { string header = sr.ReadLine(); // make sure it is the header if (!header.Trim().StartsWith("<?xml")) { throw new ArgumentException(Resources.PaaSDiagnosticsWrongHeader); } PublicConfiguration = sr.ReadToEnd(); } // the element <StorageAccount> is not meant to be set by teh user in the public config. // Make sure it matches the storage account in the private config. XmlDocument doc = new XmlDocument(); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("ns", XmlNamespace); doc.Load(DiagnosticsConfigurationPath); var node = doc.SelectSingleNode("//ns:StorageAccount", ns); if (node != null) { if (node.InnerText == null) { throw new ArgumentException(Resources.PaaSDiagnosticsNullStorageAccount); } if (string.Compare(node.InnerText, StorageContext.StorageAccountName, true) != 0) { throw new ArgumentException(Resources.PassDiagnosticsNoMatchStorageAccount); } } else { // the StorageAccount is not there. we must set it string storageAccountElem = "\n<StorageAccount>" + StorageContext.StorageAccountName + "</StorageAccount>\n"; // insert it after </WadCfg> int wadCfgEndIndex = PublicConfiguration.IndexOf("</WadCfg>"); PublicConfiguration = PublicConfiguration.Insert(wadCfgEndIndex + "</WadCfg>".Length, storageAccountElem); } PrivateConfigurationXml = new XDocument(PrivateConfigurationXmlTemplate); SetPrivateConfigAttribute(StorageAccountElemStr, PrivConfNameAttr, StorageContext.StorageAccountName); SetPrivateConfigAttribute(StorageAccountElemStr, PrivConfKeyAttr, StorageKey); SetPrivateConfigAttribute(StorageAccountElemStr, PrivConfEndpointAttr, Endpoint); PrivateConfiguration = PrivateConfigurationXml.ToString(); }
public override async Task HoldFocus() { // Request server configuration this.config = await this.Rpc.Event(LoginEvents.Configuration).Request <PublicConfiguration>(); // Update local configuration on server configuration change this.Rpc.Event(LoginEvents.Configuration).On <PublicConfiguration>((e, c) => this.config = c); // Create overlay this.overlay = new LoginOverlay(this.OverlayManager); // Hide HUD Screen.Hud.IsVisible = false; // Disable the loading screen from automatically being dismissed API.SetManualShutdownLoadingScreenNui(true); // Position character, required for switching Game.Player.Character.Position = Vector3.Zero; // Freeze Game.Player.Freeze(); // Switch out the player if it isn't already in a switch state if (!API.IsPlayerSwitchInProgress()) { API.SwitchOutPlayer(API.PlayerPedId(), 0, 1); } // Remove most clouds API.SetCloudHatOpacity(0.01f); // Wait for switch while (API.GetPlayerSwitchState() != 5) { await Delay(10); } // Hide loading screen API.ShutdownLoadingScreen(); // Fade out Screen.Fading.FadeOut(0); while (Screen.Fading.IsFadingOut) { await Delay(10); } // Show the overlay this.overlay.Configure(this.config); this.overlay.SwitchToForm(Forms.Login); this.overlay.Login += OnLogin; this.overlay.Register += OnRegister; this.overlay.Show(); // Let server know we started authentication process this.Rpc.Event(LoginEvents.AuthenticationStarted).Trigger(); // Focus overlay API.SetNuiFocus(true, true); // Shut down the NUI loading screen API.ShutdownLoadingScreenNui(); // Fade in Screen.Fading.FadeIn(500); while (Screen.Fading.IsFadingIn) { await Delay(10); } }
public void Configure(PublicConfiguration config) { Send("config", new ConfigOverlayEventArgs(config, this)); }
protected override void ValidateConfiguration() { using (StreamReader sr = new StreamReader(DiagnosticsConfigurationPath)) { string header = sr.ReadLine(); // make sure it is the header if (!header.Trim().StartsWith("<?xml")) { throw new ArgumentException(Resources.DiagnosticsExtensionWrongHeader); } } var publicConfigElem = DiagnosticsHelper.GetPublicConfigXElementFromXmlFile(this.DiagnosticsConfigurationPath); if (publicConfigElem == null) { throw new ArgumentException(Resources.DiagnosticsExtensionNullPublicConfig); } publicConfigElem.SetAttributeValue("xmlns", XmlNamespace); PublicConfiguration = publicConfigElem.ToString(); // The element <StorageAccount> is not meant to be set by the user in the public config. // Make sure it matches the storage account in the private config. XmlDocument doc = new XmlDocument(); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("ns", XmlNamespace); doc.Load(DiagnosticsConfigurationPath); var node = doc.SelectSingleNode("//ns:StorageAccount", ns); if (node != null) { // The StorageAccount is empty, we must set it if (string.IsNullOrEmpty(node.InnerText)) { var insertIndex = PublicConfiguration.IndexOf("</StorageAccount>"); PublicConfiguration = PublicConfiguration.Insert(insertIndex, StorageAccountName); } else if (!string.IsNullOrEmpty(node.InnerText) && string.Compare(node.InnerText, StorageAccountName, true) != 0) { throw new ArgumentException(Resources.DiagnosticsExtensionNoMatchStorageAccount); } } else { // the StorageAccount is not there. we must set it string storageAccountElem = "\n<StorageAccount>" + StorageAccountName + "</StorageAccount>\n"; // insert it after </WadCfg> int wadCfgEndIndex = PublicConfiguration.IndexOf("</WadCfg>"); PublicConfiguration = PublicConfiguration.Insert(wadCfgEndIndex + "</WadCfg>".Length, storageAccountElem); } // Make sure the storage account name in PrivateConfig matches. var privateConfigStorageAccountName = DiagnosticsHelper.GetStorageAccountInfoFromPrivateConfig(this.DiagnosticsConfigurationPath, DiagnosticsHelper.PrivConfNameAttr); if (!string.IsNullOrEmpty(privateConfigStorageAccountName) && !string.Equals(StorageAccountName, privateConfigStorageAccountName, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(Resources.DiagnosticsExtensionNoMatchPrivateStorageAccount); } PrivateConfigurationXml = new XDocument(PrivateConfigurationXmlTemplate); SetPrivateConfigAttribute(DiagnosticsHelper.StorageAccountElemStr, DiagnosticsHelper.PrivConfNameAttr, StorageAccountName); SetPrivateConfigAttribute(DiagnosticsHelper.StorageAccountElemStr, DiagnosticsHelper.PrivConfKeyAttr, StorageAccountKey); SetPrivateConfigAttribute(DiagnosticsHelper.StorageAccountElemStr, DiagnosticsHelper.PrivConfEndpointAttr, StorageAccountEndpoint); PrivateConfiguration = PrivateConfigurationXml.ToString(); }
public LoginOverlay(OverlayManager manager, PublicConfiguration config) : base("LoginOverlay.html", manager) { Attach("load", (_, callback) => Send("config", config)); Attach <Credentials>("login", (credentials, callback) => this.Login?.Invoke(this, new CredentialsOverlayEventArgs(this, credentials, callback))); Attach <Credentials>("register", (credentials, callback) => this.Register?.Invoke(this, new CredentialsOverlayEventArgs(this, credentials, callback))); }