Пример #1
0
        }// onTextChange

        void onBrowse(Object o, EventArgs e)
        {
            // Pop up a file dialog so the user can find an assembly
            OpenFileDialog fd = new OpenFileDialog();

            fd.Title  = CResourceStore.GetString("CTrustAppWiz2:ChooseAssemFDTitle");
            fd.Filter = CResourceStore.GetString("AssemFDMask");
            System.Windows.Forms.DialogResult dr = fd.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (Fusion.isManaged(fd.FileName))
                {
                    m_txtFilename.Text = fd.FileName;
                    // Inform our wizard that we have a new assembly for it to try and load
                    CFullTrustWizard wiz = (CFullTrustWizard)CNodeManager.GetNode(m_iCookie);
                    wiz.NewAssembly();
                }
                else
                {
                    MessageBox(CResourceStore.GetString("isNotManagedCode"),
                               CResourceStore.GetString("isNotManagedCodeTitle"),
                               MB.ICONEXCLAMATION);
                }
            }
        } // onBrowse
Пример #2
0
        }// isForHomeUser

        void onTextChange(Object o, EventArgs e)
        {
            CFullTrustWizard wiz = (CFullTrustWizard)CNodeManager.GetNode(m_iCookie);

            // The assembly we were looking at changed.
            wiz.WipeEvidence();
            if (m_txtFilename.Text.Length > 0)
            {
                wiz.TurnOnNext(true);
            }
            else
            {
                wiz.TurnOnNext(false);
            }
        }// onTextChange
Пример #3
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