private void CopyFrom(DBDataPermission permission) { _isUnrestricted = permission.IsUnrestricted(); if (!_isUnrestricted) { _allowBlankPassword = permission.AllowBlankPassword; try { lock (permission) { // single writer, multiple reader if (null != permission._keyvalues) { _keyvalues = (ArrayList)permission._keyvalues.Clone(); if (null != permission._keyvaluetree) { _keyvaluetree = permission._keyvaluetree.Copy(); } } } } catch { // MDAC 80973 throw; } } }
/// <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 bool IsSubsetOf(IPermission target) { if (target == null) { return(this.IsEmpty()); } if (target.GetType() != base.GetType()) { throw ADP.PermissionTypeMismatch(); } DBDataPermission permission = target as DBDataPermission; bool flag = permission.IsUnrestricted(); if ((!flag && !this.IsUnrestricted()) && (!this.AllowBlankPassword || permission.AllowBlankPassword)) { if ((this._keyvalues != null) && (permission._keyvaluetree == null)) { return(flag); } flag = true; if (this._keyvalues == null) { return(flag); } foreach (DBConnectionString str in this._keyvalues) { if (!permission._keyvaluetree.CheckValueForKeyPermit(str)) { return(false); } } } return(flag); }
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); }
private void Check (string msg, DBDataPermission dbdp, bool blank, bool unrestricted, int count) { Assert.AreEqual (blank, dbdp.AllowBlankPassword, msg + ".AllowBlankPassword"); Assert.AreEqual (unrestricted, dbdp.IsUnrestricted (), msg + ".IsUnrestricted"); if (count == 0) Assert.IsNull (dbdp.ToXml ().Children, msg + ".Count != 0"); else Assert.AreEqual (count, dbdp.ToXml ().Children.Count, msg + ".Count"); }
public override IPermission Intersect(IPermission target) { // FIXME: restrictions not completely implemented - nor documented DBDataPermission dbdp = Cast(target); if (dbdp == null) { return(null); } if (IsUnrestricted()) { if (dbdp.IsUnrestricted()) { DBDataPermission u = CreateInstance(); u.state = PermissionState.Unrestricted; return(u); } return(dbdp.Copy()); } if (dbdp.IsUnrestricted()) { return(Copy()); } if (IsEmpty() || dbdp.IsEmpty()) { return(null); } DBDataPermission p = CreateInstance(); p.allowBlankPassword = (allowBlankPassword && dbdp.allowBlankPassword); foreach (DictionaryEntry de in _connections) { object o = dbdp._connections [de.Key]; if (o != null) { p._connections.Add(de.Key, de.Value); } } return((p._connections.Count > 0) ? p : null); }
public override bool IsSubsetOf(IPermission target) { // FIXME: restrictions not completely implemented - nor documented DBDataPermission dbdp = Cast(target); if (dbdp == null) { return(IsEmpty()); } if (dbdp.IsUnrestricted()) { return(true); } if (IsUnrestricted()) { return(dbdp.IsUnrestricted()); } if (allowBlankPassword && !dbdp.allowBlankPassword) { return(false); } if (_connections.Count > dbdp._connections.Count) { return(false); } foreach (DictionaryEntry de in _connections) { object o = dbdp._connections [de.Key]; if (o == null) { return(false); } // FIXME: this is a subset of what is required // it seems that we must process both the connect string // and the restrictions - but this has other effects :-/ } return(true); }
/// <include file='doc\DBDataPermission.uex' path='docs/doc[@for="DBDataPermission.IsSubsetOf"]/*' /> override public bool IsSubsetOf(IPermission target) { if (null == target) { return(IsEmpty()); } if (target.GetType() != this.GetType()) { throw ADP.WrongType(this.GetType()); } DBDataPermission superset = (target as DBDataPermission); #if DATAPERMIT if (null != superset._keyvalues) { Debug.WriteLine("+ " + (superset._keyvalues[0] as DBConnectionString).ConnectionString); } else { Debug.WriteLine("+ <>"); } if (null != _keyvalues) { Debug.WriteLine("- " + (_keyvalues[0] as DBConnectionString).ConnectionString); } else { Debug.WriteLine("- <>"); } #endif bool subset = superset.IsUnrestricted(); if (!subset) { subset = (!IsUnrestricted() && (!AllowBlankPassword || superset.AllowBlankPassword) && ((null == _keyvalues) || (null != superset._keyvaluetree))); if (subset && (null != _keyvalues)) { foreach (DBConnectionString kventry in _keyvalues) { if (!superset._keyvaluetree.CheckValueForKeyPermit(kventry)) { subset = false; break; } } } } return(subset); }
private void CopyFrom(DBDataPermission permission) { this._isUnrestricted = permission.IsUnrestricted(); if (!this._isUnrestricted) { this._allowBlankPassword = permission.AllowBlankPassword; if (permission._keyvalues != null) { this._keyvalues = (ArrayList)permission._keyvalues.Clone(); if (permission._keyvaluetree != null) { this._keyvaluetree = permission._keyvaluetree.CopyNameValue(); } } } }
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); }
/// <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 Intersect(IPermission target) { if (target == null) { return(null); } if (target.GetType() != base.GetType()) { throw ADP.PermissionTypeMismatch(); } if (this.IsUnrestricted()) { return(target.Copy()); } DBDataPermission permission2 = (DBDataPermission)target; if (permission2.IsUnrestricted()) { return(this.Copy()); } DBDataPermission permission = (DBDataPermission)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); }
override public bool IsSubsetOf(IPermission target) { if (null == target) { return(IsEmpty()); } if (target.GetType() != this.GetType()) { throw ADP.PermissionTypeMismatch(); } DBDataPermission superset = (target as DBDataPermission); bool subset = superset.IsUnrestricted(); if (!subset) { if (!IsUnrestricted() && (!AllowBlankPassword || superset.AllowBlankPassword) && ((null == _keyvalues) || (null != superset._keyvaluetree))) { subset = true; if (null != _keyvalues) { foreach (DBConnectionString kventry in _keyvalues) { if (!superset._keyvaluetree.CheckValueForKeyPermit(kventry)) { subset = false; break; } } } } } return(subset); }
public override IPermission Union(IPermission target) { // FIXME: restrictions not completely implemented - nor documented DBDataPermission dbdp = Cast(target); if (dbdp == null) { return(Copy()); } if (IsEmpty() && dbdp.IsEmpty()) { return(Copy()); } DBDataPermission p = CreateInstance(); if (IsUnrestricted() || dbdp.IsUnrestricted()) { p.state = PermissionState.Unrestricted; } else { p.allowBlankPassword = (allowBlankPassword || dbdp.allowBlankPassword); p._connections = new Hashtable(_connections.Count + dbdp._connections.Count); foreach (DictionaryEntry de in _connections) { p._connections.Add(de.Key, de.Value); } // don't duplicate foreach (DictionaryEntry de in dbdp._connections) { p._connections [de.Key] = de.Value; } } return(p); }
private void CopyFrom(DBDataPermission permission) { _isUnrestricted = permission.IsUnrestricted(); if (!_isUnrestricted) { _allowBlankPassword = permission.AllowBlankPassword; if (null != permission._keyvalues) { _keyvalues = (ArrayList) permission._keyvalues.Clone(); if (null != permission._keyvaluetree) { _keyvaluetree = permission._keyvaluetree.CopyNameValue(); } } } }