Exemplo n.º 1
0
        }// RefreshDisplayName

        //-------------------------------------------------
        // RefreshResultView
        //
        // Our nodes will call this when they need their Result
        // view refreshed
        //-------------------------------------------------
        internal virtual void RefreshResultView()
        {
            // We'll only refresh ourselves if we're currently selected
            if (this == CNodeManager.SelectedNode)
            {
                if (m_hPropertyPageRouter != (IntPtr)(-1))
                {
                    m_fWantToRefreshResult = true;
                }
                else
                {
                    // Record who orginally had focus. If we had a property page
                    // or something that had focus first, we're going to piss people
                    // off if we hide it with MMC
                    IntPtr hOriginalActive = GetActiveWindow();
                    m_fStartResultRefresh = true;
                    CNodeManager.SelectScopeItem(HScopeItem);
                    IntPtr hFinalActive = GetActiveWindow();
                    if (hOriginalActive != hFinalActive)
                    {
                        SetActiveWindow(hOriginalActive);
                    }
                    m_fWantToRefreshResult = false;
                }
            }
        }// RefreshDisplayName
        }// AddMenuItems

        internal override void MenuCommand(int nCommandID, Object oResultItem)
        {
            if (nCommandID == COMMANDS.DUPLICATE_PERMISSIONSET)
            {
                NamedPermissionSet nps = (NamedPermissionSet)m_psetWrapper.PSet.Copy();

                String sBaseName = nps.Name;

                nps.Name = String.Format(CResourceStore.GetString("CSinglePermissionSet:PrependtoDupPSets"), nps.Name);
                int nCounter = 1;
                // make sure it's not already used
                while (Security.isPermissionSetNameUsed(m_pl, nps.Name))
                {
                    nCounter++;
                    nps.Name = String.Format(CResourceStore.GetString("CSinglePermissionSet:NumPrependtoDupPSets"), nCounter.ToString(), sBaseName);
                }


                CNode node = CNodeManager.GetNodeByHScope(ParentHScopeItem);
                CSinglePermissionSet newNode = ((CPermissionSet)node).AddPermissionSet(nps);
                newNode.SecurityPolicyChanged();
                // Put the selection on the new permission set we just created
                CNodeManager.SelectScopeItem(newNode.HScopeItem);
            }

            else if (nCommandID == COMMANDS.VIEW_PERMISSION)
            {
                int iResultItem = (int)oResultItem - 1;
                // Pop up the Dialog Box for this permission
                (new CReadOnlyPermission((IPermission)m_alPermissions[iResultItem])).ShowDialog();
            }

            else if (nCommandID == COMMANDS.ADD_PERMISSIONS)
            {
                CAddPermissionsWizard wiz = new CAddPermissionsWizard(m_psetWrapper);
                wiz.LaunchWizard(Cookie);
                if (wiz.didFinish)
                {
                    SecurityPolicyChanged();
                    GenerateGivenPermissionsStringList();
                    CNodeManager.Console.SelectScopeItem(HScopeItem);
                }
            }
            else if (nCommandID == COMMANDS.SHOW_LISTVIEW)
            {
                m_oResults = this;
                RefreshResultView();
                m_fShowHTMLPage = false;
            }

            else if (nCommandID == COMMANDS.SHOW_TASKPAD)
            {
                m_oResults      = m_taskpad;
                m_fShowHTMLPage = true;
                // The HTML pages comes displayed with this checkbox marked. Make
                // sure we update the xml setting
                CConfigStore.SetSetting("ShowHTMLForPermissionSet", "yes");
                RefreshResultView();
            }
        }// MenuCommand
Exemplo n.º 3
0
        }// MenuCommand

        internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com)
        {
            // We want to browse this apps properties
            if ((int)arg == 0)
            {
                OpenMyPropertyPage();
            }

            // We want to browse the Assembly Dependencies
            else if ((int)arg == 1)
            {
                CNode node = FindChild("Assembly Dependencies");
                CNodeManager.SelectScopeItem(node.HScopeItem);
                node.MenuCommand(COMMANDS.SHOW_LISTVIEW);
            }
            // We want to Configure Assemblies
            else if ((int)arg == 2)
            {
                CNode node = FindChild("Configured Assemblies");
                CNodeManager.SelectScopeItem(node.HScopeItem);
            }
            // We want to go to remoting node
            else if ((int)arg == 3)
            {
                CNode node = FindChild("Remoting Services");
                CNodeManager.SelectScopeItem(node.HScopeItem);
                node.OpenMyPropertyPage();
            }
            else if ((int)arg == 4)
            {
                MenuCommand(COMMANDS.FIX_APPLICATION);
                // Inform our Command History that we did this
                CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.FIX_APPLICATION);
            }
        }// TaskPadTaskNotify
Exemplo n.º 4
0
        }// CIntroTaskPad

        internal override void Notify(Object arg, Object param, IConsole2 con, CData com)
        {
            String sNodeToOpen = null;


            // We want to browse the shared assemblies
            if ((int)arg == 1)
            {
                sNodeToOpen = "Assembly Cache";
            }
            // We want to Configure Assemblies
            else if ((int)arg == 2)
            {
                sNodeToOpen = "Configured Assemblies";
            }
            // We want to set Security Policy
            else if ((int)arg == 3)
            {
                sNodeToOpen = "Runtime Security Policy";
            }
            // We want to go to remoting node
            else if ((int)arg == 4)
            {
                CNode node = m_myNode.FindChild("Remoting Services");
                CNodeManager.SelectScopeItem(node.HScopeItem);
                node.OpenMyPropertyPage();
            }
            // We want to go to the applications node
            else if ((int)arg == 5)
            {
                sNodeToOpen = "Applications";
            }



            // This is a CommandHistory item
            else if ((int)arg >= 100)
            {
                CCommandHistory.FireOffCommand((int)arg);
            }
            else
            {
                MessageBox(0, "Error in web page! I don't know what to do!", "", 0);
            }

            if (sNodeToOpen != null)
            {
                CNode node = m_myNode.FindChild(sNodeToOpen);
                // This node must have a shared assemblies node... if it doesn't, then the
                // node hasn't added it's children yet. We'll force it to do that, and try
                // again
                if (node == null)
                {
                    m_myNode.CreateChildren();
                    node = m_myNode.FindChild(sNodeToOpen);
                }
                CNodeManager.Console.SelectScopeItem(node.HScopeItem);
            }
        }// Notify
Exemplo n.º 5
0
        }// AddMenuItems

        internal override void MenuCommand(int iCommandID)
        {
            if (iCommandID == COMMANDS.NEW_PERMISSIONSET)
            {
                CNewPermSetWizard wiz = new CNewPermSetWizard(m_pl);
                wiz.LaunchWizard(Cookie);
                if (wiz.CreatedPermissionSet != null)
                {
                    CNode node = AddPermissionSet(wiz.CreatedPermissionSet);
                    SecurityPolicyChanged();
                    // Now select the permission set we just created
                    CNodeManager.SelectScopeItem(node.HScopeItem);
                }
            }
        }// MenuCommand
Exemplo n.º 6
0
        }// AddMenuItems

        internal override void MenuCommand(int nCommandID)
        {
            if (nCommandID == COMMANDS.CREATE_CODEGROUP)
            {
                CNewCodeGroupWizard wiz = new CNewCodeGroupWizard(m_pl);
                wiz.LaunchWizard(Cookie);
                // Ok, let's see what goodies we have...
                String sPermSetName = null;
                if (wiz.CreatedPermissionSet != null)
                {
                    sPermSetName = AddPermissionSet(wiz.CreatedPermissionSet).DisplayName;
                    SecurityPolicyChanged();
                }
                if (wiz.CreatedCodeGroup != null)
                {
                    try
                    {
                        CodeGroup cg = wiz.CreatedCodeGroup;
                        if (sPermSetName != null)
                        {
                            PermissionSet   ps   = m_pl.GetNamedPermissionSet(sPermSetName);
                            PolicyStatement pols = cg.PolicyStatement;
                            pols.PermissionSet = ps;
                            cg.PolicyStatement = pols;
                        }
                        CSingleCodeGroup node = AddCodeGroup(wiz.CreatedCodeGroup);
                        // Put the focus on the newly created codegroup
                        CNodeManager.SelectScopeItem(node.HScopeItem);
                    }
                    catch (Exception)
                    {
                        MessageBox(CResourceStore.GetString("CSingleCodeGroup:ErrorCreatingCodegroup"),
                                   CResourceStore.GetString("CSingleCodeGroup:ErrorCreatingCodegroupTitle"),
                                   MB.ICONEXCLAMATION);
                    }
                }
            }
            else if (nCommandID == COMMANDS.DUPLICATE_CODEGROUP)
            {
                CNode node;

                CodeGroup newcg = m_cg.Copy();

                // Change this code group's name

                String sBaseName = newcg.Name;
                newcg.Name = String.Format(CResourceStore.GetString("CSingleCodeGroup:PrependtoDupCodegroups"), newcg.Name);
                int nCounter = 1;
                // make sure it's not already used
                while (Security.isCodeGroupNameUsed(m_pl.RootCodeGroup, newcg.Name))
                {
                    nCounter++;
                    newcg.Name = String.Format(CResourceStore.GetString("CSingleCodeGroup:NumPrependtoDupCodegroups"), nCounter.ToString(), sBaseName);
                }

                CNode newCodeGroup = null;
                // If we are the root codegroup, then we'll add this as a child
                if (Security.GetRootCodeGroupNode(m_pl) == this)
                {
                    newCodeGroup = AddCodeGroup(newcg);
                    node         = this;
                }
                else
                {
                    node         = CNodeManager.GetNodeByHScope(ParentHScopeItem);
                    newCodeGroup = ((CSingleCodeGroup)node).AddCodeGroup(newcg);
                }

                // Select the new item
                CNodeManager.SelectScopeItem(newCodeGroup.HScopeItem);
            }
        }// MenuCommand
Exemplo n.º 7
0
        }// AddMenuItems

        internal override void MenuCommand(int iCommandID)
        {
            // All these menu commands are going to require the policy nodes to be created and expanded.
            // Let's check to see if we've done that already....
            if (NumChildren == 0)
            {
                CNodeManager.CNamespace.Expand(HScopeItem);
            }

            if (iCommandID == COMMANDS.NEW_SECURITYPOLICY)
            {
                CNewSecurityPolicyDialog          nspd = new CNewSecurityPolicyDialog();
                System.Windows.Forms.DialogResult dr   = nspd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    // To get a 'New' Security policy, we just load a policy from a file that doesn't exist
                    CSecurityPolicy secpolnode = GetSecurityPolicyNode(nspd.SecPolType);

                    // Ok, this is really dumb. I need to create a security file where the user
                    // wants to store the policy before I can tell the Security Manager about it.
                    File.Copy(secpolnode.MyPolicyLevel.StoreLocation, nspd.Filename, true);
                    PolicyLevel pl = SecurityManager.LoadPolicyLevelFromFile(nspd.Filename, nspd.SecPolType);
                    pl.Reset();
                    secpolnode.SetNewSecurityPolicyLevel(pl);
                    secpolnode.SecurityPolicyChanged();
                    // Select the policy node the user just mucked with
                    CNodeManager.SelectScopeItem(secpolnode.HScopeItem);
                }
            }
            else if (iCommandID == COMMANDS.OPEN_SECURITYPOLICY)
            {
                COpenSecurityPolicyDialog ospd = new COpenSecurityPolicyDialog(new String[] { EnterpriseNode.ComputerPolicyFilename,
                                                                                              MachineNode.ComputerPolicyFilename,
                                                                                              UserNode.ComputerPolicyFilename });
                System.Windows.Forms.DialogResult dr = ospd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    // Try and load the given security policy
                    PolicyLevel pl;
                    try
                    {
                        pl = SecurityManager.LoadPolicyLevelFromFile(ospd.Filename, ospd.SecPolType);
                    }
                    catch
                    {
                        MessageBox(String.Format(CResourceStore.GetString("CGenSecurity:isNotASecurityFile"), ospd.Filename),
                                   CResourceStore.GetString("CGenSecurity:isNotASecurityFileTitle"),
                                   MB.ICONEXCLAMATION);
                        return;
                    }
                    CSecurityPolicy secpolnode = GetSecurityPolicyNode(ospd.SecPolType);
                    secpolnode.SetNewSecurityPolicyLevel(pl);
                    // Select the policy node the user just mucked with
                    CNodeManager.SelectScopeItem(secpolnode.HScopeItem);
                }
            }
            else if (iCommandID == COMMANDS.EVALUATE_ASSEMBLY)
            {
                CWizard wiz = new CEvalAssemWizard();
                wiz.LaunchWizard(Cookie);
            }
            else if (iCommandID == COMMANDS.TRUST_ASSEMBLY)
            {
                // Let's create a new wizard now to dump any old settings we have
                CFullTrustWizard wiz = new CFullTrustWizard(MachineNode.ReadOnly, UserNode.ReadOnly);

                wiz.LaunchWizard(Cookie);

                // See if it updated anything a codegroup
                if (wiz.MadeChanges)
                {
                    CSecurityPolicy sp = GetSecurityPolicyNode(Security.GetPolicyLevelTypeFromLabel(wiz.PolLevel.Label));
                    sp.RedoChildren();
                    sp.SecurityPolicyChanged();
                }
            }
            else if (iCommandID == COMMANDS.ADJUST_SECURITYPOLICY)
            {
                CSecurityAdjustmentWizard wiz = new CSecurityAdjustmentWizard(MachineNode.ReadOnly, UserNode.ReadOnly);
                wiz.LaunchWizard(Cookie);

                // Check to see if we need to tell any policies that we changed them
                if (wiz.didUserPolicyChange)
                {
                    UserNode.RedoChildren();
                    UserNode.SecurityPolicyChanged();
                }

                if (wiz.didMachinePolicyChange)
                {
                    MachineNode.RedoChildren();
                    MachineNode.SecurityPolicyChanged();
                }
            }
            else if (iCommandID == COMMANDS.CREATE_MSI)
            {
                CWizard wiz = new CCreateDeploymentPackageWizard(this);
                wiz.LaunchWizard(Cookie);
            }
            else if (iCommandID == COMMANDS.RESET_POLICY)
            {
                int nRes = MessageBox(CResourceStore.GetString("CGenSecurity:ConfirmResetAll"),
                                      CResourceStore.GetString("CGenSecurity:ConfirmResetAllTitle"),
                                      MB.YESNO | MB.ICONQUESTION);
                if (nRes == MB.IDYES)
                {
                    if (!EnterpriseNode.ReadOnly)
                    {
                        EnterpriseNode.ResetSecurityPolicy();
                    }
                    if (!MachineNode.ReadOnly)
                    {
                        MachineNode.ResetSecurityPolicy();
                    }
                    if (!UserNode.ReadOnly)
                    {
                        UserNode.ResetSecurityPolicy();
                    }
                    MessageBox(CResourceStore.GetString("CGenSecurity:PoliciesResetAll"),
                               CResourceStore.GetString("CGenSecurity:PoliciesResetAllTitle"),
                               MB.ICONINFORMATION);
                }
            }
        }// MenuCommand