private void btnCreate_Click(object sender, System.EventArgs e) { try { // create a new instance of an application configuration SSOAppConfig appConfig = new SSOAppConfig(); appConfig.AppInfo.Enabled = true; // update the application metadata information with the data entered by the user foreach (AppWizardStep step in this.steps) { step.Update(appConfig.AppInfo); } // create the application SSOManager.CreateApplication(appConfig); } catch (Exception ex) { MsgBoxUtil.Show(this, ex); } }
private static bool Import(string[] args) { // validate arguments string suppressConfirm = string.Empty; string fileName = string.Empty; if (args.Length == 2) { fileName = args[1]; } else if (args.Length == 3) { suppressConfirm = args[1]; fileName = args[2]; } else { Console.WriteLine("ERROR - Invalid number of arguments."); Console.WriteLine(); return(false); } // validate suppress confirm if (string.IsNullOrEmpty(suppressConfirm) == false && suppressConfirm.ToLower() != "/y") { Console.WriteLine("ERROR - Invalid option."); Console.WriteLine(); return(false); } // validate file name if (File.Exists(fileName) == false) { Console.WriteLine("ERROR - The specified SSO application configuration file does not exist."); Console.WriteLine(); return(false); } // import the SSO application configuration file try { // load the app configuration from the file SSOAppConfig appConfig = XmlSerializationUtil.LoadXml <SSOAppConfig>(fileName); // check if the application already exists if (SSOManager.ApplicationExists(appConfig.AppInfo.Name) == true) { bool overrideApp = true; // the application exists, ask the user for confirmation to override // if confirmation was not suppressed if (string.IsNullOrEmpty(suppressConfirm) == true) { Console.WriteLine("SSO application already exists. Override (Y/N)?"); int key = Console.Read(); char ch = Convert.ToChar(key); overrideApp = (ch == 'y' || ch == 'Y'); } if (overrideApp == true) { // update/recreate the application SSOManager.UpdateApplication(appConfig, true); Console.WriteLine("SSO application successfully imported."); } } else { // create a new application SSOManager.CreateApplication(appConfig); Console.WriteLine("SSO application successfully imported."); } return(true); } catch (Exception ex) { Console.WriteLine("ERROR - An error has occurred importing the SSO application."); Console.WriteLine(""); Console.WriteLine(ex); return(false); } }