Exemplo n.º 1
0
        }// InsertPropSheetPageControls

        internal bool PutValuesinPage()
        {
            m_txtAssemEval.Text = m_sAssemName;
            // Make sure this starts off enabled
            m_btnViewPerm.Enabled = true;

            m_lblLevelEvalVal.Text = CEvalAssemWizard.GetDisplayString(m_nPolicyLevel);

            // Display the various permissions in the currently selected permission set
            m_lvPermissions.Items.Clear();
            if (m_ps != null)
            {
                if (m_ps.IsUnrestricted())
                {
                    ListViewItem lvi = new ListViewItem(CResourceStore.GetString("Unrestricted"), UNRESTRICTEDIMAGEINDEX);
                    m_lvPermissions.Items.Add(lvi);
                    m_btnViewPerm.Enabled = false;
                }
                else
                {
                    IEnumerator permEnumerator = m_ps.GetEnumerator();
                    while (permEnumerator.MoveNext())
                    {
                        IPermission  perm        = (IPermission)permEnumerator.Current;
                        int          nImageIndex = DeterminePermissionIcon(perm);
                        ListViewItem lvi         = new ListViewItem(Security.GetDisplayStringForPermission(perm), nImageIndex);
                        m_lvPermissions.Items.Add(lvi);
                    }
                }
            }

            m_txtAssemEval.Select(0, 0);
            return(true);
        }// PutValuesinPage
Exemplo n.º 2
0
        }// onObjectiveChange

        void onLevelChange(Object o, EventArgs e)
        {
            // Get a jump on the loading of this assembly
            if (m_tEvidence == null && m_txtFilename.Text.Length > 0)
            {
                m_tEvidence = new Thread(new ThreadStart(NewAssembly));
                m_tEvidence.Start();
            }

            CEvalAssemWizard wiz = (CEvalAssemWizard)CNodeManager.GetNode(m_iCookie);

            wiz.RestartEvaluation();
        }// onLevelChange
Exemplo n.º 3
0
        }// onBrowse

        void onObjectiveChange(Object o, EventArgs e)
        {
            // Get a jump on the loading of this assembly
            if (m_tEvidence == null && m_txtFilename.Text.Length > 0)
            {
                m_tEvidence = new Thread(new ThreadStart(NewAssembly));
                m_tEvidence.Start();
            }

            CEvalAssemWizard wiz = (CEvalAssemWizard)CNodeManager.GetNode(m_iCookie);

            wiz.NewObjectiveReceived(m_radViewPerms.Checked);
        }// onObjectiveChange
Exemplo n.º 4
0
        }// onTextChange

        void NewAssembly()
        {
            CEvalAssemWizard wiz = (CEvalAssemWizard)CNodeManager.GetNode(m_iCookie);

            try
            {
                AssemblyRef ar = m_al.LoadAssemblyInOtherAppDomainFrom(m_txtFilename.Text);
                wiz.NewEvidenceReceived(ar.GetEvidence());
                m_al.Finished();
            }
            catch (Exception)
            {
                wiz.NewEvidenceReceived(null);
                m_al.Finished();
            }
        }// NewAssembly
Exemplo n.º 5
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
Exemplo n.º 6
0
        }// InsertPropSheetPageControls

        internal bool PutValuesinPage()
        {
            m_txtAssemEval.Text = m_sAssemName;
            m_txtAssemEval.Select(0, 0);
            m_txtLevelEval.Select(0, 0);
            m_txtLevelEval.Text = CEvalAssemWizard.GetDisplayString(m_nPolicyLevel);

            m_tvCodegroups.Nodes.Clear();

            // Figure out the real policy level
            if (m_nPolicyLevel != CEvalAssemWizard.ALL_CODEGROUPS)
            {
                // We only want to show one policy level

                // Figure out what Icon, index, and display string to use
                int nImageIndex = ENTERPRISENODE;

                if (m_nPolicyLevel == CEvalAssemWizard.ENTERPRISE_CODEGROUPS)
                {
                    nImageIndex = ENTERPRISENODE;
                }
                else if (m_nPolicyLevel == CEvalAssemWizard.MACHINE_CODEGROUPS)
                {
                    nImageIndex = MACHINENODE;
                }
                else
                {
                    nImageIndex = USERNODE;
                }
                // Let's start walking our tree
                MyTreeNode tn = new MyTreeNode(m_txtLevelEval.Text, null);
                tn.ImageIndex = tn.SelectedImageIndex = nImageIndex;
                m_tvCodegroups.Nodes.Add(tn);

                PutInCodeGroup(m_cgMatchingCGs[m_nPolicyLevel], tn);
            }
            else // They want to look at all the code groups...
            {
                String[] sNodeNames = new String[] { CResourceStore.GetString("Enterprise Policy"),
                                                     CResourceStore.GetString("Machine Policy"),
                                                     CResourceStore.GetString("User Policy") };

                int[] nImageIndex = new int[] { ENTERPRISENODE, MACHINENODE, USERNODE };
                for (int i = 0; i < 3; i++)
                {
                    MyTreeNode tn = new MyTreeNode(sNodeNames[i], null);
                    tn.ImageIndex = tn.SelectedImageIndex = nImageIndex[i];
                    m_tvCodegroups.Nodes.Add(tn);

                    // If no codegroups evaulated for this level....
                    if (m_cgMatchingCGs == null || m_cgMatchingCGs[i] == null)
                    {
                        MyTreeNode newtn = new MyTreeNode(CResourceStore.GetString("CEvalAssemWiz3:NoCodegroups"), null);
                        newtn.ImageIndex = newtn.SelectedImageIndex = INFOICON;
                        tn.Nodes.Add(newtn);
                    }
                    // If we didn't evaluate codegroups for this policy level because
                    // a higher policy level contained a 'Level Final' codegroup
                    else if (m_cgMatchingCGs[i] is NotEvalCodegroup)
                    {
                        MyTreeNode newtn = new MyTreeNode(CResourceStore.GetString("CEvalAssemWiz3:NotEvalCodegroups"), null);
                        newtn.ImageIndex = newtn.SelectedImageIndex = INFOICON;
                        tn.Nodes.Add(newtn);
                    }
                    // We actually did get some codegroups
                    else
                    {
                        PutInCodeGroup(m_cgMatchingCGs[i], tn);
                    }
                }
            }
            return(true);
        }// PutValuesinPage