Inheritance: System.Security.IPermission, IUnrestrictedPermission, System.Security.ISecurityEncodable, IBuiltInPermission
Esempio n. 1
0
        /// <summary>Determines whether the current permission is a subset of the specified permission.</summary>
        /// <returns>true if the current permission is a subset of the specified permission; otherwise, false.</returns>
        /// <param name="target">A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is an object that is not of the same type as the current permission. </exception>
        public bool IsSubsetOf(IPermission target)
        {
            PrincipalPermission principalPermission = this.Cast(target);

            if (principalPermission == null)
            {
                return(this.IsEmpty());
            }
            if (this.IsUnrestricted())
            {
                return(principalPermission.IsUnrestricted());
            }
            if (principalPermission.IsUnrestricted())
            {
                return(true);
            }
            foreach (object obj in this.principals)
            {
                PrincipalPermission.PrincipalInfo principalInfo = (PrincipalPermission.PrincipalInfo)obj;
                bool flag = false;
                foreach (object obj2 in principalPermission.principals)
                {
                    PrincipalPermission.PrincipalInfo principalInfo2 = (PrincipalPermission.PrincipalInfo)obj2;
                    if ((principalInfo.Name == principalInfo2.Name || principalInfo2.Name == null) && (principalInfo.Role == principalInfo2.Role || principalInfo2.Role == null) && principalInfo.IsAuthenticated == principalInfo2.IsAuthenticated)
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        public EmailContainer EmailSelectFiltered(Email filter)
        {
            // Check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            EmailContainer result;
            DataSet entitySet = m_DataContext.ndihdEmailSelectFiltered(
              filter.Category,
              filter.FilterOnSentFrom,
              filter.FilterOnSentTo,
              filter.FilterOnActivityPrevention,
              filter.FilterOnActivityResearch,
              filter.FilterOnActivityRehabilitation,
              filter.FilterOnActivityOther,
              filter.FilterOnNDI,
              filter.FilterOnActivityAll
              );
            result = new EmailContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 3
0
 //[PrincipalPermission(SecurityAction.Demand, Name="aa")]
 protected void testRoleBtn_Click(object sender, EventArgs e)
 {
     var aPermission = new PrincipalPermission("a", null);
     var bPermission = new PrincipalPermission("b", null);
     aPermission.Union(bPermission).Demand();
     //permission.Demand();
 }
        public void Authorize()
        {
            var serviceType = this.GetType();
            var configItem = Config.Get(serviceType);

            IList<string> groups = null;
            if (configItem != null)
            {
                groups = configItem.AuthorizedGroups;
            }

            if (groups == null)
            {
                throw new SecurityException("Group is null");
            }

            var pps = new PrincipalPermission[groups.Count];
            for (var i = 0; i < groups.Count; i++)
            {
                pps[i] = new PrincipalPermission(null, groups[i]);
            }

            var pp = pps[0];
            if (groups.Count> 0)
            {
                for (var i = 1; i < groups.Count; i++)
                {
                    pp = (PrincipalPermission)pp.Union(pps[i]);
                }
            }
            pp.Demand();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
              SetTitle(" - Állásajánlatra jelentkezés rögzítése");
              SetDefaultControls("btnCreate", "txtMotivation");
              // Check permission: anybody can use this page
              PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              permReg.Demand();

              string jobId = Request["jobId"];
              m_sender = Request["sender"];
              if (jobId == null)
            throw new ApplicationException("Hiányzó kötelező paraméter: hirdetés azonosító.");

              m_srvJob = ServiceFactory.GetJobOfferService();
              m_JobId = new Guid(jobId);
              m_Job = m_srvJob.JobOfferSelect(m_JobId);

              if (!Page.IsPostBack)
              {
            RetreiveData();

            #region Attachement grid feltöltése

            ShowAttachementGrid();

            #endregion
              }
        }
        public new void NewsAttachmentDelete(NewsAttachment entity)
        {
            // check permission: admin
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            FileDataContext fileDataContext = new FileDataContext();
            string ext = Path.GetExtension(entity.Path).ToLower();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.NewsAttachmentDelete(entity.NewsRef, fileName);
            base.NewsAttachmentDelete(entity);

            BusinessAuditEvent.Success();
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        /// <summary>创建一个权限,该权限是当前权限与指定权限的并集。</summary>
        /// <returns>一个新权限,它表示当前权限与指定权限的并集。</returns>
        /// <param name="other">将与当前权限合并的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="other" /> 参数是与当前权限属于不同类型的对象。</exception>
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            if (!this.VerifyType(other))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            PrincipalPermission principalPermission = (PrincipalPermission)other;

            if (this.IsUnrestricted() || principalPermission.IsUnrestricted())
            {
                return((IPermission) new PrincipalPermission(PermissionState.Unrestricted));
            }
            IDRole[] array = new IDRole[this.m_array.Length + principalPermission.m_array.Length];
            int      index1;

            for (index1 = 0; index1 < this.m_array.Length; ++index1)
            {
                array[index1] = this.m_array[index1];
            }
            for (int index2 = 0; index2 < principalPermission.m_array.Length; ++index2)
            {
                array[index1 + index2] = principalPermission.m_array[index2];
            }
            return((IPermission) new PrincipalPermission(array));
        }
Esempio n. 8
0
 public new void JobAnswerDelete(JobAnswer entity)
 {
     PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
       PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
       permReg.Union(permAdmin).Demand();
       base.JobAnswerDelete(entity);
 }
        public new void EDocumentCommendationDelete(EDocumentCommendation entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            base.EDocumentCommendationDelete(entity);

            BusinessAuditEvent.Success();
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SetDefaultControls("btnGetRight", "");
              PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              permReg.Demand();

              if (!Page.IsPostBack)
              {
            IOrganisationService srvOrg = ServiceFactory.GetOrganisationService();

            //megnézzük hogy volt e szervezet kiválasztva (van e selectedOrgId)
            string selectedOrgId = Request["selectedOrgId"];

            if (selectedOrgId != null)
            {
              //lekérdezzük a kiválasztott szervezet adatait
              Organisation org = srvOrg.OrganisationSelect(new Guid(selectedOrgId));

              txtOrgInstitution.Text = org.Name;
              lblZipCode.Text = org.PostCode;
              lblTownShip.Text = org.City;
              lblAddress.Text = org.Address;

              lblOrganisationForm.Text = org.Department.IsNull ? "-" : org.Department.ToString();
            }
              }
        }
Esempio n. 11
0
 public static void OfficerMethod()
 {
     string name = "��";
     string role = "ʿ��";
     PrincipalPermission principalPermission = new PrincipalPermission(name, role);
     principalPermission.Demand();
 }
        public void Authorize()
        {
            string[] groups = null;
            Type serviceType = this.GetType();
            var configItem = WcfConfigManager.GetServiceConfig(serviceType);

            if (null != configItem)
            {
                groups = configItem.Item.AuthorizedGroups.Split(',');
            }

            if (null != groups)
            {
                PrincipalPermission[] pps = new PrincipalPermission[groups.Length];
                for (int i = 0; i < groups.Length; i++)
                {
                    pps[i] = new PrincipalPermission(null, groups[i]);
                }

                PrincipalPermission pp = pps[0];
                if (groups.Length > 0)
                {
                    for (int i = 1; i < groups.Length; i++)
                    {
                        pp = (PrincipalPermission)pp.Union(pps[i]);
                    }
                }
                pp.Demand();
            }
            else
                throw new SecurityException("Group is null");
        }
Esempio n. 13
0
        /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
        /// <param name="other">A permission to combine with the current permission. It must be of the same type as the current permission. </param>
        /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
        /// <exception cref="T:System.ArgumentException">The <paramref name="other" /> parameter is an object that is not of the same type as the current permission. </exception>
        // Token: 0x06002609 RID: 9737 RVA: 0x00089284 File Offset: 0x00087484
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            if (!this.VerifyType(other))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            PrincipalPermission principalPermission = (PrincipalPermission)other;

            if (this.IsUnrestricted() || principalPermission.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }
            int num = this.m_array.Length + principalPermission.m_array.Length;

            IDRole[] array = new IDRole[num];
            int      i;

            for (i = 0; i < this.m_array.Length; i++)
            {
                array[i] = this.m_array[i];
            }
            for (int j = 0; j < principalPermission.m_array.Length; j++)
            {
                array[i + j] = principalPermission.m_array[j];
            }
            return(new PrincipalPermission(array));
        }
Esempio n. 14
0
        public new void ContinuativeDelete(Continuative entity)
        {
            //check permission: Admin
              PrincipalPermission permAdm = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            base.ContinuativeDelete(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ContinuativeID", entity.ID)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ContinuativeID", entity.ID));
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Put user code to initialize the page here
       // Check permission: all registered user
       PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
       perm.Demand();
 }
Esempio n. 16
0
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            else if (!VerifyType(target))
            {
                throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
            }
            else if (IsUnrestricted())
            {
                return(target.Copy());
            }

            PrincipalPermission operand = (PrincipalPermission)target;

            if (operand.IsUnrestricted())
            {
                return(Copy());
            }

            List <IDRole> idroles = null;

            foreach (IDRole idRole in _idArray)
            {
                foreach (IDRole operandIdRole in operand._idArray)
                {
                    if (operandIdRole.Authenticated == idRole.Authenticated)
                    {
                        string newID            = string.Empty;
                        string newRole          = string.Empty;
                        bool   newAuthenticated = operandIdRole.Authenticated;
                        bool   addToNewIDRoles  = false;

                        if (operandIdRole.ID == null || idRole.ID == null || idRole.ID.Equals(operandIdRole.ID))
                        {
                            newID           = operandIdRole.ID == null ? idRole.ID : operandIdRole.ID;
                            addToNewIDRoles = true;
                        }
                        if (operandIdRole.Role == null || idRole.Role == null || idRole.Role.Equals(operandIdRole.Role))
                        {
                            newRole         = operandIdRole.Role == null ? idRole.Role : operandIdRole.Role;
                            addToNewIDRoles = true;
                        }
                        if (addToNewIDRoles)
                        {
                            if (idroles == null)
                            {
                                idroles = new List <IDRole>();
                            }
                            idroles.Add(new IDRole(newAuthenticated, newID, newRole));
                        }
                    }
                }
            }

            return((idroles == null) ? null : new PrincipalPermission(idroles.ToArray()));
        }
		public void PermissionStateUnrestricted () 
		{
			PrincipalPermission p = new PrincipalPermission (PermissionState.Unrestricted);
			AssertNotNull ("PrincipalPermission(PermissionState.Unrestricted)", p);
			Assert ("IsUnrestricted", p.IsUnrestricted ());
			PrincipalPermission copy = (PrincipalPermission) p.Copy ();
			AssertEquals ("Copy.IsUnrestricted", p.IsUnrestricted (), copy.IsUnrestricted ());
			// Note: Unrestricted isn't shown in XML
		}
		// Method
		public override IPermission CreatePermission ()
		{
			PrincipalPermission perm = null;
			if (this.Unrestricted)
				perm = new PrincipalPermission (PermissionState.Unrestricted);
			else
				perm = new PrincipalPermission (name, role, authenticated);
			return perm;
		}
Esempio n. 19
0
		public void PermissionStateUnrestricted () 
		{
			PrincipalPermission p = new PrincipalPermission (PermissionState.Unrestricted);
			Assert.IsNotNull (p, "PrincipalPermission(PermissionState.Unrestricted)");
			Assert.IsTrue (p.IsUnrestricted (), "IsUnrestricted");
			PrincipalPermission copy = (PrincipalPermission) p.Copy ();
			Assert.AreEqual (p.IsUnrestricted (), copy.IsUnrestricted (), "Copy.IsUnrestricted");
			// Note: Unrestricted isn't shown in XML
		}
 protected void Page_Load(object sender, EventArgs e)
 {
     // Check permission: all registered user
       PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
       perm.Demand();
       if (!Page.IsPostBack)
       {
     ShowGrid(gridCompetition, 0, null, null);
       }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
              SetTitle(" - Keresés hirdetés jelentkezés adatai");
              SetDefaultControls("btnModify","");
              // Check permission: anybody can use this page
              PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              permReg.Demand();
              string jobId = Request["jobId"];
              m_sender = Request["sender"];
              m_subscriber = Request["subscriber"];

              if (jobId == null)
            throw new ApplicationException("Hiányzó kötelező paraméter: hirdetés azonosító.");
              if (m_sender == null)
            throw new ApplicationException("Hiányzó kötelező paraméter: hirdetés azonosító.");
              if (m_subscriber == null)
            throw new ApplicationException("Hiányzó kötelező paraméter: hirdetés azonosító.");

              if (m_subscriber != Context.User.Identity.Name && m_sender != Context.User.Identity.Name)
              {
            if (m_subscriber != Context.User.Identity.Name)
            {
              throw new SecurityException("Nem az ön jelentkezése, nem tekintheti meg az adatokat.");
            }
            if (m_sender != Context.User.Identity.Name)
            {
              throw new SecurityException("Nem az ön hirdetése, nem tekintheti meg az adatokat.");
            }
              }
              m_srvJob = ServiceFactory.GetJobFindService();
              m_JobId = new Guid(jobId);
              m_Job = m_srvJob.JobFindSelect(m_JobId);
              m_JobAnswer = m_srvJobAnswer.JobAnswerSelect(m_JobId, JobAnswerTypeEnum.FIN, m_subscriber,m_sender);
              if (!Page.IsPostBack)
              {
            RetreiveData();

            #region Egyéb dokumentumok grid feltöltése

            ShowAttachementGrid();

            #endregion
              }
              if (m_JobAnswer.SenderNameRef == Context.User.Identity.Name)
              {
            btnModify.Visible = false;
            tdUser.InnerHtml = "<BR/>Jelentkező adatai:";
              }
              else
              {
            btnModify.Visible = true;
            tdUser.InnerText = "Állást kereső személy adatai:";
              }
        }
Esempio n. 22
0
        //------------------------------------------------------
        //
        // IPERMISSION IMPLEMENTATION
        //
        //------------------------------------------------------

        public bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(this.IsEmpty());
            }

            try
            {
                PrincipalPermission operand = (PrincipalPermission)target;

                if (operand.IsUnrestricted())
                {
                    return(true);
                }
                else if (this.IsUnrestricted())
                {
                    return(false);
                }
                else
                {
                    for (int i = 0; i < this.m_array.Length; ++i)
                    {
                        bool foundMatch = false;

                        for (int j = 0; j < operand.m_array.Length; ++j)
                        {
                            if (operand.m_array[j].m_authenticated == this.m_array[i].m_authenticated &&
                                (operand.m_array[j].m_id == null ||
                                 (this.m_array[i].m_id != null && this.m_array[i].m_id.Equals(operand.m_array[j].m_id))) &&
                                (operand.m_array[j].m_role == null ||
                                 (this.m_array[i].m_role != null && this.m_array[i].m_role.Equals(operand.m_array[j].m_role))))
                            {
                                foundMatch = true;
                                break;
                            }
                        }

                        if (!foundMatch)
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }
            catch (InvalidCastException)
            {
                throw new
                      ArgumentException(
                          Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                          );
            }
        }
Esempio n. 23
0
        public IPermission Intersect(IPermission target)
        {
            PrincipalPermission pp = Cast(target);

            if (pp == null)
            {
                return(null);
            }

            if (IsUnrestricted())
            {
                return(pp.Copy());
            }
            if (pp.IsUnrestricted())
            {
                return(Copy());
            }

            PrincipalPermission intersect = new PrincipalPermission(PermissionState.None);

            foreach (PrincipalInfo pi in principals)
            {
                foreach (PrincipalInfo opi in pp.principals)
                {
                    if (pi.IsAuthenticated == opi.IsAuthenticated)
                    {
                        string name = null;
                        if ((pi.Name == opi.Name) || (opi.Name == null))
                        {
                            name = pi.Name;
                        }
                        else if (pi.Name == null)
                        {
                            name = opi.Name;
                        }
                        string role = null;
                        if ((pi.Role == opi.Role) || (opi.Role == null))
                        {
                            role = pi.Role;
                        }
                        else if (pi.Role == null)
                        {
                            role = opi.Role;
                        }
                        if ((name != null) || (role != null))
                        {
                            PrincipalInfo ipi = new PrincipalInfo(name, role, pi.IsAuthenticated);
                            intersect.principals.Add(ipi);
                        }
                    }
                }
            }

            return((intersect.principals.Count > 0) ? intersect : null);
        }
		public void PermissionStateNone () 
		{
			PrincipalPermission p = new PrincipalPermission (PermissionState.None);
			AssertNotNull ("PrincipalPermission(PermissionState.None)", p);
			Assert ("IsUnrestricted", !p.IsUnrestricted ());
			PrincipalPermission copy = (PrincipalPermission) p.Copy ();
			AssertEquals ("Copy.IsUnrestricted", p.IsUnrestricted (), copy.IsUnrestricted ());
			SecurityElement se = p.ToXml ();
			Assert ("ToXml-class", (se.Attributes ["class"] as string).StartsWith (className));
			AssertEquals ("ToXml-version", "1", (se.Attributes ["version"] as string));
		}
Esempio n. 25
0
        /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
        /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission will be null if the intersection is empty.</returns>
        /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not an instance of the same class as the current permission. </exception>
        public IPermission Intersect(IPermission target)
        {
            PrincipalPermission principalPermission = this.Cast(target);

            if (principalPermission == null)
            {
                return(null);
            }
            if (this.IsUnrestricted())
            {
                return(principalPermission.Copy());
            }
            if (principalPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            PrincipalPermission principalPermission2 = new PrincipalPermission(PermissionState.None);

            foreach (object obj in this.principals)
            {
                PrincipalPermission.PrincipalInfo principalInfo = (PrincipalPermission.PrincipalInfo)obj;
                foreach (object obj2 in principalPermission.principals)
                {
                    PrincipalPermission.PrincipalInfo principalInfo2 = (PrincipalPermission.PrincipalInfo)obj2;
                    if (principalInfo.IsAuthenticated == principalInfo2.IsAuthenticated)
                    {
                        string text = null;
                        if (principalInfo.Name == principalInfo2.Name || principalInfo2.Name == null)
                        {
                            text = principalInfo.Name;
                        }
                        else if (principalInfo.Name == null)
                        {
                            text = principalInfo2.Name;
                        }
                        string text2 = null;
                        if (principalInfo.Role == principalInfo2.Role || principalInfo2.Role == null)
                        {
                            text2 = principalInfo.Role;
                        }
                        else if (principalInfo.Role == null)
                        {
                            text2 = principalInfo2.Role;
                        }
                        if (text != null || text2 != null)
                        {
                            PrincipalPermission.PrincipalInfo value = new PrincipalPermission.PrincipalInfo(text, text2, principalInfo.IsAuthenticated);
                            principalPermission2.principals.Add(value);
                        }
                    }
                }
            }
            return((principalPermission2.principals.Count <= 0) ? null : principalPermission2);
        }
Esempio n. 26
0
		public void PermissionStateNone () 
		{
			PrincipalPermission p = new PrincipalPermission (PermissionState.None);
			Assert.IsNotNull (p, "PrincipalPermission(PermissionState.None)");
			Assert.IsTrue (!p.IsUnrestricted (), "IsUnrestricted");
			PrincipalPermission copy = (PrincipalPermission) p.Copy ();
			Assert.AreEqual (p.IsUnrestricted (), copy.IsUnrestricted (), "Copy.IsUnrestricted");
			SecurityElement se = p.ToXml ();
			Assert.IsTrue ((se.Attributes ["class"] as string).StartsWith (className), "ToXml-class");
			Assert.AreEqual ("1", (se.Attributes ["version"] as string), "ToXml-version");
		}
Esempio n. 27
0
 private PrincipalPermission(PrincipalPermission copyFrom, bool copyChildren)
 {
     state = copyFrom.state;
     if (copyChildren)
     {
         principals = (ArrayList)(copyFrom.principals.Clone());
     }
     else
     {
         principals = new ArrayList();
     }
 }
Esempio n. 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetDefaultControls("btnModify", "");
              // Check permission: all registered user
              PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              perm.Demand();
              SetTitle(" - Felhasználói adatok");
              if (!Page.IsPostBack)
              {

            RetreivData();
              }
        }
        /// <summary>Creates and returns a new <see cref="T:System.Security.Permissions.PrincipalPermission" />.</summary>
        /// <returns>A <see cref="T:System.Security.Permissions.PrincipalPermission" /> that corresponds to this attribute.</returns>
        public override IPermission CreatePermission()
        {
            PrincipalPermission result;

            if (base.Unrestricted)
            {
                result = new PrincipalPermission(PermissionState.Unrestricted);
            }
            else
            {
                result = new PrincipalPermission(this.name, this.role, this.authenticated);
            }
            return(result);
        }
Esempio n. 30
0
        // Method
        public override IPermission CreatePermission()
        {
            PrincipalPermission perm = null;

            if (this.Unrestricted)
            {
                perm = new PrincipalPermission(PermissionState.Unrestricted);
            }
            else
            {
                perm = new PrincipalPermission(name, role, authenticated);
            }
            return(perm);
        }
Esempio n. 31
0
        private PrincipalPermission Cast(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            PrincipalPermission principalPermission = target as PrincipalPermission;

            if (principalPermission == null)
            {
                CodeAccessPermission.ThrowInvalidPermission(target, typeof(PrincipalPermission));
            }
            return(principalPermission);
        }
Esempio n. 32
0
        /// <summary>Determines whether the current permission is a subset of the specified permission.</summary>
        /// <param name="target">A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission. </param>
        /// <returns>
        ///     <see langword="true" /> if the current permission is a subset of the specified permission; otherwise, <see langword="false" />.</returns>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is an object that is not of the same type as the current permission. </exception>
        // Token: 0x06002607 RID: 9735 RVA: 0x00088E4C File Offset: 0x0008704C
        public bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(this.IsEmpty());
            }
            bool result;

            try
            {
                PrincipalPermission principalPermission = (PrincipalPermission)target;
                if (principalPermission.IsUnrestricted())
                {
                    result = true;
                }
                else if (this.IsUnrestricted())
                {
                    result = false;
                }
                else
                {
                    for (int i = 0; i < this.m_array.Length; i++)
                    {
                        bool flag = false;
                        for (int j = 0; j < principalPermission.m_array.Length; j++)
                        {
                            if (principalPermission.m_array[j].m_authenticated == this.m_array[i].m_authenticated && (principalPermission.m_array[j].m_id == null || (this.m_array[i].m_id != null && this.m_array[i].m_id.Equals(principalPermission.m_array[j].m_id))) && (principalPermission.m_array[j].m_role == null || (this.m_array[i].m_role != null && this.m_array[i].m_role.Equals(principalPermission.m_array[j].m_role))))
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            return(false);
                        }
                    }
                    result = true;
                }
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            return(result);
        }
Esempio n. 33
0
        static void Main(string[] args)
        {
            Console.WriteLine("\nWindows Identity");
            WindowsIdentity identity = WindowsIdentity.GetCurrent();
            Console.WriteLine("Authentication Type: " + identity.AuthenticationType);
            Console.WriteLine("Name: " + identity.Name);
            Console.WriteLine("Is System: " + identity.IsSystem);
            Console.WriteLine("Is Authenticated: " + identity.IsAuthenticated);
            Console.WriteLine("Owner Value: " + identity.Owner.Value);
            Console.WriteLine("User Value: " + identity.User.Value);
            Console.WriteLine("Token: " + identity.Token.ToString());
            Console.WriteLine("Groups:");
            IdentityReferenceCollection groups = identity.Groups;
            foreach (IdentityReference ir in groups)
            {
                Console.WriteLine(" - Value: " + ir.Value);
            }

            
            Console.WriteLine("\nWindows Principal");
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
            Console.WriteLine("Identity Name: " + principal.Identity.Name);

            Console.WriteLine("\nUser Roles: ");
            Console.WriteLine("Administrator: " + principal.IsInRole(WindowsBuiltInRole.Administrator));
            Console.WriteLine("Power User: "******"User: "******"ToString: " + pp.ToString());
                pp.Demand();
                Console.WriteLine("Success!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            try
            {
                SuperDuperMethod();
            }
            catch (Exception e)
            {
                Console.WriteLine("Super Duper method threw a far out exception: " + e.ToString());
            }
        }
Esempio n. 34
0
		static void Main(string[] args)
		{
			try
			{
				AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
				/*
				string id1 = "Bob";
				string role1 = "Manager";
				PrincipalPermission principalPermission1 = new PrincipalPermission(id1, role1);

				PrincipalPermission principalPermission2 = new PrincipalPermission("Louise", "Supervisor");

				(principalPermission1.Union(principalPermission2)).Demand();
				*/

				WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
				Console.WriteLine("Identity name: " + principal.Identity.Name);
				Console.WriteLine("Authentication type: " + principal.Identity.AuthenticationType);
				Console.WriteLine("IsInRole(\"administrators\"): " + principal.IsInRole("Administrators").ToString());

				Console.WriteLine("Checking that the current user is \"EZETOP\\dobyrne\" and that they are in the " + 
					"\"administrators\" group \\ role:");

				PrincipalPermission permission = new PrincipalPermission("EZETOP\\dobyrne", "administrators");
				permission.Demand();

				Console.WriteLine("Demand succeeded.");

				Console.WriteLine("\nChecking that the current user is in the \"administrators\" role. I know we did" + 
					" it already but it's on the page:");
				PrincipalPermission principalPerm = new PrincipalPermission(null, "Administrators");
				principalPerm.Demand();
				Console.WriteLine("Demand succeeded.");

				Console.WriteLine("\nPlease be sure to note that if either the \"name\" or \"role\" passed to a " +
					"PrincipalPermission constructor are null it means that any value is accepted.");

				Console.WriteLine("Checking if unrestricted: ");
				PrincipalPermission finalPerm = new PrincipalPermission(PermissionState.Unrestricted);
				finalPerm.Demand();
				Console.WriteLine("Demand succeeded, the current principal is unrestricted.");


			}
			catch (Exception e)
			{
				Console.WriteLine("Exception: " + e.ToString());
			}
		}
Esempio n. 35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Context.User.Identity.IsAuthenticated)
              {
            PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
            permReg.Demand();
              }

              if (!Page.IsPostBack)
              {
            SetSearchLabel();
            ShowForumGroupGrid(gridForumGroup, 0, null, null);
              }
              //SearchStrategyIFrame(lblSearch, lblIframe);
        }
        public Main()
        {
            InitializeComponent();
            Program.Project.Changed += new EventHandler<Library.ChangedEventArgs>(Project_Changed);
            this.InitUI();

            PrincipalPermission permission = new PrincipalPermission(null, "Administrators");
            try
            {
                permission.Demand();
            }
            catch (SecurityException ex)
            {
                this.envoyerToolStripMenuItem.Visible = false;
            }
        }
        public void ProgramAttachmentInactivate(DBGuid IdVal)
        {
            // check permission: admin
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();

              ProgramAttachment selected = base.ProgramAttachmentSelect(IdVal);
              if (selected == null)
            throw new ApplicationException("A megadott azonosítóval nem létezik csatolt fájl.");

              ProgramService progSrv = new ProgramService();
              Program selectedProgram = progSrv.ProgramSelect(selected.ProgramRef);
              if (selectedProgram == null)
            throw new ApplicationException("A megadott azonosítóval nem létezik program.");

              string writerRole = selectedProgram.OrganisationRef.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              permWriter.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // save data
            selected.IsActive = false;
            base.ProgramAttachmentUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramAttachmentID", IdVal.ToString()),
              new EventParameter("ProgramAttachmentName", selected.Name),
              new EventParameter("ProgramID", selected.ProgramRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramAttachmentID", IdVal.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 38
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetDefaultControls("btnCreate", "txtName");
              PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              permReg.Demand();

              string orgId = Request["orgId"];
              if (orgId == null)
            throw new ApplicationException("Hiányzó kötelezõ paraméter: szervezet azonosító.");

              Guid orgGuid = new Guid(orgId);
              string writerRole = orgId + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Context.User.Identity.Name, writerRole);
              permWriter.Demand();

              txtDescription.Attributes.Add("onkeyup", "DescriptionChanged()");
        }
Esempio n. 39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check permission: datawriter
              PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              permReg.Demand();
              NdiPrincipal principal = (NdiPrincipal) Context.User;
              string writerRole = principal.OrganisationID + ".Writer";
              PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, writerRole);
              perm.Demand();

              string kefId = Request["kefId"];
              Guid kefGuid = new Guid(kefId);

              if (!Page.IsPostBack)
              {
             RetrieveData(kefGuid);
              }
        }
Esempio n. 40
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check permission: all registered user
              PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
              perm.Demand();

              if (!Page.IsPostBack)
              {
            //a hírek dinamikus feltöltése
            INewsCategoryService srvNewsCateg = ServiceFactory.GetNewsCategoryService();
            NewsCategoryContainer categCont = srvNewsCateg.NewsCategorySelectAll();

            foreach (NewsCategory item in categCont.All.SortBy("Rank", true))
            {
              CreateControl(item.ID, item.Name);
            }
              }
        }
Esempio n. 41
0
        public bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(IsEmpty());
            }
            else if (!VerifyType(target))
            {
                throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
            }

            PrincipalPermission operand = (PrincipalPermission)target;

            if (operand.IsUnrestricted())
            {
                return(true);
            }
            else if (IsUnrestricted())
            {
                return(false);
            }

            foreach (IDRole idRole in _idArray)
            {
                bool foundMatch = false;
                foreach (IDRole operandIdRole in operand._idArray)
                {
                    if ((operandIdRole.Authenticated == idRole.Authenticated) &&
                        (operandIdRole.ID == null || (idRole.ID != null && idRole.ID.Equals(operandIdRole.ID))) &&
                        (operandIdRole.Role == null || (idRole.Role != null && idRole.Role.Equals(operandIdRole.Role))))
                    {
                        foundMatch = true;
                        break;
                    }
                }

                if (!foundMatch)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 42
0
        public void KefDownloadChangeRank(DBGuid uid1, DBGuid uid2, int rank1, int rank2)
        {
            //check permission: Admin
              PrincipalPermission permAdm = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            m_DataContext.ndihdKefDownloadChangeRank(uid1, uid2, rank1, rank2);
            TraceCallReturnEvent.Raise();
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 43
0
        public IPermission Union(IPermission target)
        {
            // Handle the easy cases first.
            if (target == null)
            {
                return(Copy());
            }
            else if (!(target is PrincipalPermission))
            {
                throw new ArgumentException(_("Arg_PermissionMismatch"));
            }
            else if (IsUnrestricted() ||
                     ((PrincipalPermission)target).IsUnrestricted())
            {
                return(new PrincipalPermission
                           (PermissionState.Unrestricted));
            }

            // Form the union of the two lists.
            PrincipalPermission perm =
                new PrincipalPermission(this, true);
            PrincipalInfo other, newPrin;

            foreach (PrincipalInfo prin in ((PrincipalPermission)target)
                     .principals)
            {
                other = perm.Find(prin.name, prin.role);
                if (other == null)
                {
                    newPrin                 = new PrincipalInfo();
                    newPrin.name            = prin.name;
                    newPrin.role            = prin.role;
                    newPrin.isAuthenticated = prin.isAuthenticated;
                    perm.principals.Add(newPrin);
                }
                else
                {
                    other.isAuthenticated =
                        (prin.isAuthenticated || other.isAuthenticated);
                }
            }
            return(perm);
        }
Esempio n. 44
0
        public IPermission Intersect(IPermission target)
        {
            // Handle the easy cases first.
            if (target == null)
            {
                return(target);
            }
            else if (!(target is PrincipalPermission))
            {
                throw new ArgumentException(_("Arg_PermissionMismatch"));
            }
            else if (((PrincipalPermission)target).IsUnrestricted())
            {
                if (IsUnrestricted())
                {
                    return(Copy());
                }
            }
            else if (IsUnrestricted())
            {
                return(target.Copy());
            }

            // Form the intersection of the two principal lists.
            PrincipalPermission perm = new PrincipalPermission(this, false);
            PrincipalInfo       other, newPrin;

            foreach (PrincipalInfo prin in principals)
            {
                other = Find(prin.name, prin.role);
                if (other != null)
                {
                    newPrin                 = new PrincipalInfo();
                    newPrin.name            = prin.name;
                    newPrin.role            = prin.role;
                    newPrin.isAuthenticated = prin.isAuthenticated &&
                                              other.isAuthenticated;
                    perm.principals.Add(newPrin);
                }
            }
            return(perm);
        }
        public new void ProgramPartnerDelete(ProgramPartner entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // logical checks:
            ProgramService progSrv = new ProgramService();
            Program selected = progSrv.ProgramSelect(entity.ProgramRef);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");
            if (!selected.IsActive)
              throw new ApplicationException("A program nem aktív.");

            // check permission: Writer or Admin
            string writerRole = selected.OrganisationRef.Value.ToString() + ".Writer";
            PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
            PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
            permWriter.Union(permAdmin).Demand();

            // save data:
            base.ProgramPartnerDelete(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 46
0
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(this.Copy());
            }
            else if (!VerifyType(other))
            {
                throw new
                      ArgumentException(
                          Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                          );
            }

            PrincipalPermission operand = (PrincipalPermission)other;

            if (this.IsUnrestricted() || operand.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }

            // Now we have to do a real union

            int combinedLength = this.m_array.Length + operand.m_array.Length;

            IDRole[] idrolesArray = new IDRole[combinedLength];

            int i, j;

            for (i = 0; i < this.m_array.Length; ++i)
            {
                idrolesArray[i] = this.m_array[i];
            }

            for (j = 0; j < operand.m_array.Length; ++j)
            {
                idrolesArray[i + j] = operand.m_array[j];
            }

            return(new PrincipalPermission(idrolesArray));
        }
Esempio n. 47
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            PrincipalPermission pp = (obj as PrincipalPermission);

            if (pp == null)
            {
                return(false);
            }

            // same number of principals ?
            if (principals.Count != pp.principals.Count)
            {
                return(false);
            }

            // then all principals in "this" should be in "pp"
            foreach (PrincipalInfo pi in principals)
            {
                bool thisItem = false;
                foreach (PrincipalInfo opi in pp.principals)
                {
                    if (((pi.Name == opi.Name) || (opi.Name == null)) &&
                        ((pi.Role == opi.Role) || (opi.Role == null)) &&
                        (pi.IsAuthenticated == opi.IsAuthenticated))
                    {
                        thisItem = true;
                        break;
                    }
                }
                if (!thisItem)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 48
0
        /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
        /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
        /// <param name="other">A permission to combine with the current permission. It must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="other" /> parameter is an object that is not of the same type as the current permission. </exception>
        public IPermission Union(IPermission other)
        {
            PrincipalPermission principalPermission = this.Cast(other);

            if (principalPermission == null)
            {
                return(this.Copy());
            }
            if (this.IsUnrestricted() || principalPermission.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }
            PrincipalPermission principalPermission2 = new PrincipalPermission(this.principals);

            foreach (object obj in principalPermission.principals)
            {
                PrincipalPermission.PrincipalInfo value = (PrincipalPermission.PrincipalInfo)obj;
                principalPermission2.principals.Add(value);
            }
            return(principalPermission2);
        }
Esempio n. 49
0
 /// <summary>确定当前权限是否为指定权限的子集。</summary>
 /// <returns>如果当前权限是指定权限的子集,则为 true;否则为 false。</returns>
 /// <param name="target">将要测试子集关系的权限。此权限必须与当前权限属于同一类型。</param>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="target" /> 参数是与当前权限属于不同类型的对象。</exception>
 public bool IsSubsetOf(IPermission target)
 {
     if (target == null)
     {
         return(this.IsEmpty());
     }
     try
     {
         PrincipalPermission principalPermission = (PrincipalPermission)target;
         if (principalPermission.IsUnrestricted())
         {
             return(true);
         }
         if (this.IsUnrestricted())
         {
             return(false);
         }
         for (int index1 = 0; index1 < this.m_array.Length; ++index1)
         {
             bool flag = false;
             for (int index2 = 0; index2 < principalPermission.m_array.Length; ++index2)
             {
                 if (principalPermission.m_array[index2].m_authenticated == this.m_array[index1].m_authenticated && (principalPermission.m_array[index2].m_id == null || this.m_array[index1].m_id != null && this.m_array[index1].m_id.Equals(principalPermission.m_array[index2].m_id)) && (principalPermission.m_array[index2].m_role == null || this.m_array[index1].m_role != null && this.m_array[index1].m_role.Equals(principalPermission.m_array[index2].m_role)))
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 return(false);
             }
         }
         return(true);
     }
     catch (InvalidCastException ex)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
     }
 }
Esempio n. 50
0
        public bool IsSubsetOf(IPermission target)
        {
            PrincipalPermission pp = Cast(target);

            if (pp == null)
            {
                return(IsEmpty());
            }

            if (IsUnrestricted())
            {
                return(pp.IsUnrestricted());
            }
            else if (pp.IsUnrestricted())
            {
                return(true);
            }

            // each must be a subset of the target
            foreach (PrincipalInfo pi in principals)
            {
                bool thisItem = false;
                foreach (PrincipalInfo opi in pp.principals)
                {
                    if (((pi.Name == opi.Name) || (opi.Name == null)) &&
                        ((pi.Role == opi.Role) || (opi.Role == null)) &&
                        (pi.IsAuthenticated == opi.IsAuthenticated))
                    {
                        thisItem = true;
                    }
                }
                if (!thisItem)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 51
0
        public IPermission Union(IPermission target)
        {
            PrincipalPermission pp = Cast(target);

            if (pp == null)
            {
                return(Copy());
            }

            if (IsUnrestricted() || pp.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }

            PrincipalPermission union = new PrincipalPermission(principals);

            foreach (PrincipalInfo pi in pp.principals)
            {
                union.principals.Add(pi);
            }

            return(union);
        }
Esempio n. 52
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            PrincipalPermission principalPermission = obj as PrincipalPermission;

            if (principalPermission == null)
            {
                return(false);
            }
            if (this.principals.Count != principalPermission.principals.Count)
            {
                return(false);
            }
            foreach (object obj2 in this.principals)
            {
                PrincipalPermission.PrincipalInfo principalInfo = (PrincipalPermission.PrincipalInfo)obj2;
                bool flag = false;
                foreach (object obj3 in principalPermission.principals)
                {
                    PrincipalPermission.PrincipalInfo principalInfo2 = (PrincipalPermission.PrincipalInfo)obj3;
                    if ((principalInfo.Name == principalInfo2.Name || principalInfo2.Name == null) && (principalInfo.Role == principalInfo2.Role || principalInfo2.Role == null) && principalInfo.IsAuthenticated == principalInfo2.IsAuthenticated)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 53
0
        public IPermission Union(IPermission other)
        {
            if (other == null)
            {
                return(Copy());
            }
            else if (!VerifyType(other))
            {
                throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
            }

            PrincipalPermission operand = (PrincipalPermission)other;

            if (IsUnrestricted() || operand.IsUnrestricted())
            {
                return(new PrincipalPermission(PermissionState.Unrestricted));
            }

            IDRole[] idrolesArray = new IDRole[_idArray.Length + operand._idArray.Length];
            Array.Copy(_idArray, 0, idrolesArray, 0, _idArray.Length);
            Array.Copy(operand._idArray, 0, idrolesArray, _idArray.Length, operand._idArray.Length);

            return(new PrincipalPermission(idrolesArray));
        }
Esempio n. 54
0
 /// <internalonly/>
 int IBuiltInPermission.GetTokenIndex()
 {
     return(PrincipalPermission.GetTokenIndex());
 }
Esempio n. 55
0
        /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
        /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission. </param>
        /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission will be <see langword="null" /> if the intersection is empty.</returns>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not <see langword="null" /> and is not an instance of the same class as the current permission. </exception>
        // Token: 0x06002608 RID: 9736 RVA: 0x00088FB4 File Offset: 0x000871B4
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            if (!this.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            if (this.IsUnrestricted())
            {
                return(target.Copy());
            }
            PrincipalPermission principalPermission = (PrincipalPermission)target;

            if (principalPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            List <IDRole> list = null;

            for (int i = 0; i < this.m_array.Length; i++)
            {
                for (int j = 0; j < principalPermission.m_array.Length; j++)
                {
                    if (principalPermission.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
                    {
                        if (principalPermission.m_array[j].m_id == null || this.m_array[i].m_id == null || this.m_array[i].m_id.Equals(principalPermission.m_array[j].m_id))
                        {
                            if (list == null)
                            {
                                list = new List <IDRole>();
                            }
                            IDRole idrole = new IDRole();
                            idrole.m_id = ((principalPermission.m_array[j].m_id == null) ? this.m_array[i].m_id : principalPermission.m_array[j].m_id);
                            if (principalPermission.m_array[j].m_role == null || this.m_array[i].m_role == null || this.m_array[i].m_role.Equals(principalPermission.m_array[j].m_role))
                            {
                                idrole.m_role = ((principalPermission.m_array[j].m_role == null) ? this.m_array[i].m_role : principalPermission.m_array[j].m_role);
                            }
                            else
                            {
                                idrole.m_role = "";
                            }
                            idrole.m_authenticated = principalPermission.m_array[j].m_authenticated;
                            list.Add(idrole);
                        }
                        else if (principalPermission.m_array[j].m_role == null || this.m_array[i].m_role == null || this.m_array[i].m_role.Equals(principalPermission.m_array[j].m_role))
                        {
                            if (list == null)
                            {
                                list = new List <IDRole>();
                            }
                            list.Add(new IDRole
                            {
                                m_id            = "",
                                m_role          = ((principalPermission.m_array[j].m_role == null) ? this.m_array[i].m_role : principalPermission.m_array[j].m_role),
                                m_authenticated = principalPermission.m_array[j].m_authenticated
                            });
                        }
                    }
                }
            }
            if (list == null)
            {
                return(null);
            }
            IDRole[]    array      = new IDRole[list.Count];
            IEnumerator enumerator = list.GetEnumerator();
            int         num        = 0;

            while (enumerator.MoveNext())
            {
                object obj = enumerator.Current;
                array[num++] = (IDRole)obj;
            }
            return(new PrincipalPermission(array));
        }
Esempio n. 56
0
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            else if (!VerifyType(target))
            {
                throw new
                      ArgumentException(
                          Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                          );
            }
            else if (this.IsUnrestricted())
            {
                return(target.Copy());
            }

            PrincipalPermission operand = (PrincipalPermission)target;

            if (operand.IsUnrestricted())
            {
                return(this.Copy());
            }

            List <IDRole> idroles = null;

            for (int i = 0; i < this.m_array.Length; ++i)
            {
                for (int j = 0; j < operand.m_array.Length; ++j)
                {
                    if (operand.m_array[j].m_authenticated == this.m_array[i].m_authenticated)
                    {
                        if (operand.m_array[j].m_id == null ||
                            this.m_array[i].m_id == null ||
                            this.m_array[i].m_id.Equals(operand.m_array[j].m_id))
                        {
                            if (idroles == null)
                            {
                                idroles = new List <IDRole>();
                            }

                            IDRole idrole = new IDRole();

                            idrole.m_id = operand.m_array[j].m_id == null ? this.m_array[i].m_id : operand.m_array[j].m_id;

                            if (operand.m_array[j].m_role == null ||
                                this.m_array[i].m_role == null ||
                                this.m_array[i].m_role.Equals(operand.m_array[j].m_role))
                            {
                                idrole.m_role = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            }
                            else
                            {
                                idrole.m_role = "";
                            }

                            idrole.m_authenticated = operand.m_array[j].m_authenticated;

                            idroles.Add(idrole);
                        }
                        else if (operand.m_array[j].m_role == null ||
                                 this.m_array[i].m_role == null ||
                                 this.m_array[i].m_role.Equals(operand.m_array[j].m_role))
                        {
                            if (idroles == null)
                            {
                                idroles = new List <IDRole>();
                            }

                            IDRole idrole = new IDRole();

                            idrole.m_id            = "";
                            idrole.m_role          = operand.m_array[j].m_role == null ? this.m_array[i].m_role : operand.m_array[j].m_role;
                            idrole.m_authenticated = operand.m_array[j].m_authenticated;

                            idroles.Add(idrole);
                        }
                    }
                }
            }

            if (idroles == null)
            {
                return(null);
            }
            else
            {
                IDRole[] idrolesArray = new IDRole[idroles.Count];

                IEnumerator idrolesEnumerator = idroles.GetEnumerator();
                int         index             = 0;

                while (idrolesEnumerator.MoveNext())
                {
                    idrolesArray[index++] = (IDRole)idrolesEnumerator.Current;
                }

                return(new PrincipalPermission(idrolesArray));
            }
        }
Esempio n. 57
0
        /// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary>
        /// <returns>一个新权限,它表示当前权限与指定权限的交集。交集为空时,新权限将为 null。</returns>
        /// <param name="target">要与当前权限相交的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="target" /> 参数不为 null,并且不是与当前权限属于相同类的实例。</exception>
        public IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return((IPermission)null);
            }
            if (!this.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            if (this.IsUnrestricted())
            {
                return(target.Copy());
            }
            PrincipalPermission principalPermission = (PrincipalPermission)target;

            if (principalPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            List <IDRole> idRoleList = (List <IDRole>)null;

            for (int index1 = 0; index1 < this.m_array.Length; ++index1)
            {
                for (int index2 = 0; index2 < principalPermission.m_array.Length; ++index2)
                {
                    if (principalPermission.m_array[index2].m_authenticated == this.m_array[index1].m_authenticated)
                    {
                        if (principalPermission.m_array[index2].m_id == null || this.m_array[index1].m_id == null || this.m_array[index1].m_id.Equals(principalPermission.m_array[index2].m_id))
                        {
                            if (idRoleList == null)
                            {
                                idRoleList = new List <IDRole>();
                            }
                            idRoleList.Add(new IDRole()
                            {
                                m_id            = principalPermission.m_array[index2].m_id == null ? this.m_array[index1].m_id : principalPermission.m_array[index2].m_id,
                                m_role          = principalPermission.m_array[index2].m_role == null || this.m_array[index1].m_role == null || this.m_array[index1].m_role.Equals(principalPermission.m_array[index2].m_role) ? (principalPermission.m_array[index2].m_role == null ? this.m_array[index1].m_role : principalPermission.m_array[index2].m_role) : "",
                                m_authenticated = principalPermission.m_array[index2].m_authenticated
                            });
                        }
                        else if (principalPermission.m_array[index2].m_role == null || this.m_array[index1].m_role == null || this.m_array[index1].m_role.Equals(principalPermission.m_array[index2].m_role))
                        {
                            if (idRoleList == null)
                            {
                                idRoleList = new List <IDRole>();
                            }
                            idRoleList.Add(new IDRole()
                            {
                                m_id            = "",
                                m_role          = principalPermission.m_array[index2].m_role == null ? this.m_array[index1].m_role : principalPermission.m_array[index2].m_role,
                                m_authenticated = principalPermission.m_array[index2].m_authenticated
                            });
                        }
                    }
                }
            }
            if (idRoleList == null)
            {
                return((IPermission)null);
            }
            IDRole[]    array      = new IDRole[idRoleList.Count];
            IEnumerator enumerator = (IEnumerator)idRoleList.GetEnumerator();
            int         num        = 0;

            while (enumerator.MoveNext())
            {
                array[num++] = (IDRole)enumerator.Current;
            }
            return((IPermission) new PrincipalPermission(array));
        }