// IPermission interface methods
        /// <include file='doc\DBDataPermission.uex' path='docs/doc[@for="DBDataPermission.Copy"]/*' />
        override public IPermission Copy()
        {
            DBDataPermission copy = CreateInstance();

            copy.CopyFrom(this);
            return(copy);
        }
        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);
        }
        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 Copy()
        {
            DBDataPermission permission = this.CreateInstance();

            permission.CopyFrom(this);
            return(permission);
        }
        /// <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);
        }
        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.DBDataPermission3"]/*' />
 protected DBDataPermission(DBDataPermission permission)   // for Copy
 {
     if (null == permission)
     {
         throw ADP.ArgumentNull("permissionAttribute");
     }
     CopyFrom(permission);
 }
示例#8
0
        public override IPermission Copy()
        {
            DBDataPermission dbdp = CreateInstance();

            dbdp.allowBlankPassword = this.allowBlankPassword;
            dbdp._connections       = (Hashtable)this._connections.Clone();
            return(dbdp);
        }
示例#9
0
		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");
		}
 protected DBDataPermission(DBDataPermission permission)
 {
     this._keyvaluetree = NameValuePermission.Default;
     if (permission == null)
     {
         throw ADP.ArgumentNull("permissionAttribute");
     }
     this.CopyFrom(permission);
 }
 protected DBDataPermission(DBDataPermission permission)
 {
     this._keyvaluetree = NameValuePermission.Default;
     if (permission == null)
     {
         throw ADP.ArgumentNull("permissionAttribute");
     }
     this.CopyFrom(permission);
 }
		protected DBDataPermission (DBDataPermission permission)
		{
			if (permission == null)
				throw new ArgumentNullException ("permission");

			state = permission.state;
			if (state != PermissionState.Unrestricted) {
				allowBlankPassword = permission.allowBlankPassword;
				_connections = (Hashtable) permission._connections.Clone ();
			}
		}
        /// <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);
        }
示例#14
0
        protected DBDataPermission(DBDataPermission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException("permission");
            }

            state = permission.state;
            if (state != PermissionState.Unrestricted)
            {
                allowBlankPassword = permission.allowBlankPassword;
                _connections       = (Hashtable)permission._connections.Clone();
            }
        }
 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();
             }
         }
     }
 }
示例#16
0
        private DBDataPermission Cast(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }

            DBDataPermission dbdp = (target as DBDataPermission);

            if (dbdp == null)
            {
                PermissionHelper.ThrowInvalidPermission(target, this.GetType());
            }

            return(dbdp);
        }
示例#17
0
        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);
        }
示例#18
0
        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);
        }
示例#19
0
        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.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);
        }
示例#22
0
        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);
        }
示例#23
0
        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);
        }
示例#24
0
 protected DBDataPermission(DBDataPermission permission)
 {
 }
		internal FirebirdClientPermission(DBDataPermission permission) : base (permission)
		{
		}
		// required for Copy method
		internal OdbcPermission (DBDataPermission permission)
			: base (permission)
		{
		}
		public NonAbstractDBDataPermission (DBDataPermission permission, bool allowBlankPassword)
			: base (permission)
		{
			AllowBlankPassword = allowBlankPassword;
		}
示例#28
0
 private IngresPermission(DBDataPermission permission)
     : base(permission)
 {
 }
示例#29
0
		public NonAbstractDBDataPermission (DBDataPermission permission)
			: base (permission)
		{
		}
示例#30
0
 protected DBDataPermission(DBDataPermission permission) { // V1.0.5000,  for Copy
     if (null == permission) {
         throw ADP.ArgumentNull("permissionAttribute");
     }
     CopyFrom(permission);
 }
示例#31
0
        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();
                    }
                }
            }
        }
	internal MySqlClientPermission (DBDataPermission permission)
		: base (permission)
	{
	}
示例#33
0
		// required for Copy method
		internal OraclePermission (DBDataPermission permission)
			: base (permission)
		{
		}
		// required for Copy method
		internal OleDbPermission (DBDataPermission permission)
			: base (permission)
		{
		}