/// <summary> /// Updates the specified application including both, metadata information /// and fields. /// </summary> /// <param name="appConfig">Configuration information used to update the application.</param> /// <param name="recreate">Value indicating wheter to recreate the application.</param> public static void UpdateApplication(SSOAppConfig appConfig, bool recreate) { using (TransactionScope transactionScope = new TransactionScope()) { // create SSO objects ISSOAdmin2 ssoAdmin = new ISSOAdmin2(); ISSOConfigStore ssoConfigStore = new ISSOConfigStore(); // enlist them in the transaction SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current); SSOManager.Enlist(ssoConfigStore as IPropertyBag, Transaction.Current); // check if the application needs to be recreated or just updated if (recreate == true) { // delete and recreate SSOManager.DeleteApplication(ssoAdmin, appConfig.AppInfo.Name); SSOManager.CreateApplication(ssoAdmin, appConfig); } else { // just update the application metadata SSOManager.UpdateApplicationInfo(ssoAdmin, appConfig.AppInfo); } // update the application fields ssoConfigStore.SetConfigInfo(appConfig.AppInfo.Name, SSOManager.ConfigIdentifier, appConfig.AppFields); // commit the transaction transactionScope.Complete(); } }
/// <summary> /// Imports the specified file containing an XML configuration of the SSO application. /// </summary> /// <param name="filePath">Import file path.</param> /// <param name="overrideApp">Value indicating whether to override the application if it already exists.</param> /// <returns><b>true</b> if the application imported successfully; otherwise <b>false</b>.</returns> public static bool ImportApplication(string filePath, bool overrideApp) { // load the app configuration from the file SSOAppConfig appConfig = XmlSerializationUtil.LoadXml <SSOAppConfig>(filePath); // check if the application already exists if (SSOManager.ApplicationExists(appConfig.AppInfo.Name) == true) { if (overrideApp == true) { // update/recreate the application SSOManager.UpdateApplication(appConfig, true); } else { return(false); } } else { // create a new application SSOManager.CreateApplication(appConfig); } return(true); }
/// <summary> /// Creates a new application in the SSO store using specified /// the configuration information. Creates both, the application /// and fields. /// </summary> /// <param name="appConfig">Configuration information used to create the application.</param> public static void CreateApplication(SSOAppConfig appConfig) { // create a transaction using (TransactionScope transactionScope = new TransactionScope()) { // create SSO objects ISSOAdmin2 ssoAdmin = new ISSOAdmin2(); // enlist them in the transaction SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current); // create the sso application SSOManager.CreateApplication(ssoAdmin, appConfig); // commit the transaction transactionScope.Complete(); } // update the application fields ISSOConfigStore ssoConfigStore = new ISSOConfigStore(); //SSO.Enlist(ssoConfigStore as IPropertyBag, Transaction.Current); ssoConfigStore.SetConfigInfo(appConfig.AppInfo.Name, SSOManager.ConfigIdentifier, appConfig.AppFields); }