// Form the intersection of two permission objects. public override IPermission Intersect(IPermission target) { if (target == null) { return(target); } else if (target.GetType() != GetType()) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if (((ResourcePermissionBase)target).IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } ResourcePermissionBase perm; perm = (ResourcePermissionBase)(target.Copy()); perm.Clear(); foreach (ResourcePermissionBaseEntry entry in permissions) { if (((ResourcePermissionBase)target).Contains(entry)) { perm.AddPermissionAccess(entry); } } return(perm); }
/// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary> /// <returns>一个新权限,它表示当前权限与指定权限的交集。如果交集为空,则此新权限为 null。</returns> /// <param name="target">与当前权限对象相交的权限。它必须与当前权限属于同一类型。</param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> 参数不是 null,而且与当前权限不是同一类型。</exception> public override 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)); } IsolatedStorageFilePermission storageFilePermission1 = (IsolatedStorageFilePermission)target; if (storageFilePermission1.IsUnrestricted()) { return(this.Copy()); } if (this.IsUnrestricted()) { return(target.Copy()); } IsolatedStorageFilePermission storageFilePermission2 = new IsolatedStorageFilePermission(PermissionState.None); storageFilePermission2.m_userQuota = IsolatedStoragePermission.min(this.m_userQuota, storageFilePermission1.m_userQuota); storageFilePermission2.m_machineQuota = IsolatedStoragePermission.min(this.m_machineQuota, storageFilePermission1.m_machineQuota); storageFilePermission2.m_expirationDays = IsolatedStoragePermission.min(this.m_expirationDays, storageFilePermission1.m_expirationDays); storageFilePermission2.m_permanentData = this.m_permanentData && storageFilePermission1.m_permanentData; storageFilePermission2.m_allowed = (IsolatedStorageContainment)IsolatedStoragePermission.min((long)this.m_allowed, (long)storageFilePermission1.m_allowed); if (storageFilePermission2.m_userQuota == 0L && storageFilePermission2.m_machineQuota == 0L && (storageFilePermission2.m_expirationDays == 0L && !storageFilePermission2.m_permanentData) && storageFilePermission2.m_allowed == IsolatedStorageContainment.None) { return((IPermission)null); } return((IPermission)storageFilePermission2); }
public override IPermission Union(IPermission target) { if (target == null) { return(this.Copy()); } if (target.GetType() != base.GetType()) { throw ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { return(this.Copy()); } DBDataPermission permission = (DBDataPermission)target.Copy(); if (!permission.IsUnrestricted()) { permission._allowBlankPassword |= this.AllowBlankPassword; if (this._keyvalues != null) { foreach (DBConnectionString str in this._keyvalues) { permission.AddPermissionEntry(str); } } } if (!permission.IsEmpty()) { return(permission); } return(null); }
//-----------------------------------------------------------+ // H E L P E R //-----------------------------------------------------------+ private PermissionSet CreateSingletonSet(IPermission perm) { PermissionSet permSet = new PermissionSet(false); permSet.AddPermission(perm.Copy()); return(permSet); }
/// <include file='doc\DBDataPermission.uex' path='docs/doc[@for="DBDataPermission.Union"]/*' /> override public IPermission Union(IPermission target) { if (null == target) { return(this.Copy()); } if (target.GetType() != this.GetType()) { throw ADP.Argument("target"); } if (IsUnrestricted()) // MDAC 84803 { return(this.Copy()); } DBDataPermission newPermission = (DBDataPermission)target.Copy(); if (!newPermission.IsUnrestricted()) { newPermission._allowBlankPassword |= AllowBlankPassword; if (null != _keyvalues) { foreach (DBConnectionString entry in _keyvalues) { newPermission.AddEntry(entry); } } } return(newPermission); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } IsolatedStorageFilePermission permission = (IsolatedStorageFilePermission)target; if (permission.IsUnrestricted()) { return(this.Copy()); } if (base.IsUnrestricted()) { return(target.Copy()); } IsolatedStorageFilePermission permission2 = new IsolatedStorageFilePermission(PermissionState.None) { m_userQuota = IsolatedStoragePermission.min(base.m_userQuota, permission.m_userQuota), m_machineQuota = IsolatedStoragePermission.min(base.m_machineQuota, permission.m_machineQuota), m_expirationDays = IsolatedStoragePermission.min(base.m_expirationDays, permission.m_expirationDays), m_permanentData = base.m_permanentData && permission.m_permanentData, m_allowed = (IsolatedStorageContainment)((int)IsolatedStoragePermission.min((long)base.m_allowed, (long)permission.m_allowed)) }; if ((((permission2.m_userQuota == 0L) && (permission2.m_machineQuota == 0L)) && ((permission2.m_expirationDays == 0L) && !permission2.m_permanentData)) && (permission2.m_allowed == IsolatedStorageContainment.None)) { return(null); } return(permission2); }
public override 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()); } RegistryPermission registryPermission = (RegistryPermission)target; if (registryPermission.IsUnrestricted()) { return(this.Copy()); } StringExpressionSet stringExpressionSet1 = this.m_read == null ? (StringExpressionSet)null : this.m_read.Intersect(registryPermission.m_read); StringExpressionSet stringExpressionSet2 = this.m_write == null ? (StringExpressionSet)null : this.m_write.Intersect(registryPermission.m_write); StringExpressionSet stringExpressionSet3 = this.m_create == null ? (StringExpressionSet)null : this.m_create.Intersect(registryPermission.m_create); StringExpressionSet stringExpressionSet4 = this.m_viewAcl == null ? (StringExpressionSet)null : this.m_viewAcl.Intersect(registryPermission.m_viewAcl); StringExpressionSet stringExpressionSet5 = this.m_changeAcl == null ? (StringExpressionSet)null : this.m_changeAcl.Intersect(registryPermission.m_changeAcl); if ((stringExpressionSet1 == null || stringExpressionSet1.IsEmpty()) && (stringExpressionSet2 == null || stringExpressionSet2.IsEmpty()) && ((stringExpressionSet3 == null || stringExpressionSet3.IsEmpty()) && (stringExpressionSet4 == null || stringExpressionSet4.IsEmpty())) && (stringExpressionSet5 == null || stringExpressionSet5.IsEmpty())) { return((IPermission)null); } return((IPermission) new RegistryPermission(PermissionState.None) { m_unrestricted = false, m_read = stringExpressionSet1, m_write = stringExpressionSet2, m_create = stringExpressionSet3, m_viewAcl = stringExpressionSet4, m_changeAcl = stringExpressionSet5 }); }
override public IPermission Union(IPermission target) { if (null == target) { return(this.Copy()); } if (target.GetType() != this.GetType()) { throw ADP.PermissionTypeMismatch(); } if (IsUnrestricted()) { // MDAC 84803 return(this.Copy()); } SqlClientPermission newPermission = (SqlClientPermission)target.Copy(); if (!newPermission.IsUnrestricted()) { newPermission.AllowBlankPassword |= AllowBlankPassword; if (null != _keyvalues) { foreach (DBConnectionString entry in _keyvalues) { newPermission.AddPermissionEntry(entry); } } } return(newPermission.IsEmpty() ? null : newPermission); }
public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is ZoneIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } SecurityZone otherZone = ((ZoneIdentityPermission)target).zone; if (zone == otherZone || otherZone == SecurityZone.NoZone) { return(Copy()); } else if (zone == SecurityZone.NoZone) { return(target.Copy()); } else { return(null); } }
/// <include file='doc\PublisherIdentityPermission.uex' path='docs/doc[@for="PublisherIdentityPermission.Union"]/*' /> public override IPermission Union(IPermission target) { if (target == null) { return(this.m_certificate != null?this.Copy() : null); } else if (!VerifyType(target)) { throw new ArgumentException( String.Format(Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName) ); } PublisherIdentityPermission operand = (PublisherIdentityPermission)target; if (this.m_certificate == null) { return(operand.m_certificate != null?target.Copy() : null); } else if (operand.m_certificate == null || this.m_certificate.Equals(((PublisherIdentityPermission)target).m_certificate)) { return(this.Copy()); } else { return(null); } }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.IsUnrestricted()) { return(target.Copy()); } RegistryPermission permission = (RegistryPermission)target; if (permission.IsUnrestricted()) { return(this.Copy()); } StringExpressionSet set = (this.m_read == null) ? null : this.m_read.Intersect(permission.m_read); StringExpressionSet set2 = (this.m_write == null) ? null : this.m_write.Intersect(permission.m_write); StringExpressionSet set3 = (this.m_create == null) ? null : this.m_create.Intersect(permission.m_create); StringExpressionSet set4 = (this.m_viewAcl == null) ? null : this.m_viewAcl.Intersect(permission.m_viewAcl); StringExpressionSet set5 = (this.m_changeAcl == null) ? null : this.m_changeAcl.Intersect(permission.m_changeAcl); if (((((set == null) || set.IsEmpty()) && ((set2 == null) || set2.IsEmpty())) && (((set3 == null) || set3.IsEmpty()) && ((set4 == null) || set4.IsEmpty()))) && ((set5 == null) || set5.IsEmpty())) { return(null); } return(new RegistryPermission(PermissionState.None) { m_unrestricted = false, m_read = set, m_write = set2, m_create = set3, m_viewAcl = set4, m_changeAcl = set5 }); }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if (target == null) { return(target); } else if (!(target is FileIOPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (((FileIOPermission)target).IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } // Create a new object and intersect the lists. return(new FileIOPermission (PermissionState.None, EnvironmentPermission.Intersect(readList, ((FileIOPermission)target).readList), EnvironmentPermission.Intersect(writeList, ((FileIOPermission)target).writeList), EnvironmentPermission.Intersect(appendList, ((FileIOPermission)target).appendList), EnvironmentPermission.Intersect(discoveryList, ((FileIOPermission)target).discoveryList), allLocalFiles & ((FileIOPermission)target).allLocalFiles, allFiles & ((FileIOPermission)target).allFiles)); }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if (target == null) { return(target); } else if (!(target is EnvironmentPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (((EnvironmentPermission)target).IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } // Create a new object and intersect the lists. return(new EnvironmentPermission (PermissionState.None, Intersect(readList, ((EnvironmentPermission)target).readList), Intersect(writeList, ((EnvironmentPermission)target).writeList))); }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } IsolatedStorageFilePermission permission = (IsolatedStorageFilePermission) target; if (permission.IsUnrestricted()) { return this.Copy(); } if (base.IsUnrestricted()) { return target.Copy(); } IsolatedStorageFilePermission permission2 = new IsolatedStorageFilePermission(PermissionState.None) { m_userQuota = IsolatedStoragePermission.min(base.m_userQuota, permission.m_userQuota), m_machineQuota = IsolatedStoragePermission.min(base.m_machineQuota, permission.m_machineQuota), m_expirationDays = IsolatedStoragePermission.min(base.m_expirationDays, permission.m_expirationDays), m_permanentData = base.m_permanentData && permission.m_permanentData, m_allowed = (IsolatedStorageContainment) ((int) IsolatedStoragePermission.min((long) base.m_allowed, (long) permission.m_allowed)) }; if ((((permission2.m_userQuota == 0L) && (permission2.m_machineQuota == 0L)) && ((permission2.m_expirationDays == 0L) && !permission2.m_permanentData)) && (permission2.m_allowed == IsolatedStorageContainment.None)) { return null; } return permission2; }
// Form the union of two permission objects. public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (target.GetType() != GetType()) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if (IsUnrestricted() || ((ResourcePermissionBase)target).IsUnrestricted()) { return((ResourcePermissionBase)Activator.CreateInstance (GetType(), new Object [] { PermissionState.Unrestricted })); } else { ResourcePermissionBase perm; perm = (ResourcePermissionBase)(target.Copy()); foreach (ResourcePermissionBaseEntry entry in permissions) { if (!perm.Contains(entry)) { perm.AddPermissionAccess(entry); } } return(perm); } }
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())); }
protected override IPermission GetPermissionImpl(Type permClass) { IPermission permissionImpl = base.GetPermissionImpl(permClass); if (permissionImpl == null) { return(null); } return(permissionImpl.Copy()); }
public override 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()); } RegistryPermission operand = (RegistryPermission)target; if (operand.IsUnrestricted()) { return(this.Copy()); } StringExpressionSet intersectRead = this.m_read == null ? null : this.m_read.Intersect(operand.m_read); StringExpressionSet intersectWrite = this.m_write == null ? null : this.m_write.Intersect(operand.m_write); StringExpressionSet intersectCreate = this.m_create == null ? null : this.m_create.Intersect(operand.m_create); StringExpressionSet intersectViewAcl = this.m_viewAcl == null ? null : this.m_viewAcl.Intersect(operand.m_viewAcl); StringExpressionSet intersectChangeAcl = this.m_changeAcl == null ? null : this.m_changeAcl.Intersect(operand.m_changeAcl); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty()) && (intersectCreate == null || intersectCreate.IsEmpty()) && (intersectViewAcl == null || intersectViewAcl.IsEmpty()) && (intersectChangeAcl == null || intersectChangeAcl.IsEmpty())) { return(null); } RegistryPermission intersectPermission = new RegistryPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; intersectPermission.m_create = intersectCreate; intersectPermission.m_viewAcl = intersectViewAcl; intersectPermission.m_changeAcl = intersectChangeAcl; return(intersectPermission); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } FileIOPermission operand = target as FileIOPermission; if (operand == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); } else if (this.IsUnrestricted()) { return(target.Copy()); } if (operand.IsUnrestricted()) { return(this.Copy()); } FileIOAccess intersectRead = this.m_read == null ? null : this.m_read.Intersect(operand.m_read); FileIOAccess intersectWrite = this.m_write == null ? null : this.m_write.Intersect(operand.m_write); FileIOAccess intersectAppend = this.m_append == null ? null : this.m_append.Intersect(operand.m_append); FileIOAccess intersectPathDiscovery = this.m_pathDiscovery == null ? null : this.m_pathDiscovery.Intersect(operand.m_pathDiscovery); FileIOAccess intersectViewAcl = this.m_viewAcl == null ? null : this.m_viewAcl.Intersect(operand.m_viewAcl); FileIOAccess intersectChangeAcl = this.m_changeAcl == null ? null : this.m_changeAcl.Intersect(operand.m_changeAcl); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty()) && (intersectAppend == null || intersectAppend.IsEmpty()) && (intersectPathDiscovery == null || intersectPathDiscovery.IsEmpty()) && (intersectViewAcl == null || intersectViewAcl.IsEmpty()) && (intersectChangeAcl == null || intersectChangeAcl.IsEmpty())) { return(null); } FileIOPermission intersectPermission = new FileIOPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; intersectPermission.m_append = intersectAppend; intersectPermission.m_pathDiscovery = intersectPathDiscovery; intersectPermission.m_viewAcl = intersectViewAcl; intersectPermission.m_changeAcl = intersectChangeAcl; return(intersectPermission); }
/// <summary> /// Return a new permission with the intersection of claims. /// Issuer must be an exact match. /// Intersecting claims are added to a new ClaimSet by the same issuer. /// </summary> /// <param name="target"></param> /// <returns></returns> public IPermission Intersect(IPermission target) { if (target == null) { return(null); } ClaimsPrincipalPermission perm = target as ClaimsPrincipalPermission; if (perm == null) { return(null); } if (this.IsUnrestricted()) { return(target.Copy()); } if (perm.IsUnrestricted()) { return(this.Copy()); } if (this.m_isAuthenticated != perm.IsAuthenticated) { return(null); } if (!IsExactIssuerMatch(perm.Issuer)) { return(null); } List <Claim> claims = new List <Claim>(); foreach (Claim c in this.m_requiredClaims) { if (perm.RequiredClaims.ContainsClaim(c)) { claims.Add(c); } } // it is assumed that the issuers are identical from the call // to IsExactIssuerMatch() above ClaimsPrincipalPermission newPerm = new ClaimsPrincipalPermission(this.m_isAuthenticated, new DefaultClaimSet(this.m_requiredClaims.Issuer, claims)); return(newPerm); }
override public IPermission Intersect(IPermission target) { // used during Deny actions if (null == target) { return(null); } if (target.GetType() != this.GetType()) { throw ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { // MDAC 84803, NDPWhidbey 29121 return(target.Copy()); } DBDataPermission operand = (DBDataPermission)target; if (operand.IsUnrestricted()) { // NDPWhidbey 29121 return(this.Copy()); } SqlClientPermission newPermission = (SqlClientPermission)operand.Copy(); newPermission.AllowBlankPassword &= AllowBlankPassword; if ((null != _keyvalues) && (null != newPermission._keyvalues)) { newPermission._keyvalues.Clear(); newPermission._keyvaluetree.Intersect(newPermission._keyvalues, _keyvaluetree); } else { // either target.Add or this.Add have not been called // return a non-null object so IsSubset calls will fail newPermission._keyvalues = null; newPermission._keyvaluetree = null; } if (newPermission.IsEmpty()) { // no intersection, MDAC 86773 newPermission = null; } return(newPermission); }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if (target == null) { return(target); } else if (!(target is UIPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (((UIPermission)target) .IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } // Get the minimum flag values. UIPermissionWindow w = ((UIPermission)target).window; if (((int)w) > ((int)window)) { w = window; } UIPermissionClipboard c = ((UIPermission)target).clipboard; if (((int)c) > ((int)clipboard)) { c = clipboard; } // Create a new object for the intersection. if (w == UIPermissionWindow.NoWindows && c == UIPermissionClipboard.NoClipboard) { return(null); } else { return(new UIPermission(w, c)); } }
/// <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 is null if the intersection is empty.</returns> public IPermission Intersect(IPermission target) { // An intersection operation isn't possible unless both operands employ the same permissioning scheme. if (target is ClaimsPrincipalPermission) { // This is the source Permission scheme for the operation. ClaimsPrincipalPermission targetPermission = target as ClaimsPrincipalPermission; // If this permission scheme allows unrestricted access, then it has nothing it can add to the intersection of the // two schemes. if (this.IsUnrestricted()) { return(target.Copy()); } // If the other permission scheme is unrestricted, it has nothing to add to the intersection of the two schemes. if (targetPermission.IsUnrestricted()) { return(this.Copy()); } // Both permission schemes must share the requirement that the user is authenticated and both issuers must be the // same for the claims to be merged. if (this.isAuthenticated == targetPermission.IsAuthenticated && IsExactIssuerMatch(targetPermission.Issuer)) { // This creates a list that is the intersection of the claims in the two permission schemes. List <Claim> claims = new List <Claim>(); foreach (Claim claim in this.requiredClaims) { if (targetPermission.RequiredClaims.ContainsClaim(claim)) { claims.Add(claim); } } // Once the set of interesecting claims is created, the permission scheme can be created. It is known at this // point that the authenticated state of the user and the issuer are equivalent. return(new ClaimsPrincipalPermission(this.isAuthenticated, new DefaultClaimSet(this.requiredClaims.Issuer, claims))); } } // An intersection of the two permission schemes could not be constructed at this point. return(null); }
/// <include file='doc\IsolatedStorageFilePermission.uex' path='docs/doc[@for="IsolatedStorageFilePermission.Intersect"]/*' /> public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } else if (!VerifyType(target)) { throw new ArgumentException( String.Format(Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName) ); } IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target; if (operand.IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } IsolatedStorageFilePermission intersection; intersection = new IsolatedStorageFilePermission(PermissionState.None); intersection.m_userQuota = min(m_userQuota, operand.m_userQuota); intersection.m_machineQuota = min(m_machineQuota, operand.m_machineQuota); intersection.m_expirationDays = min(m_expirationDays, operand.m_expirationDays); intersection.m_permanentData = m_permanentData && operand.m_permanentData; intersection.m_allowed = (IsolatedStorageContainment)min((long)m_allowed, (long)operand.m_allowed); if ((intersection.m_userQuota == 0) && (intersection.m_machineQuota == 0) && (intersection.m_expirationDays == 0) && (intersection.m_permanentData == false) && (intersection.m_allowed == IsolatedStorageContainment.None)) { return(null); } return(intersection); }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if (target == null) { return(target); } else if (!(target is IsolatedStorageFilePermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (((IsolatedStorageFilePermission)target) .IsUnrestricted()) { return(Copy()); } else if (IsUnrestricted()) { return(target.Copy()); } // Get the minimum quota and containment values. long quota = ((IsolatedStorageFilePermission)target).userQuota; if (quota > userQuota) { quota = userQuota; } IsolatedStorageContainment allowed; allowed = ((IsolatedStorageFilePermission)target).usageAllowed; if (((int)allowed) > ((int)usageAllowed)) { allowed = usageAllowed; } // Create a new object and intersect the lists. IsolatedStorageFilePermission perm; perm = new IsolatedStorageFilePermission(PermissionState.None); perm.userQuota = quota; perm.usageAllowed = allowed; return(perm); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } else if (!VerifyType(target)) { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName) ); } else if (this.IsUnrestricted()) { return(target.Copy()); } EnvironmentPermission operand = (EnvironmentPermission)target; if (operand.IsUnrestricted()) { return(this.Copy()); } StringExpressionSet intersectRead = this.m_read == null ? null : this.m_read.Intersect(operand.m_read); StringExpressionSet intersectWrite = this.m_write == null ? null : this.m_write.Intersect(operand.m_write); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty())) { return(null); } EnvironmentPermission intersectPermission = new EnvironmentPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; return(intersectPermission); }
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); }
/// <summary> /// Recupera a intercessão da instancia com a permissão informada. /// </summary> /// <param name="target"></param> /// <returns></returns> public IPermission Intersect(IPermission target) { if (target == null) { return(null); } SystemPermission permission = target as SystemPermission; if (permission == null) { throw new ArgumentException(string.Format(Properties.Resources.Argument_WrongType, base.GetType().FullName)); } if (this.IsUnrestricted()) { return(target.Copy()); } if (permission.IsUnrestricted()) { return(this.Copy()); } SystemAccess access = (this._read == null) ? null : this._read.Intersect(permission._read); SystemAccess access2 = (this._write == null) ? null : this._write.Intersect(permission._write); SystemAccess access3 = (this._execute == null) ? null : this._execute.Intersect(permission._execute); SystemAccess access4 = (this._pathDiscovery == null) ? null : this._pathDiscovery.Intersect(permission._pathDiscovery); SystemAccess access5 = (this._viewAcl == null) ? null : this._viewAcl.Intersect(permission._viewAcl); SystemAccess access6 = (this._changeAcl == null) ? null : this._changeAcl.Intersect(permission._changeAcl); if (((((access == null) || access.IsEmpty()) && ((access2 == null) || access2.IsEmpty())) && (((access3 == null) || access3.IsEmpty()) && ((access4 == null) || access4.IsEmpty()))) && (((access5 == null) || access5.IsEmpty()) && ((access6 == null) || access6.IsEmpty()))) { return(null); } SystemPermission permission2 = new SystemPermission(PermissionState.None); permission2._unrestricted = false; permission2._read = access; permission2._write = access2; permission2._execute = access3; permission2._pathDiscovery = access4; permission2._viewAcl = access5; permission2._changeAcl = access6; return(permission2); }
// Create the union of two permission objects. public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is AspNetHostingPermission)) { throw new ArgumentException (S._("Arg_PermissionMismatch")); } else if (level > ((AspNetHostingPermission)target).level) { return(Copy()); } else { return(target.Copy()); } }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if(target == null) { return target; } else if(!(target is IsolatedStorageFilePermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(((IsolatedStorageFilePermission)target) .IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } // Get the minimum quota and containment values. long quota = ((IsolatedStorageFilePermission)target).userQuota; if(quota > userQuota) { quota = userQuota; } IsolatedStorageContainment allowed; allowed = ((IsolatedStorageFilePermission)target).usageAllowed; if(((int)allowed) > ((int)usageAllowed)) { allowed = usageAllowed; } // Create a new object and intersect the lists. IsolatedStorageFilePermission perm; perm = new IsolatedStorageFilePermission(PermissionState.None); perm.userQuota = quota; perm.usageAllowed = allowed; return perm; }
public override IPermission Union(IPermission target) { if (target == null) { return(Copy()); } else if (!(target is UrlIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (url != null) { // Return the first one, because union'ing two // non-empty url identities doesn't make sense. return(Copy()); } else { return(target.Copy()); } }
/// <include file='doc\DBDataPermission.uex' path='docs/doc[@for="DBDataPermission.Intersect"]/*' /> override public IPermission Intersect(IPermission target) // used during Deny actions { if (null == target) { return(null); } if (target.GetType() != this.GetType()) { throw ADP.Argument("target"); } if (IsUnrestricted()) // MDAC 84803 { return(Copy()); } DBDataPermission newPermission = (DBDataPermission)target.Copy(); if (!newPermission.IsUnrestricted()) { newPermission._allowBlankPassword &= AllowBlankPassword; if ((null != _keyvalues) && (null != newPermission._keyvalues)) { newPermission._keyvalues.Clear(); newPermission._keyvaluetree.Intersect(newPermission._keyvalues, _keyvaluetree); } else { // either target.Add or this.Add have not been called // return a non-null object so IsSubset calls will fail newPermission._keyvalues = null; newPermission._keyvaluetree = null; } if (newPermission.IsEmpty()) // MDAC 86773 { newPermission = null; } } return(newPermission); }
public override IPermission Union(IPermission target) { if (target == null) { return this.Copy(); } if (target.GetType() != base.GetType()) { throw System.Data.Common.ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { return this.Copy(); } OraclePermission permission = (OraclePermission) target.Copy(); if (!permission.IsUnrestricted()) { permission._allowBlankPassword |= this.AllowBlankPassword; if (this._keyvalues != null) { foreach (System.Data.OracleClient.DBConnectionString str in this._keyvalues) { permission.AddPermissionEntry(str); } } } if (!permission.IsEmpty()) { return permission; } return null; }
public override IPermission Intersect(IPermission target) { if(target == null) { return target; } else if(!(target is PublisherIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(IsSubsetOf(target)) { return Copy(); } else if(target.IsSubsetOf(this)) { return target.Copy(); } else { return null; } }
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 override IPermission Intersect(IPermission target) { if (target == null) return null; else if (!VerifyType(target)) { throw new ArgumentException( Environment.GetResourceString("Argument_WrongType", this.GetType().FullName) ); } IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target; if(operand.IsUnrestricted()) return Copy(); else if(IsUnrestricted()) return target.Copy(); IsolatedStorageFilePermission intersection; intersection = new IsolatedStorageFilePermission( PermissionState.None ); intersection.m_userQuota = min(m_userQuota,operand.m_userQuota); intersection.m_machineQuota = min(m_machineQuota,operand.m_machineQuota); intersection.m_expirationDays = min(m_expirationDays,operand.m_expirationDays); intersection.m_permanentData = m_permanentData && operand.m_permanentData; intersection.m_allowed = (IsolatedStorageContainment)min((long)m_allowed,(long)operand.m_allowed); if ((intersection.m_userQuota == 0) && (intersection.m_machineQuota == 0) && (intersection.m_expirationDays == 0) && (intersection.m_permanentData == false) && (intersection.m_allowed == IsolatedStorageContainment.None)) return null; return intersection; }
override public IPermission Intersect(IPermission target) { // used during Deny actions if (null == target) { return null; } if (target.GetType() != this.GetType()) { throw ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { // MDAC 84803, NDPWhidbey 29121 return target.Copy(); } DBDataPermission operand = (DBDataPermission) target; if (operand.IsUnrestricted()) { // NDPWhidbey 29121 return this.Copy(); } DBDataPermission newPermission = (DBDataPermission) operand.Copy(); newPermission._allowBlankPassword &= AllowBlankPassword; if ((null != _keyvalues) && (null != newPermission._keyvalues)) { newPermission._keyvalues.Clear(); newPermission._keyvaluetree.Intersect(newPermission._keyvalues, _keyvaluetree); } else { // either target.Add or this.Add have not been called // return a non-null object so IsSubset calls will fail newPermission._keyvalues = null; newPermission._keyvaluetree = null; } if (newPermission.IsEmpty()) { // no intersection, MDAC 86773 newPermission = null; } return newPermission; }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if(target == null) { return target; } else if(!(target is EnvironmentPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(((EnvironmentPermission)target).IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } // Create a new object and intersect the lists. return new EnvironmentPermission (PermissionState.None, Intersect(readList, ((EnvironmentPermission)target).readList), Intersect(writeList, ((EnvironmentPermission)target).writeList)); }
public override IPermission Union(IPermission target) { if(target == null) { return Copy(); } else if(!(target is UrlIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(url != null) { // Return the first one, because union'ing two // non-empty url identities doesn't make sense. return Copy(); } else { return target.Copy(); } }
public override IPermission Intersect(IPermission target) { if(target == null) { return target; } else if(!(target is SocketPermission)) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if(((SocketPermission)target).IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } else { SocketPermission perm = new SocketPermission (PermissionState.None); EndpointPermission newInfo; foreach(EndpointPermission info in permissions) { foreach(EndpointPermission info2 in ((SocketPermission)target).permissions) { newInfo = Intersect(info, info2); if(newInfo != null) { perm.permissions.Add(newInfo); } } } return perm; } }
/// <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 is 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) { //returns a new permission object that represents the intersection of two permissions. //In the ClaimsPrincipalPermission, this is implemented in the following manner: // - If the permission to intersect with is null, null is returned. // - If the permission to intersect with is not a ClaimsPrincipalPermission type, null is returned. // - If either the permission to intersect or this permission is unrestricted, return a copy of the //opposite permission. // - If IsAuthenticated does not match for both permissions, null is returned. // - If ALL of the Issuer claims are not matched, null is returned. The assumption here is that a //developer is providing another permission to intersect with, and they should thus describe the //Issuer with the same set of claims. This simplifies how developers can use these permissions, by //reducing the complexity that would follow if you attempted to intersect the ClaimSet of an Issuer, //and the Issuer’s Issuer, and that Issuer’s Issuer, and so on. In other words, the nature of the //ClaimSet and the nested Issuer claim sets demands simplicity here. //Once the Issuer ClaimSet is verified as a perfect match between permissions, the actual claim sets //can be intersected. So long as they are issued by the same Issuer, the list of required claim sets //in both permissions can be intersected to produce a new ClaimSet by the same Issuer. if (target == null) return null; ClaimsPrincipalPermission perm = target as ClaimsPrincipalPermission; if (perm == null) return null; if (this.IsUnrestricted()) return target.Copy(); if (perm.IsUnrestricted()) return this.Copy(); if (this.isAuthenticated != perm.IsAuthenticated) return null; if (!IsExactIssuerMatch(perm.Issuer)) return null; List<Claim> claims = this.requiredClaims.Where(c => perm.RequiredClaims.ContainsClaim(c)).ToList(); // it is assumed that the issuers are identical from the call // to IsExactIssuerMatch() above ClaimsPrincipalPermission newPerm = new ClaimsPrincipalPermission(this.isAuthenticated, new DefaultClaimSet(this.requiredClaims.Issuer, claims)); return newPerm; }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if(target == null) { return target; } else if(!(target is FileIOPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(((FileIOPermission)target).IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } // Create a new object and intersect the lists. return new FileIOPermission (PermissionState.None, EnvironmentPermission.Intersect(readList, ((FileIOPermission)target).readList), EnvironmentPermission.Intersect(writeList, ((FileIOPermission)target).writeList), EnvironmentPermission.Intersect(appendList, ((FileIOPermission)target).appendList), EnvironmentPermission.Intersect(discoveryList, ((FileIOPermission)target).discoveryList), allLocalFiles & ((FileIOPermission)target).allLocalFiles, allFiles & ((FileIOPermission)target).allFiles); }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } if (target.GetType() != base.GetType()) { throw System.Data.Common.ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { return target.Copy(); } OraclePermission permission2 = (OraclePermission) target; if (permission2.IsUnrestricted()) { return this.Copy(); } OraclePermission permission = (OraclePermission) permission2.Copy(); permission._allowBlankPassword &= this.AllowBlankPassword; if ((this._keyvalues != null) && (permission._keyvalues != null)) { permission._keyvalues.Clear(); permission._keyvaluetree.Intersect(permission._keyvalues, this._keyvaluetree); } else { permission._keyvalues = null; permission._keyvaluetree = null; } if (permission.IsEmpty()) { permission = null; } return permission; }
// Create the union of two permission objects. public override IPermission Union(IPermission target) { if(target == null) { return Copy(); } else if(!(target is AspNetHostingPermission)) { throw new ArgumentException (S._("Arg_PermissionMismatch")); } else if(level > ((AspNetHostingPermission)target).level) { return Copy(); } else { return target.Copy(); } }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } else if (!VerifyType(target)) { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName) ); } else if (this.IsUnrestricted()) { return target.Copy(); } EnvironmentPermission operand = (EnvironmentPermission)target; if (operand.IsUnrestricted()) { return this.Copy(); } StringExpressionSet intersectRead = this.m_read == null ? null : this.m_read.Intersect( operand.m_read ); StringExpressionSet intersectWrite = this.m_write == null ? null : this.m_write.Intersect( operand.m_write ); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty())) { return null; } EnvironmentPermission intersectPermission = new EnvironmentPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; return intersectPermission; }
public override IPermission Union(IPermission target) { if(target == null) { return Copy(); } else if(!(target is StrongNameIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(IsSubsetOf(target)) { return target.Copy(); } else if(target.IsSubsetOf(this)) { return Copy(); } else { return null; } }
override public IPermission Union(IPermission target) { if (null == target) { return this.Copy(); } if (target.GetType() != this.GetType()) { throw ADP.PermissionTypeMismatch(); } if (IsUnrestricted()) { // MDAC 84803 return this.Copy(); } DBDataPermission newPermission = (DBDataPermission) target.Copy(); if (!newPermission.IsUnrestricted()) { newPermission._allowBlankPassword |= AllowBlankPassword; if (null != _keyvalues) { foreach(DBConnectionString entry in _keyvalues) { newPermission.AddPermissionEntry(entry); } } } return (newPermission.IsEmpty() ? null : newPermission); }
// Form the intersection of two permission objects. public override IPermission Intersect(IPermission target) { if(target == null) { return target; } else if(target.GetType() != GetType()) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if(((ResourcePermissionBase)target).IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } ResourcePermissionBase perm; perm = (ResourcePermissionBase)(target.Copy()); perm.Clear(); foreach(ResourcePermissionBaseEntry entry in permissions) { if(((ResourcePermissionBase)target).Contains(entry)) { perm.AddPermissionAccess(entry); } } return perm; }
[System.Security.SecuritySafeCritical] // auto-generated public override 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(); } RegistryPermission operand = (RegistryPermission)target; if (operand.IsUnrestricted()) { return this.Copy(); } StringExpressionSet intersectRead = this.m_read == null ? null : this.m_read.Intersect( operand.m_read ); StringExpressionSet intersectWrite = this.m_write == null ? null : this.m_write.Intersect( operand.m_write ); StringExpressionSet intersectCreate = this.m_create == null ? null : this.m_create.Intersect( operand.m_create ); StringExpressionSet intersectViewAcl = this.m_viewAcl == null ? null : this.m_viewAcl.Intersect( operand.m_viewAcl ); StringExpressionSet intersectChangeAcl = this.m_changeAcl == null ? null : this.m_changeAcl.Intersect( operand.m_changeAcl ); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty()) && (intersectCreate == null || intersectCreate.IsEmpty()) && (intersectViewAcl == null || intersectViewAcl.IsEmpty()) && (intersectChangeAcl == null || intersectChangeAcl.IsEmpty())) { return null; } RegistryPermission intersectPermission = new RegistryPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; intersectPermission.m_create = intersectCreate; intersectPermission.m_viewAcl = intersectViewAcl; intersectPermission.m_changeAcl = intersectChangeAcl; return intersectPermission; }
// Form the union of two permission objects. public override IPermission Union(IPermission target) { if(target == null) { return Copy(); } else if(target.GetType() != GetType()) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if(IsUnrestricted() || ((ResourcePermissionBase)target).IsUnrestricted()) { return (ResourcePermissionBase)Activator.CreateInstance (GetType(), new Object [] {PermissionState.Unrestricted}); } else { ResourcePermissionBase perm; perm = (ResourcePermissionBase)(target.Copy()); foreach(ResourcePermissionBaseEntry entry in permissions) { if(!perm.Contains(entry)) { perm.AddPermissionAccess(entry); } } return perm; } }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } FileIOPermission permission = target as FileIOPermission; if (permission == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.IsUnrestricted()) { return target.Copy(); } if (permission.IsUnrestricted()) { return this.Copy(); } FileIOAccess access = (this.m_read == null) ? null : this.m_read.Intersect(permission.m_read); FileIOAccess access2 = (this.m_write == null) ? null : this.m_write.Intersect(permission.m_write); FileIOAccess access3 = (this.m_append == null) ? null : this.m_append.Intersect(permission.m_append); FileIOAccess access4 = (this.m_pathDiscovery == null) ? null : this.m_pathDiscovery.Intersect(permission.m_pathDiscovery); FileIOAccess access5 = (this.m_viewAcl == null) ? null : this.m_viewAcl.Intersect(permission.m_viewAcl); FileIOAccess access6 = (this.m_changeAcl == null) ? null : this.m_changeAcl.Intersect(permission.m_changeAcl); if (((((access == null) || access.IsEmpty()) && ((access2 == null) || access2.IsEmpty())) && (((access3 == null) || access3.IsEmpty()) && ((access4 == null) || access4.IsEmpty()))) && (((access5 == null) || access5.IsEmpty()) && ((access6 == null) || access6.IsEmpty()))) { return null; } return new FileIOPermission(PermissionState.None) { m_unrestricted = false, m_read = access, m_write = access2, m_append = access3, m_pathDiscovery = access4, m_viewAcl = access5, m_changeAcl = access6 }; }
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 ); } }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } if (this.IsUnrestricted()) { return target.Copy(); } EnvironmentPermission permission = (EnvironmentPermission) target; if (permission.IsUnrestricted()) { return this.Copy(); } StringExpressionSet set = (this.m_read == null) ? null : this.m_read.Intersect(permission.m_read); StringExpressionSet set2 = (this.m_write == null) ? null : this.m_write.Intersect(permission.m_write); if (((set == null) || set.IsEmpty()) && ((set2 == null) || set2.IsEmpty())) { return null; } return new EnvironmentPermission(PermissionState.None) { m_unrestricted = false, m_read = set, m_write = set2 }; }
public override IPermission Intersect(IPermission target) { // Handle the easy cases first. if(target == null) { return target; } else if(!(target is UIPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(((UIPermission)target) .IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } // Get the minimum flag values. UIPermissionWindow w = ((UIPermission)target).window; if(((int)w) > ((int)window)) { w = window; } UIPermissionClipboard c = ((UIPermission)target).clipboard; if(((int)c) > ((int)clipboard)) { c = clipboard; } // Create a new object for the intersection. if(w == UIPermissionWindow.NoWindows && c == UIPermissionClipboard.NoClipboard) { return null; } else { return new UIPermission(w, c); } }
//-----------------------------------------------------------+ // H E L P E R //-----------------------------------------------------------+ private PermissionSet CreateSingletonSet(IPermission perm) { PermissionSet permSet = new PermissionSet(false); permSet.AddPermission(perm.Copy()); return permSet; }
public override IPermission Intersect(IPermission target) { if(target == null) { return target; } else if(!(target is WebPermission)) { throw new ArgumentException(S._("Arg_PermissionMismatch")); } else if(((WebPermission)target).IsUnrestricted()) { return Copy(); } else if(IsUnrestricted()) { return target.Copy(); } else { WebPermission perm = new WebPermission(); WebPermission other = (WebPermission)target; foreach(Object p1 in acceptList) { if(!other.acceptList.Contains(p1)) { perm.acceptList.Add(p1); } } foreach(Object p2 in connectList) { if(!other.connectList.Contains(p2)) { perm.connectList.Add(p2); } } return perm; } }
public override IPermission Intersect(IPermission target) { if (target == null) { return null; } FileIOPermission operand = target as FileIOPermission; if (operand == null) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); } else if (this.IsUnrestricted()) { return target.Copy(); } if (operand.IsUnrestricted()) { return this.Copy(); } FileIOAccess intersectRead = this.m_read == null ? null : this.m_read.Intersect(operand.m_read); FileIOAccess intersectWrite = this.m_write == null ? null : this.m_write.Intersect(operand.m_write); FileIOAccess intersectAppend = this.m_append == null ? null : this.m_append.Intersect(operand.m_append); FileIOAccess intersectPathDiscovery = this.m_pathDiscovery == null ? null : this.m_pathDiscovery.Intersect(operand.m_pathDiscovery); FileIOAccess intersectViewAcl = this.m_viewAcl == null ? null : this.m_viewAcl.Intersect(operand.m_viewAcl); FileIOAccess intersectChangeAcl = this.m_changeAcl == null ? null : this.m_changeAcl.Intersect(operand.m_changeAcl); if ((intersectRead == null || intersectRead.IsEmpty()) && (intersectWrite == null || intersectWrite.IsEmpty()) && (intersectAppend == null || intersectAppend.IsEmpty()) && (intersectPathDiscovery == null || intersectPathDiscovery.IsEmpty()) && (intersectViewAcl == null || intersectViewAcl.IsEmpty()) && (intersectChangeAcl == null || intersectChangeAcl.IsEmpty())) { return null; } FileIOPermission intersectPermission = new FileIOPermission(PermissionState.None); intersectPermission.m_unrestricted = false; intersectPermission.m_read = intersectRead; intersectPermission.m_write = intersectWrite; intersectPermission.m_append = intersectAppend; intersectPermission.m_pathDiscovery = intersectPathDiscovery; intersectPermission.m_viewAcl = intersectViewAcl; intersectPermission.m_changeAcl = intersectChangeAcl; return intersectPermission; }
/// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.Union"]/*' /> public override IPermission Union(IPermission target) { if (target == null) { return this.m_url != null ? this.Copy() : null; } else if (!VerifyType(target)) { throw new ArgumentException( String.Format(Environment.GetResourceString("Argument_WrongType"), this.GetType().FullName) ); } UrlIdentityPermission operand = (UrlIdentityPermission)target; if (this.m_url == null) { return operand.m_url != null ? target.Copy() : null; } else if (operand.m_url == null) { return this.Copy(); } URLString url = (URLString)operand.m_url.Union( this.m_url ); if (url == null) { return null; } else { return new UrlIdentityPermission( url ); } }
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 override IPermission Union(IPermission target) { if(target == null) { return Copy(); } else if(!(target is ZoneIdentityPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } SecurityZone otherZone = ((ZoneIdentityPermission)target).zone; if(zone == otherZone || otherZone == SecurityZone.NoZone) { return Copy(); } else if(zone == SecurityZone.NoZone) { return target.Copy(); } else { return null; } }