コード例 #1
0
        public static bool ExportSSOApplication(string appName, string encryptionKey, ApplicationScopeNode currentNode)
        {
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            string[]      keys           = sSO.GetKeys(appName);
            string[]      values         = sSO.GetValues(appName);
            StringBuilder stringBuilder  = new StringBuilder();

            stringBuilder.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><SSOApplicationExport><applicationData>");
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] != null && !(keys[i] == ""))
                {
                    stringBuilder.Append(string.Concat(new string[]
                    {
                        "<add key=\"",
                        keys[i],
                        "\" value=\"",
                        HttpUtility.HtmlEncode(values[i]),
                        "\" />"
                    }));
                }
            }
            stringBuilder.Append("</applicationData></SSOApplicationExport>");
            bool result;

            using (SaveFileDialog saveFileDialog = new SaveFileDialog())
            {
                saveFileDialog.CheckPathExists = true;
                saveFileDialog.Filter          = "SSO Extract files (*.sso)|*.sso|All files (*.*)|*.*";
                saveFileDialog.DefaultExt      = "*.sso";
                saveFileDialog.FileName        = appName + ".sso";
                saveFileDialog.Title           = "Export SSO Application";
                DialogResult dialogResult = currentNode.SnapIn.Console.ShowDialog(saveFileDialog);
                if (dialogResult != DialogResult.Cancel)
                {
                    StreamWriter streamWriter = new StreamWriter(saveFileDialog.FileName, false);
                    try
                    {
                        streamWriter.Write(bizilante.SSO.Helper.SSO.Encrypt(stringBuilder.ToString(), encryptionKey));
                        streamWriter.Flush();
                    }
                    catch (Exception ex)
                    {
                        EventLog.WriteEntry("SSO MMC SnapIn - ExportSSOApplication \r\n", ex.ToString());
                        result = false;
                        return(result);
                    }
                    finally
                    {
                        streamWriter.Close();
                        streamWriter.Dispose();
                    }
                }
                result = true;
            }
            return(result);
        }
コード例 #2
0
        protected override bool OnShowInitializationWizard()
        {
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            sSO.GetSecretServerName();
            WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            bool             flag             = windowsPrincipal.IsInRole(sSO.SSOAdminGroup);
            bool             flag2            = windowsPrincipal.IsInRole(sSO.AffiliateAppMgrGroup);

            return(flag || flag2);
        }
コード例 #3
0
 private void InitializeRootApplications()
 {
     RootNode.Children.Clear();
     bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
     string[] applications        = sSO.GetApplications();
     for (int i = 0; i < applications.Length; i++)
     {
         ApplicationScopeNode applicationScopeNode = new ApplicationScopeNode(applications[i]);
         applicationScopeNode.ApplicationImported += new EventHandler(this.rootNode_ApplicationImported);
         base.RootNode.Children.Add(applicationScopeNode);
     }
 }
コード例 #4
0
        protected override bool OnOK()
        {
            string scopeNode = this._scopeNode;
            string text      = "";
            string text2     = "";

            this.modifyPropertiesControl.GetKeyValue(out text, out text2);
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            string[] keys   = sSO.GetKeys(scopeNode);
            string[] values = sSO.GetValues(scopeNode);
            string[] array  = new string[keys.Length];
            string[] array2 = new string[values.Length];
            bool     flag   = false;

            if (!(text == "") && !(text2 == ""))
            {
                for (int i = 0; i < keys.Length; i++)
                {
                    if (keys[i] == text)
                    {
                        flag = true;
                    }
                }
                for (int j = 0; j < keys.Length; j++)
                {
                    if (keys[j].ToUpper() == this._currentKeyName.ToUpper())
                    {
                        array[j]  = text;
                        array2[j] = text2;
                    }
                    else
                    {
                        array[j]  = keys[j];
                        array2[j] = values[j];
                    }
                }
                if (flag)
                {
                    if (!(text.ToUpper() == this._currentKeyName.ToUpper()))
                    {
                        this.modifyPropertiesControl.KeyExistException();
                        return(true);
                    }
                    sSO.CreateApplicationFieldsValues(scopeNode, array, array2);
                }
                else
                {
                    sSO.CreateApplicationFieldsValues(scopeNode, array, array2);
                }
            }
            return(this.OnApply());
        }
コード例 #5
0
        protected override void OnSelectionAction(Microsoft.ManagementConsole.Action action, AsyncStatus status)
        {
            string a;

            if ((a = (string)action.Tag) != null)
            {
                if (a == "Properties")
                {
                    base.SelectionData.ShowPropertySheet("Key/Value Properties");
                    return;
                }
                if (!(a == "Delete"))
                {
                    return;
                }
                StringBuilder stringBuilder = new StringBuilder();
                foreach (ResultNode resultNode in ((IEnumerable)base.SelectedNodes))
                {
                    base.ResultNodes.Remove(resultNode);
                    stringBuilder.Append(resultNode.DisplayName);
                }
                bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
                string[] keys   = sSO.GetKeys(base.ScopeNode.DisplayName);
                string[] values = sSO.GetValues(base.ScopeNode.DisplayName);
                string[] array  = new string[keys.Length - 1];
                string[] array2 = new string[values.Length - 1];
                string   b      = stringBuilder.ToString();
                int      num    = 0;
                if (keys.Length == 1)
                {
                    array     = new string[1];
                    array2    = new string[1];
                    array[0]  = "";
                    array2[0] = "";
                }
                else
                {
                    for (int i = 0; i < keys.Length; i++)
                    {
                        if (!(keys[i] == b))
                        {
                            array[num]  = keys[i];
                            array2[num] = values[i];
                            num++;
                        }
                    }
                }
                sSO.CreateApplicationFieldsValues(base.ScopeNode.DisplayName, array, array2);
            }
        }
コード例 #6
0
        protected override void OnRename(string newText, SyncStatus status)
        {
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            string[] applications        = sSO.GetApplications();
            bool     flag = false;

            for (int i = 0; i < applications.Length; i++)
            {
                if (applications[i].ToUpper() == newText.ToUpper())
                {
                    flag = true;
                }
            }
            if (flag)
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Application Already Exists: " + newText;
                messageBoxParameters.Caption = "Add New Application";
                messageBoxParameters.Icon    = MessageBoxIcon.Exclamation;
                base.SnapIn.Console.ShowDialog(messageBoxParameters);
            }
            else
            {
                int count = base.Parent.Children.Count;
                int index = 0;
                for (int j = 0; j < count; j++)
                {
                    if (base.Parent.Children[j].DisplayName == "_NewApplication")
                    {
                        index = j;
                    }
                }
                sSO.DeleteApplication(base.Parent.Children[index].DisplayName);
                base.Parent.Children[index].DisplayName             = newText;
                base.Parent.Children[index].LanguageIndependentName = newText;
                base.Parent.Children[index].EnabledStandardVerbs    = StandardVerbs.None;
                string[] array  = new string[1];
                string[] array2 = new string[1];
                array[0]  = "";
                array2[0] = "";
                sSO.CreateApplicationFieldsValues(newText, array, array2);
            }
            base.OnRename(newText, status);
        }
コード例 #7
0
        public void Refresh()
        {
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            string displayName           = base.ScopeNode.DisplayName;

            string[] keys   = sSO.GetKeys(displayName);
            string[] values = sSO.GetValues(displayName);
            base.ResultNodes.Clear();
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] != null && !(keys[i] == ""))
                {
                    ResultNode resultNode = new ResultNode();
                    resultNode.DisplayName = keys[i];
                    resultNode.SubItemDisplayNames.Add(values[i]);
                    base.ResultNodes.Add(resultNode);
                }
            }
        }
コード例 #8
0
        protected override bool OnOK()
        {
            bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
            string[] keys   = sSO.GetKeys(this._scopenode);
            string[] values = sSO.GetValues(this._scopenode);
            string[] array  = new string[keys.Length + 1];
            string[] array2 = new string[values.Length + 1];
            string   text;
            string   text2;

            this._add_KeyValue_PropertiesControl.GetKeyValue(out text, out text2);
            if (!this._add_KeyValue_PropertiesControl.CheckText())
            {
                bool flag = false;
                for (int i = 0; i < values.Length; i++)
                {
                    if (keys[i].ToUpper() == text.ToUpper())
                    {
                        flag = true;
                    }
                }
                for (int j = 0; j < values.Length; j++)
                {
                    array[j]  = keys[j];
                    array2[j] = values[j];
                }
                array[keys.Length]    = text;
                array2[values.Length] = text2;
                if (flag)
                {
                    this._add_KeyValue_PropertiesControl.KeyExist(text);
                }
                else
                {
                    sSO.CreateApplicationFieldsValues(this._scopenode, array, array2);
                }
            }
            return(this.OnApply());
        }
コード例 #9
0
 public static void ValidateServerDatabase(NameValueCollection nameValueArgs)
 {
     Trace.WriteLine("Validating Server and Database parameters...");
     if ((nameValueArgs["Server"] != null) && (nameValueArgs["Server"].Length > 0))
     {
         if ((nameValueArgs["Database"] == null) || (nameValueArgs["Database"].Length == 0))
         {
             throw new CommandLineArgumentException(CommandResources.GetString(CommandResources.ResourceID.DatabaseNotSpecified), "Database", System.Diagnostics.TraceLevel.Error);
         }
     }
     else
     {
         bizilante.SSO.Helper.SSO sso = new bizilante.SSO.Helper.SSO();
         sso.GetSecretServerName();
         nameValueArgs.Set("Server", sso.DBServer);
         if ((nameValueArgs["Database"] == null) || (nameValueArgs["Database"].Length == 0))
         {
             nameValueArgs.Set("Database", sso.DB);
         }
     }
     ValidateServer(nameValueArgs["Server"]);
     ValidateDatabase(nameValueArgs["Database"]);
 }
コード例 #10
0
ファイル: SSO.cs プロジェクト: dheerajbhavsar/BizTalk2016
 public SSO(TaskLoggingHelper log, string companyName)
 {
     _log         = log;
     _companyName = companyName;
     _sso         = new bizilante.SSO.Helper.SSO(companyName);
 }
コード例 #11
0
 public static bool ImportSSOApplication(string encryptionKey, string applicationFileName, string encryptedText)
 {
     bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
     return(sSO.ImportSSOApplication(encryptionKey, applicationFileName, encryptedText));
 }
コード例 #12
0
        public bool Execute(out string title)
        {
            title = string.Format("Deploy SSO file '{0}'", this.NonEncryptedFile);

            // Validate the file
            FileInfo info = new FileInfo(this.NonEncryptedFile);

            if (!info.Exists)
            {
                throw new Exception(string.Format("Could not find the specified input file: '{0}'", new object[] { this.NonEncryptedFile }));
            }

            bool        newSSOApp = true;
            XmlDocument document  = new XmlDocument();
            string      appName   = string.Empty;

            // Create the SSO object
            bizilante.SSO.Helper.SSO sso;
            if (!string.IsNullOrEmpty(Timeout))
            {
                sso = new bizilante.SSO.Helper.SSO(int.Parse(Timeout));
            }
            else
            {
                sso = new bizilante.SSO.Helper.SSO();
            }

            // Register the Event handler
            sso.SsoEvent += new EventHandler <bizilante.SSO.Helper.SSOEventArgs>(SSO_Update);

            // Get the name of the SSO application
            appName = Path.GetFileNameWithoutExtension(this.NonEncryptedFile);

            // Check to see if the application is already deployed
            string[] applications = sso.GetApplications();
            for (int i = 0; i < applications.Length; i++)
            {
                if (applications[i].ToUpper() == appName.ToUpper())
                {
                    newSSOApp = false;
                }
            }

            // Load into XmlDOM
            document.Load(this.NonEncryptedFile);

            XmlNodeList   list  = document.DocumentElement.SelectNodes("applicationData/add");
            List <string> list2 = new List <string>();
            List <string> list3 = new List <string>();

            if (!Overwrite)
            {
                // Check to see if we are deploying an existing application (flag = false)
                if (!newSSOApp)
                {
                    list2.AddRange(sso.GetKeys(appName));
                    list3.AddRange(sso.GetValues(appName));
                }
                foreach (XmlNode node in list)
                {
                    string str3 = node.SelectSingleNode("@key").Value;
                    string str4 = node.SelectSingleNode("@value").Value;
                    if ((!string.IsNullOrEmpty(str3) && !string.IsNullOrEmpty(str4)))
                    {
                        // New key value ?
                        if (!list2.Contains(str3))
                        {
                            list2.Add(str3);
                            list3.Add(str4);
                        }
                        else
                        {
                            list3[list2.IndexOf(str3)] = str4;
                        }
                    }
                }
            }
            else
            {
                foreach (XmlNode node in list)
                {
                    string str3 = node.SelectSingleNode("@key").Value;
                    string str4 = node.SelectSingleNode("@value").Value;
                    list2.Add(str3);
                    list3.Add(str4);
                }
            }
            sso.CreateApplicationFieldsValues(appName, list2.ToArray(), list3.ToArray());

            title = appName;
            return(true);
        }
コード例 #13
0
        protected override void OnAction(Microsoft.ManagementConsole.Action action, AsyncStatus status)
        {
            string a;

            if ((a = (string)action.Tag) != null)
            {
                if (a == "Delete")
                {
                    ScopeNode scopeNode = new ScopeNode();
                    scopeNode.DisplayName = base.DisplayName;
                    bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
                    sSO.GetApplications();
                    int index = 0;
                    for (int i = 0; i < base.Parent.Children.Count; i++)
                    {
                        if (Parent.Children[i].DisplayName.ToUpper() == DisplayName.ToUpper())
                        {
                            index = i;
                        }
                    }
                    sSO.DeleteApplication(base.DisplayName);
                    Parent.Children.RemoveAt(index);
                    return;
                }
                if (a == "Add_KeyValue")
                {
                    if (DisplayName.ToUpper() == "_NewApplication".ToUpper())
                    {
                        EnabledStandardVerbs = StandardVerbs.None;
                    }
                    _hasKeyValuePropertyPage = true;
                    ShowPropertySheet("Add Key/Value Pair");
                    OnRefresh(status);
                    base.OnRefresh(status);
                    return;
                }
                if (a == "Add_Application")
                {
                    string[] array  = new string[1];
                    string[] array2 = new string[1];
                    array[0]  = "";
                    array2[0] = "";
                    string text = "_NewApplication";
                    bool   flag = false;
                    bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
                    string[] applications        = sSO.GetApplications();
                    for (int j = 0; j < applications.Length; j++)
                    {
                        if (applications[j].ToUpper() == text.ToUpper())
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                        messageBoxParameters.Text    = "This application already exists";
                        messageBoxParameters.Caption = "Add New Application";
                        messageBoxParameters.Icon    = MessageBoxIcon.Exclamation;
                        SnapIn.Console.ShowDialog(messageBoxParameters);
                    }
                    else
                    {
                        ScopeNode scopeNode2 = new ScopeNode();
                        scopeNode2.DisplayName = "_NewApplication";
                        ScopeNode scopeNode3 = new ScopeNode();
                        Children.Add(scopeNode2);
                        int count = Children.Count;
                        sSO.CreateApplicationFieldsValues("_NewApplication", array, array2);
                        Children[count - 1] = new ApplicationScopeNode("_NewApplication");
                    }
                    base.OnRefresh(status);
                    return;
                }
                if (!(a == "Export"))
                {
                    if (!(a == "Import"))
                    {
                        return;
                    }
                    DialogResult dialogResult = SSOHelper.OpenSSOImportFile(
                        out _applicationFileName,
                        out _encryptedText,
                        this);
                    if (dialogResult != DialogResult.Cancel)
                    {
                        EncryptionKey_PropertyPage encryptionKey_PropertyPage =
                            new EncryptionKey_PropertyPage("Import", _applicationFileName, _encryptedText);
                        encryptionKey_PropertyPage.EncryptionKeyEnteredForImport +=
                            new EventHandler <EventArgs <bool, string> >(propertyPage_EncryptionKeyEnteredForImport);
                        AcceptKeyForImportForm form =
                            new AcceptKeyForImportForm(encryptionKey_PropertyPage);
                        base.SnapIn.Console.ShowDialog(form);
                    }
                    base.OnRefresh(status);
                }
                else
                {
                    EncryptionKey_PropertyPage encryptionKey_PropertyPage2 =
                        new EncryptionKey_PropertyPage("Export", base.DisplayName);
                    AcceptKeyForImportForm form2 = new AcceptKeyForImportForm(encryptionKey_PropertyPage2);
                    base.SnapIn.Console.ShowDialog(form2);
                    if (encryptionKey_PropertyPage2.EncryptionKey != null && encryptionKey_PropertyPage2.EncryptionKey.Length != 0)
                    {
                        if (!SSOHelper.ExportSSOApplication(base.DisplayName, encryptionKey_PropertyPage2.EncryptionKey, this))
                        {
                            MessageBoxParameters messageBoxParameters2 = new MessageBoxParameters();
                            messageBoxParameters2.Text    = "Error exporting the application.  Please check the event log for further information";
                            messageBoxParameters2.Caption = "Export Application Error";
                            messageBoxParameters2.Icon    = MessageBoxIcon.Hand;
                            base.SnapIn.Console.ShowDialog(messageBoxParameters2);
                            return;
                        }
                    }
                }
            }
        }
コード例 #14
0
 public ApplicationScopeNode(string applicationName, bool isRootNode)
 {
     if (!ActionsSnapIn.HasSecurityRights)
     {
         bizilante.SSO.Helper.SSO sSO = new bizilante.SSO.Helper.SSO();
         sSO.GetSecretServerName();
         WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
         _ssoAdminResult = windowsPrincipal.IsInRole(sSO.SSOAdminGroup);
         ActionsSnapIn.HasSecurityRights = _ssoAdminResult;
     }
     if (ActionsSnapIn.HasSecurityRights)
     {
         DisplayName = applicationName;
         if (!isRootNode)
         {
             MmcListViewDescription mmcListViewDescription = new MmcListViewDescription();
             mmcListViewDescription.DisplayName = applicationName;
             mmcListViewDescription.ViewType    = typeof(UserListView);
             mmcListViewDescription.Options     = MmcListViewOptions.SingleSelect;
             ViewDescriptions.Add(mmcListViewDescription);
             ViewDescriptions.DefaultIndex = 0;
         }
         ImageIndex         = 0;
         SelectedImageIndex = 0;
         if (DisplayName == "_NewApplication")
         {
             EnabledStandardVerbs = StandardVerbs.Rename;
         }
         Microsoft.ManagementConsole.Action actionExport =
             new Microsoft.ManagementConsole.Action("Export Application", "Exports the Key/Value Pairs for this application", -1, "Export");
         Microsoft.ManagementConsole.Action actionAdd =
             new Microsoft.ManagementConsole.Action("Add Application", "Adds a new Application", -1, "Add_Application");
         Microsoft.ManagementConsole.Action actionAddKvp =
             new Microsoft.ManagementConsole.Action("Add Key Value Pair", "Adds Key Value Pair", -1, "Add_KeyValue");
         Microsoft.ManagementConsole.Action actionDelete =
             new Microsoft.ManagementConsole.Action("Delete Application", "Deletes the Application", -1, "Delete");
         Microsoft.ManagementConsole.Action actionImport =
             new Microsoft.ManagementConsole.Action("Import Application", "Imports the Key/Value Pairs for an Application", -1, "Import");
         ActionsPaneItems.Add(actionAdd);
         if (isRootNode)
         {
             actionExport.Enabled = false;
         }
         else
         {
             actionAdd.Enabled = false;
             ActionsPaneItems.Add(actionAddKvp);
             ActionsPaneItems.Add(actionDelete);
         }
         ActionsPaneItems.Add(actionImport);
         ActionsPaneItems.Add(actionExport);
         return;
     }
     DisplayName = applicationName + " - No Access Rights!";
     if (!isRootNode)
     {
         MmcListViewDescription mmcListViewDescription2 = new MmcListViewDescription();
         mmcListViewDescription2.DisplayName = applicationName + " - No Access Rights!";
         mmcListViewDescription2.Options     = MmcListViewOptions.HideSelection;
         ViewDescriptions.Add(mmcListViewDescription2);
     }
 }