示例#1
0
 private void btRefresh_Click(object sender, RoutedEventArgs e)
 {
     this.cbAutoPopulateSSOGroups.IsChecked = false;
     this.tbSSOAdminGrp.Text         = "";
     this.tbSSOAffliateAdminGrp.Text = "";
     if (!(this.tbApplicationName.Text != string.Empty))
     {
         return;
     }
     try
     {
         string           description;
         string           contactInfo;
         string           appUserAcct;
         string           appAdminAcct;
         HybridDictionary configProperties = SSOConfigManager.GetConfigProperties(this.tbApplicationName.Text, out description, out contactInfo, out appUserAcct, out appAdminAcct);
         this.tbApplicationDescription.Text = description;
         this.tbSSOAdminGrp.Text            = appAdminAcct;
         this.tbSSOAffliateAdminGrp.Text    = appUserAcct;
         this.dgvKeyValue.Rows.Clear();
         foreach (DictionaryEntry dictionaryEntry in configProperties)
         {
             DataGridViewRow row = this.dgvKeyValue.Rows[this.dgvKeyValue.Rows.Add()];
             row.Cells["clKeyName"].Value = (object)dictionaryEntry.Key.ToString();
             row.Cells["clValue"].Value   = (object)dictionaryEntry.Value.ToString();
             row.Cells["clIsMask"].Value  = (object)"Yes";
         }
     }
     catch (Exception ex)
     {
         int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured. Details: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
示例#2
0
        private bool ExportXmlConfigurationByApplication(string appName, string path, string guid)
        {
            string           appUserAcct      = "";
            string           appAdminAcct     = "";
            string           description      = "";
            string           contactInfo      = "";
            HybridDictionary hybridDictionary = new HybridDictionary();

            if (appName != string.Empty)
            {
                try
                {
                    HybridDictionary configProperties = SSOConfigManager.GetConfigProperties(appName, out description, out contactInfo, out appUserAcct, out appAdminAcct);
                    XmlTextWriter    xmlTextWriter    = new XmlTextWriter(path + "\\SSO_" + appName + "_" + guid + ".xml", Encoding.UTF8);
                    xmlTextWriter.WriteStartDocument();
                    xmlTextWriter.WriteStartElement("sso");
                    xmlTextWriter.WriteStartElement("application");
                    xmlTextWriter.WriteAttributeString("name", appName);
                    xmlTextWriter.WriteElementString("description", description);
                    xmlTextWriter.WriteElementString("appUserAccount", appAdminAcct);
                    xmlTextWriter.WriteElementString("appAdminAccount", appUserAcct);
                    int       num       = 0;
                    ArrayList arrayList = new ArrayList();
                    foreach (DictionaryEntry dictionaryEntry in configProperties)
                    {
                        xmlTextWriter.WriteStartElement("field");
                        xmlTextWriter.WriteAttributeString("ordinal", num.ToString());
                        xmlTextWriter.WriteAttributeString("label", dictionaryEntry.Key.ToString());
                        xmlTextWriter.WriteAttributeString("masked", "yes");
                        xmlTextWriter.WriteString(dictionaryEntry.Value.ToString());
                        xmlTextWriter.WriteEndElement();
                        arrayList.Add((object)dictionaryEntry.Value.ToString());
                        ++num;
                    }
                    xmlTextWriter.WriteStartElement("flags");
                    xmlTextWriter.WriteAttributeString("configStoreApp", "yes");
                    xmlTextWriter.WriteAttributeString("allowLocalAccounts", "yes");
                    xmlTextWriter.WriteAttributeString("enableApp", "yes");
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.Flush();
                    xmlTextWriter.Close();
                    return(true);
                }
                catch (Exception ex)
                {
                    int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured. Details: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            return(false);
        }
示例#3
0
        private void btBrowseApps_Click(object sender, RoutedEventArgs e)
        {
            this.initializeFields();
            SelectApp selectApp = new SelectApp();

            selectApp.SetListBoxSelectMode = System.Windows.Forms.SelectionMode.One;
            if (selectApp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.tbApplicationName.Text = selectApp.ApplicationName;
                string text = this.tbApplicationName.Text;
                if (text != string.Empty)
                {
                    try
                    {
                        string           description;
                        string           contactInfo;
                        string           appUserAcct;
                        string           appAdminAcct;
                        HybridDictionary configProperties = SSOConfigManager.GetConfigProperties(text, out description, out contactInfo, out appUserAcct, out appAdminAcct);
                        this.tbApplicationDescription.Text = description;
                        this.tbSSOAdminGrp.Text            = appAdminAcct;
                        this.tbSSOAffliateAdminGrp.Text    = appUserAcct;
                        foreach (DictionaryEntry dictionaryEntry in configProperties)
                        {
                            DataGridViewRow row = this.dgvKeyValue.Rows[this.dgvKeyValue.Rows.Add()];
                            row.Cells["clKeyName"].Value = (object)dictionaryEntry.Key.ToString();
                            row.Cells["clValue"].Value   = (object)dictionaryEntry.Value.ToString();
                            row.Cells["clIsMask"].Value  = (object)"Yes";
                        }
                    }
                    catch (Exception ex)
                    {
                        int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured. Details: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                else
                {
                    int num1 = (int)System.Windows.Forms.MessageBox.Show("Please enter application name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            selectApp.Close();
        }
示例#4
0
文件: SelectApp.cs 项目: manjzu/BTSSO
 private void SelectApp_Load(object sender, EventArgs e)
 {
     this.apps = SSOConfigManager.GetApplications();
     if (this.apps.Count - this.apps.Where <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(x => x.Key.StartsWith("{"))).Count <KeyValuePair <string, string> >() == 0)
     {
         this.btnOk.Enabled = false;
         this.listboxApplications.Items.Add((object)"No applications found.");
     }
     else
     {
         this.listboxApplications.BeginUpdate();
         foreach (string key in (IEnumerable <string>) this.apps.Keys)
         {
             if (!key.StartsWith("{"))
             {
                 this.listboxApplications.Items.Add((object)key);
             }
         }
         this.listboxApplications.EndUpdate();
     }
 }
示例#5
0
        private void btCreate_Click(object sender, RoutedEventArgs e)
        {
            if (this.tbApplicationName.Text != string.Empty)
            {
                //Try-Catch is uplifted to handle - Duplicate Key value pair
                try
                {
                    SSOPropBag ssoPropBag = new SSOPropBag();
                    ArrayList  maskArray  = new ArrayList();
                    foreach (DataGridViewRow row in (IEnumerable)this.dgvKeyValue.Rows)
                    {
                        if (row.Cells["clKeyName"].Value != null && row.Cells["clKeyName"].Value.ToString() != string.Empty)
                        {
                            object ptrVar = row.Cells["clValue"].Value;
                            ssoPropBag.Write(row.Cells["clKeyName"].Value.ToString(), ref ptrVar);
                            if (row.Cells["clIsMask"].FormattedValue.ToString().ToLower() == "yes")
                            {
                                maskArray.Add((object)268435456);
                            }
                            else
                            {
                                maskArray.Add((object)0);
                            }
                        }
                    }

                    SSOConfigManager.CreateConfigStoreApplication(this.tbApplicationName.Text, this.tbApplicationDescription.Text, this.tbSSOAffliateAdminGrp.Text, this.tbSSOAdminGrp.Text, ssoPropBag, maskArray);
                    SSOConfigManager.SetConfigProperties(this.tbApplicationName.Text, ssoPropBag);
                    int num = (int)System.Windows.Forms.MessageBox.Show("Application Successfully Created", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch (Exception ex)
                {
                    int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured.  Details: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else
            {
                int num1 = (int)System.Windows.Forms.MessageBox.Show("Application name is required.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#6
0
 private void btDelete_Click(object sender, RoutedEventArgs e)
 {
     if (this.tbApplicationName.Text != null || this.tbApplicationName.Text != string.Empty)
     {
         if (System.Windows.Forms.MessageBox.Show("Are you sure you wish to delete this application? All its settings will be lost.", "Warning", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
         {
             return;
         }
         try
         {
             SSOConfigManager.DeleteApplication(this.tbApplicationName.Text);
             int num = (int)System.Windows.Forms.MessageBox.Show("Application deleted.", "Information", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
         }
         catch (Exception ex)
         {
             int num = (int)System.Windows.Forms.MessageBox.Show("Error Occured.  Details: " + ex.ToString(), "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
         }
     }
     else
     {
         int num1 = (int)System.Windows.Forms.MessageBox.Show("Please enter an application name for deletion.", "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
     }
 }
示例#7
0
        private void btModify_Click(object sender, RoutedEventArgs e)
        {
            SSOPropBag ssoPropBag = new SSOPropBag();
            ArrayList  maskArray  = new ArrayList();

            //Try-Catch is added to handle - Duplicate Key value pair
            try
            {
                foreach (DataGridViewRow row in (IEnumerable)this.dgvKeyValue.Rows)
                {
                    if (row.Cells["clKeyName"].Value != null && row.Cells["clKeyName"].Value.ToString() != string.Empty)
                    {
                        string propName = row.Cells["clKeyName"].Value.ToString();
                        object ptrVar   = (object)row.Cells["clValue"].Value.ToString();
                        ssoPropBag.Write(propName, ref ptrVar);
                        if (row.Cells["clIsMask"].FormattedValue.ToString().ToLower() == "yes")
                        {
                            maskArray.Add((object)268435456);
                        }
                        else
                        {
                            maskArray.Add((object)0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                int num = (int)System.Windows.Forms.MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            string           str1   = "";
            string           str2   = "";
            bool             flag1  = false;
            string           empty1 = string.Empty;
            string           empty2 = string.Empty;
            string           empty3 = string.Empty;
            string           description;
            string           contactInfo;
            string           appUserAcct;
            string           appAdminAcct;
            HybridDictionary configProperties = SSOConfigManager.GetConfigProperties(this.tbApplicationName.Text, out description, out contactInfo, out appUserAcct, out appAdminAcct);
            string           str3             = string.Empty;

            if (description != this.tbApplicationDescription.Text)
            {
                str3 = "Application description, ";
            }
            else if (appUserAcct != this.tbSSOAffliateAdminGrp.Text)
            {
                str3 += "SSO User Group, ";
            }
            else if (appAdminAcct != this.tbSSOAdminGrp.Text)
            {
                str3 += "SSO Admin Group";
            }
            if (str3 != string.Empty)
            {
                str1 = System.Windows.Forms.MessageBox.Show("Are you sure wish to modify: " + str3, "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE";
            }
            if (str1 != "DONTCHANGE")
            {
                foreach (DictionaryEntry property in ssoPropBag.properties)
                {
                    bool flag2 = false;
                    bool flag3 = false;
                    foreach (DictionaryEntry dictionaryEntry in configProperties)
                    {
                        if (dictionaryEntry.Key.ToString() == property.Key.ToString())
                        {
                            flag2 = true;
                            if (dictionaryEntry.Value.ToString() == property.Value.ToString())
                            {
                                flag3 = true;
                            }
                        }
                    }
                    empty1 += !flag2?property.Key.ToString() + ", " : "";

                    empty3 += !flag3?property.Key.ToString() + ", " : "";
                }
                foreach (DictionaryEntry dictionaryEntry in configProperties)
                {
                    bool flag2 = false;
                    flag1 = false;
                    foreach (DictionaryEntry property in ssoPropBag.properties)
                    {
                        if (dictionaryEntry.Key.ToString() == property.Key.ToString())
                        {
                            flag2 = true;
                        }
                    }
                    empty2 += !flag2?dictionaryEntry.Key.ToString() + ", " : "";
                }
                string str4 = empty2.TrimEnd(',', ' ');
                string str5 = empty1.TrimEnd(',', ' ');
                string str6 = empty3.TrimEnd(',', ' ');
                if (str5 != string.Empty && str4 != string.Empty)
                {
                    str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Add field/s' (" + str5 + ") and Delete field/s' (" + str4 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE";
                }
                else if (str5 != string.Empty)
                {
                    str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Add field/s' (" + str5 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE";
                }
                else if (str4 != string.Empty)
                {
                    str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Delete field/s' (" + str4 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE";
                }
                else if (str6 != string.Empty)
                {
                    str2 = System.Windows.Forms.MessageBox.Show("Are you sure wish to Update field/s' (" + str6 + ") to this application? Existing settings will be overwritten.", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK ? "CHANGE" : "DONTCHANGE";
                }
                try
                {
                    if ((str2 == "CHANGE" || str1 == "CHANGE") && str2 != "DONTCHANGE")
                    {
                        SSOConfigManager.DeleteApplication(this.tbApplicationName.Text);
                        SSOConfigManager.CreateConfigStoreApplication(this.tbApplicationName.Text, this.tbApplicationDescription.Text, this.tbSSOAffliateAdminGrp.Text, this.tbSSOAdminGrp.Text, ssoPropBag, maskArray);
                        SSOConfigManager.SetConfigProperties(this.tbApplicationName.Text, ssoPropBag);
                        if (str6 != string.Empty && str1 == "")
                        {
                            int num1 = (int)System.Windows.Forms.MessageBox.Show("Only field values are updated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else if (str6 != string.Empty && str1 == "CHANGE")
                        {
                            int num2 = (int)System.Windows.Forms.MessageBox.Show("User details and Only field values are updated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            int num3 = (int)System.Windows.Forms.MessageBox.Show("Application successfully modified.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                    else
                    {
                        int num = (int)System.Windows.Forms.MessageBox.Show("No field values are updated.", "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    int num = (int)System.Windows.Forms.MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else
            {
                int num4 = (int)System.Windows.Forms.MessageBox.Show("No field values are updated.", "Exclamation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }