/// <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> /// 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> /// Exports the specified SSO application into the specified file in XML format. /// </summary> /// <param name="appName">The name of the application to be deleted.</param> /// <param name="filePath">Export file path.</param> public static void ExportApplication(string appName, string filePath) { // load the specified SSO application configuration SSOAppConfig appConfig = SSOManager.GetApplicationConfig(appName); // save it into the specified file XmlSerializationUtil.SaveXml(appConfig, filePath); }
/// <summary> /// Retrieves the specified application configuration from the SSO store, /// including both, the application metadata information and the application /// fields. /// </summary> /// <param name="appName">The name of the application to retrieve.</param> /// <returns>The instance of the SSOAppConfig.</returns> public static SSOAppConfig GetApplicationConfig(string appName) { return(new SSOAppConfig() { AppInfo = SSOManager.GetApplicationInfo(appName), AppFields = SSOManager.GetApplicationFields(appName) }); }
/// <summary> /// Deletes the specified application. /// </summary> /// <param name="appName">The name of the application to be deleted.</param> public static void DeleteApplication(string appName) { using (TransactionScope transactionScope = new TransactionScope()) { ISSOAdmin2 ssoAdmin = new ISSOAdmin2(); SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current); SSOManager.DeleteApplication(ssoAdmin, appName); transactionScope.Complete(); } }
public static void UpdateApplicationFields(string appName, SSOAppFieldCollection appFields, bool recreate) { if (recreate == true) { SSOAppConfig appConfig = new SSOAppConfig() { // load the current application metadata information AppInfo = SSOManager.GetApplicationInfo(appName), // and use the application fields provided AppFields = appFields }; // update/recreate the application including the fields SSOManager.UpdateApplication(appConfig, true); } else { // just update the application fields ISSOConfigStore ssoConfigStore = new ISSOConfigStore(); ssoConfigStore.SetConfigInfo(appName, SSOManager.ConfigIdentifier, appFields); } }
/// <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); }
static SSOManager() { SSOManager.DefaultContact = string.Format(SSOManager.CONTACT_INFO_FORMAT, ConfigurationManager.AppSettings["CompanyName"]); SSOManager.LoadSSOServerInfo(); }
/// <summary> /// Updates the application metadata information. /// </summary> /// <param name="appInfo">Application metadata information.</param> public static void UpdateApplicationInfo(SSOAppInfo appInfo) { ISSOAdmin2 ssoAdmin = new ISSOAdmin2(); SSOManager.UpdateApplicationInfo(ssoAdmin, appInfo); }
/// <summary> /// Checks whether the specified application exists. /// </summary> /// <param name="appName">The name of the application.</param> /// <returns><b>true</b> if the application exists; otherwise <b>false</b>.</returns> public static bool ApplicationExists(string appName) { SSOAppInfo appInfo = SSOManager.GetApplicationInfo(appName); return(appInfo != null); }