Exemplo n.º 1
0
        public override SecurityElement ToXml()
        {
            SecurityElement se = PermissionHelper.Element(this.GetType(), version);

            if (IsUnrestricted())
            {
                se.AddAttribute("Unrestricted", "true");
            }
            else
            {
                // attribute is present for both True and False
                se.AddAttribute("AllowBlankPassword", allowBlankPassword.ToString());
                foreach (DictionaryEntry de in _connections)
                {
                    SecurityElement child = new SecurityElement("add");
                    child.AddAttribute("ConnectionString", (string)de.Key);
                    object[] restrictionsInfo = (object[])de.Value;
                    child.AddAttribute("KeyRestrictions", (string)restrictionsInfo [0]);
                    KeyRestrictionBehavior krb = (KeyRestrictionBehavior)restrictionsInfo [1];
                    child.AddAttribute("KeyRestrictionBehavior", krb.ToString());
                    se.AddChild(child);
                }
            }
            return(se);
        }
Exemplo n.º 2
0
 public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
 {
     state = PermissionState.None;
     _connections [connectionString] = new object [2] {
         restrictions, behavior
     };
 }
        // <IPermission class="...Permission" version="1" AllowBlankPassword=false>
        //     <add ConnectionString="provider=x;data source=y;" KeyRestrictions="address=;server=" KeyRestrictionBehavior=PreventUsage/>
        // </IPermission>
        /// <include file='doc\OraclePermission.uex' path='docs/doc[@for="OraclePermission.FromXml"]/*' />
        override public void FromXml(SecurityElement securityElement)
        {
            // code derived from CodeAccessPermission.ValidateElement
            if (null == securityElement)
            {
                throw ADP.ArgumentNull("securityElement");
            }
            string tag = securityElement.Tag;

            if (!tag.Equals(XmlStr._Permission) && !tag.Equals(XmlStr._IPermission))
            {
                // TODO: do we need to check this?
                //String className = el.Attribute( XmlStr._class );
                //return className == null || !className.Equals( ip.GetType().AssemblyQualifiedName );
                throw ADP.NotAPermissionElement();
            }
            String version = securityElement.Attribute(XmlStr._Version);

            if ((null != version) && !version.Equals(XmlStr._VersionNumber))
            {
                throw ADP.InvalidXMLBadVersion();
            }

            string unrestrictedValue = securityElement.Attribute(XmlStr._Unrestricted);

            _isUnrestricted = (null != unrestrictedValue) && Boolean.Parse(unrestrictedValue);

            Clear(); // MDAC 83105
            if (!_isUnrestricted)
            {
                string allowNull = securityElement.Attribute(XmlStr._AllowBlankPassword);
                _allowBlankPassword = (null != allowNull) && Boolean.Parse(allowNull);

                ArrayList children = securityElement.Children;
                if (null != children)
                {
                    foreach (SecurityElement keyElement in children)
                    {
                        if (keyElement.Tag.Equals(XmlStr._add))
                        {
                            string constr = keyElement.Attribute(XmlStr._ConnectionString);
                            string restrt = keyElement.Attribute(XmlStr._KeyRestrictions);
                            string behavr = keyElement.Attribute(XmlStr._KeyRestrictionBehavior);

                            KeyRestrictionBehavior behavior = KeyRestrictionBehavior.AllowOnly;
                            if (null != behavr)
                            {
                                behavior = (KeyRestrictionBehavior)Enum.Parse(typeof(KeyRestrictionBehavior), behavr, true);
                            }
                            Add(constr, restrt, behavior);
                        }
                    }
                }
            }
            else
            {
                _allowBlankPassword = false;
            }
        }
Exemplo n.º 4
0
        // <IPermission class="...Permission" version="1" AllowBlankPassword=false>
        //     <add ConnectionString="provider=x;data source=y;" KeyRestrictions="address=;server=" KeyRestrictionBehavior=PreventUsage/>
        // </IPermission>
        override public void FromXml(SecurityElement securityElement)
        {
            // code derived from CodeAccessPermission.ValidateElement
            if (null == securityElement)
            {
                throw ADP.ArgumentNull("securityElement");
            }
            string tag = securityElement.Tag;

            if (!tag.Equals(XmlStr._Permission) && !tag.Equals(XmlStr._IPermission))
            {
                throw ADP.NotAPermissionElement();
            }
            String version = securityElement.Attribute(XmlStr._Version);

            if ((null != version) && !version.Equals(XmlStr._VersionNumber))
            {
                throw ADP.InvalidXMLBadVersion();
            }

            string unrestrictedValue = securityElement.Attribute(XmlStr._Unrestricted);

            _IsUnrestricted = (null != unrestrictedValue) && Boolean.Parse(unrestrictedValue);

            Clear(); // MDAC 83105
            if (!_IsUnrestricted)
            {
                string allowNull = securityElement.Attribute(XmlStr._AllowBlankPassword);
                AllowBlankPassword = (null != allowNull) && Boolean.Parse(allowNull);

                ArrayList children = securityElement.Children;
                if (null != children)
                {
                    foreach (SecurityElement keyElement in children)
                    {
                        tag = keyElement.Tag;
                        if ((XmlStr._add == tag) || ((null != tag) && (XmlStr._add == tag.ToLower(CultureInfo.InvariantCulture))))
                        {
                            string constr = keyElement.Attribute(XmlStr._ConnectionString);
                            string restrt = keyElement.Attribute(XmlStr._KeyRestrictions);
                            string behavr = keyElement.Attribute(XmlStr._KeyRestrictionBehavior);

                            KeyRestrictionBehavior behavior = KeyRestrictionBehavior.AllowOnly;
                            if (null != behavr)
                            {
                                behavior = (KeyRestrictionBehavior)Enum.Parse(typeof(KeyRestrictionBehavior), behavr, true);
                            }
                            constr = DecodeXmlValue(constr);
                            restrt = DecodeXmlValue(restrt);
                            Add(constr, restrt, behavior);
                        }
                    }
                }
            }
            else
            {
                AllowBlankPassword = false;
            }
        }
Exemplo n.º 5
0
 private DBConnectionString(DBConnectionString connectionString, string[] restrictionValues, KeyRestrictionBehavior behavior)
 {
     this._encryptedUsersConnectionString = connectionString._encryptedUsersConnectionString;
     this._parsetable        = connectionString._parsetable;
     this._keychain          = connectionString._keychain;
     this._hasPassword       = connectionString._hasPassword;
     this._restrictionValues = restrictionValues;
     this._restrictions      = null;
     this._behavior          = behavior;
 }
Exemplo n.º 6
0
        private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)   // used by DBDataPermission
        {
            Debug.Assert(null != connectionOptions, "null connectionOptions");
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                _behavior = behavior;
                break;

            default:
                throw ADP.InvalidKeyRestrictionBehavior(behavior);
            }

            // grab all the parsed details from DbConnectionOptions
            _encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
            _hasPassword = connectionOptions.HasPasswordKeyword;
            _parsetable  = connectionOptions.Parsetable;
            _keychain    = connectionOptions.KeyChain;

            // we do not want to serialize out user password unless directed so by "persist security info=true"
            // otherwise all instances of user's password will be replaced with "*"
            if (_hasPassword && !connectionOptions.HasPersistablePassword)
            {
                if (mustCloneDictionary)
                {
                    // clone the hashtable to replace user's password/pwd value with "*"
                    // we only need to clone if coming from DbConnectionOptions and password exists
                    _parsetable = (Hashtable)_parsetable.Clone();
                }

                // different than Everett in that instead of removing password/pwd from
                // the hashtable, we replace the value with '*'.  This is okay since we
                // serialize out with '*' so already knows what we do.  Better this way
                // than to treat password specially later on which causes problems.
                const string star = "*";
                if (_parsetable.ContainsKey(KEY.Password))
                {
                    _parsetable[KEY.Password] = star;
                }
                if (_parsetable.ContainsKey(KEY.Pwd))
                {
                    _parsetable[KEY.Pwd] = star;
                }

                // replace user's password/pwd value with "*" in the linked list and build a new string
                _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
            }

            if (!ADP.IsEmpty(restrictions))
            {
                _restrictionValues = ParseRestrictions(restrictions, synonyms);
                _restrictions      = restrictions;
            }
        }
        public override void FromXml(SecurityElement securityElement)
        {
            if (securityElement == null)
            {
                throw ADP.ArgumentNull("securityElement");
            }
            string tag = securityElement.Tag;

            if (!tag.Equals("Permission") && !tag.Equals("IPermission"))
            {
                throw ADP.NotAPermissionElement();
            }
            string str7 = securityElement.Attribute("version");

            if ((str7 != null) && !str7.Equals("1"))
            {
                throw ADP.InvalidXMLBadVersion();
            }
            string str6 = securityElement.Attribute("Unrestricted");

            this._isUnrestricted = (str6 != null) && bool.Parse(str6);
            this.Clear();
            if (!this._isUnrestricted)
            {
                string str5 = securityElement.Attribute("AllowBlankPassword");
                this._allowBlankPassword = (str5 != null) && bool.Parse(str5);
                ArrayList children = securityElement.Children;
                if (children != null)
                {
                    foreach (SecurityElement element in children)
                    {
                        tag = element.Tag;
                        if (("add" == tag) || ((tag != null) && ("add" == tag.ToLower(CultureInfo.InvariantCulture))))
                        {
                            string str3 = element.Attribute("ConnectionString");
                            string str2 = element.Attribute("KeyRestrictions");
                            string str4 = element.Attribute("KeyRestrictionBehavior");
                            KeyRestrictionBehavior allowOnly = KeyRestrictionBehavior.AllowOnly;
                            if (str4 != null)
                            {
                                allowOnly = (KeyRestrictionBehavior)Enum.Parse(typeof(KeyRestrictionBehavior), str4, true);
                            }
                            str3 = this.DecodeXmlValue(str3);
                            str2 = this.DecodeXmlValue(str2);
                            this.Add(str3, str2, allowOnly);
                        }
                    }
                }
            }
            else
            {
                this._allowBlankPassword = false;
            }
        }
Exemplo n.º 8
0
        private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
        {
            Debug.Assert(null != connectionOptions, "null connectionOptions");
            switch (behavior)
            {
                case KeyRestrictionBehavior.PreventUsage:
                case KeyRestrictionBehavior.AllowOnly:
                    _behavior = behavior;
                    break;
                default:
                    throw ADP.InvalidKeyRestrictionBehavior(behavior);
            }

            // grab all the parsed details from DbConnectionOptions
            _encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
            _hasPassword = connectionOptions._hasPasswordKeyword;
            _parsetable = connectionOptions.Parsetable;
            _keychain = connectionOptions._keyChain;

            // we do not want to serialize out user password unless directed so by "persist security info=true"
            // otherwise all instances of user's password will be replaced with "*"
            if (_hasPassword && !connectionOptions.HasPersistablePassword)
            {
                if (mustCloneDictionary)
                {
                    // clone the hashtable to replace user's password/pwd value with "*"
                    // we only need to clone if coming from DbConnectionOptions and password exists
                    _parsetable = (Hashtable)_parsetable.Clone();
                }

                // different than Everett in that instead of removing password/pwd from
                // the hashtable, we replace the value with '*'.  This is okay since we
                // serialize out with '*' so already knows what we do.  Better this way
                // than to treat password specially later on which causes problems.
                const string star = "*";
                if (_parsetable.ContainsKey(KEY.Password))
                {
                    _parsetable[KEY.Password] = star;
                }
                if (_parsetable.ContainsKey(KEY.Pwd))
                {
                    _parsetable[KEY.Pwd] = star;
                }

                // replace user's password/pwd value with "*" in the linked list and build a new string
                _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
            }

            if (!string.IsNullOrEmpty(restrictions))
            {
                _restrictionValues = ParseRestrictions(restrictions, synonyms);
                _restrictions = restrictions;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Adds a new connection string and a set of restricted keywords
        /// to this <see cref="HsqlDataPermission"/> object.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="restrictions">The key restrictions.</param>
        /// <param name="behavior">
        /// One of the <see cref="KeyRestrictionBehavior"/> enumeration
        /// values.
        /// </param>
        public override void Add(string connectionString,
                                 string restrictions,
                                 KeyRestrictionBehavior behavior)
        {
            base.Add(connectionString, restrictions, behavior);

            if (behavior == KeyRestrictionBehavior.AllowOnly)
            {
                //
            }
        }
        // DBDataPermissionAttribute.KeyRestrictionBehavior
        internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
        {
#if DEBUG
            switch (value)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
                break;
            }
#endif
            return(InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value));
        }
Exemplo n.º 11
0
        private DBConnectionString(DBConnectionString connectionString, string[] restrictionValues, KeyRestrictionBehavior behavior)
        {
            // used by intersect for two equal connection strings with different restrictions
            _encryptedUsersConnectionString = connectionString._encryptedUsersConnectionString;
            _parsetable  = connectionString._parsetable;
            _keychain    = connectionString._keychain;
            _hasPassword = connectionString._hasPassword;

            _restrictionValues = restrictionValues;
            _restrictions      = null;
            _behavior          = behavior;

            Verify(restrictionValues);
        }
Exemplo n.º 12
0
        /// <include file='doc\OdbcPermission.uex' path='docs/doc[@for="OdbcPermission.Add"]/*' />
        override public void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                break;

            default:
                throw ADP.Argument("value");
            }
            DBConnectionString entry = new OdbcConnectionString(connectionString, restrictions, behavior); // MDAC 85142

            base.AddPermissionEntry(entry);
        }
Exemplo n.º 13
0
        /// <include file='doc\DBDataPermission.uex' path='docs/doc[@for="DBDataPermission.AddWithAllow"]/*' />
        virtual public void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                break;

            default:
                throw ADP.Argument("value");
            }
            DBConnectionString entry = new DBConnectionString(connectionString, restrictions, behavior, UdlSupport.UdlAsKeyword);

            AddPermissionEntry(entry);
        }
Exemplo n.º 14
0
        public override void FromXml(SecurityElement securityElement)
        {
            PermissionHelper.CheckSecurityElement(securityElement, "securityElement", version, version);
            // Note: we do not (yet) care about the return value
            // as we only accept version 1 (min/max values)

            state = (PermissionHelper.IsUnrestricted(securityElement) ?
                     PermissionState.Unrestricted : PermissionState.None);

            allowBlankPassword = false;
            string blank = securityElement.Attribute("AllowBlankPassword");

            if (blank != null)
            {
#if NET_2_0
                // avoid possible exceptions with Fx 2.0
                if (!Boolean.TryParse(blank, out allowBlankPassword))
                {
                    allowBlankPassword = false;
                }
#else
                try
                {
                    allowBlankPassword = Boolean.Parse(blank);
                }
                catch
                {
                    allowBlankPassword = false;
                }
#endif
            }

            if (securityElement.Children != null)
            {
                foreach (SecurityElement child in securityElement.Children)
                {
                    string connect   = child.Attribute("ConnectionString");
                    string restricts = child.Attribute("KeyRestrictions");
                    KeyRestrictionBehavior behavior = (KeyRestrictionBehavior)Enum.Parse(
                        typeof(KeyRestrictionBehavior), child.Attribute("KeyRestrictionBehavior"));

                    if ((connect != null) && (connect.Length > 0))
                    {
                        Add(connect, restricts, behavior);
                    }
                }
            }
        }
Exemplo n.º 15
0
        /// <include file='doc\OraclePermission.uex' path='docs/doc[@for="OraclePermission.AddWithAllow"]/*' />
        /// <internalonly />
        internal void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                break;

            default:
                throw ADP.Argument("value");
            }
            if (null == restrictions)
            {
                restrictions = ADP.StrEmpty;
            }
            DBConnectionString entry = new OracleConnectionString(connectionString, restrictions, behavior);

            if (!entry.ContainsPersistablePassword())
            {
                entry = new DBConnectionString(entry, true);
            }
            AddEntry(entry);
            _isUnrestricted = false; // MDAC 84639
        }
Exemplo n.º 16
0
 private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
 {
     switch (behavior)
     {
     case KeyRestrictionBehavior.AllowOnly:
     case KeyRestrictionBehavior.PreventUsage:
         this._behavior = behavior;
         this._encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
         this._hasPassword = connectionOptions.HasPasswordKeyword;
         this._parsetable  = connectionOptions.Parsetable;
         this._keychain    = connectionOptions.KeyChain;
         if (this._hasPassword && !connectionOptions.HasPersistablePassword)
         {
             if (mustCloneDictionary)
             {
                 this._parsetable = (Hashtable)this._parsetable.Clone();
             }
             if (this._parsetable.ContainsKey("password"))
             {
                 this._parsetable["password"] = "******";
             }
             if (this._parsetable.ContainsKey("pwd"))
             {
                 this._parsetable["pwd"] = "*";
             }
             this._keychain = connectionOptions.ReplacePasswordPwd(out this._encryptedUsersConnectionString, true);
         }
         if (!ADP.IsEmpty(restrictions))
         {
             this._restrictionValues = ParseRestrictions(restrictions, synonyms);
             this._restrictions      = restrictions;
         }
         return;
     }
     throw ADP.InvalidKeyRestrictionBehavior(behavior);
 }
Exemplo n.º 17
0
 public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
 {
 }
 public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
 {
     DBConnectionString entry = new DBConnectionString(connectionString, restrictions, behavior, null, false);
     this.AddPermissionEntry(entry);
 }
Exemplo n.º 19
0
 internal DBConnectionString(string value, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool useOdbcRules) : this(new DbConnectionOptions(value, synonyms, useOdbcRules), restrictions, behavior, synonyms, false)
 {
 }
Exemplo n.º 20
0
#pragma warning restore 169

        internal DBConnectionString(string value, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool useOdbcRules)
            : this(new DbConnectionOptions(value, synonyms, useOdbcRules), restrictions, behavior, synonyms, false)
        {
            // useOdbcRules is only used to parse the connection string, not to parse restrictions because values don't apply there
            // the hashtable doesn't need clone since it isn't shared with anything else
        }
 internal SqlConnectionString(string connectionString, string restrictions, KeyRestrictionBehavior behavior) : base(connectionString, restrictions, behavior, UdlSupport.ThrowIfFound) {
 }
Exemplo n.º 22
0
#pragma warning restore 169

        internal DBConnectionString(string value, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool useOdbcRules)
            : this(new DbConnectionOptions(value, synonyms, useOdbcRules), restrictions, behavior, synonyms, false)
        {
            // useOdbcRules is only used to parse the connection string, not to parse restrictions because values don't apply there
            // the hashtable doesn't need clone since it isn't shared with anything else
        }
		protected override void AddConnectionString (string connectionString, string restrictions, 
			KeyRestrictionBehavior behavior, Hashtable synonyms, bool useFirstKeyValue)
		{
			base.AddConnectionString (connectionString, restrictions, behavior, synonyms, useFirstKeyValue);
		}
Exemplo n.º 24
0
 public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior) {
     DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, SqlConnectionString.GetParseSynonyms(), false);
     AddPermissionEntry(constr);
 }
Exemplo n.º 25
0
 public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior) {
     DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, null, true);
     AddPermissionEntry(constr);
 }
        public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            DBConnectionString entry = new DBConnectionString(connectionString, restrictions, behavior, null, false);

            this.AddPermissionEntry(entry);
        }
Exemplo n.º 27
0
		protected override void AddConnectionString (string connectionString, string restrictions, 
			KeyRestrictionBehavior behavior, Hashtable synonyms, bool useFirstKeyValue)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 28
0
        internal DBConnectionString Intersect(DBConnectionString entry)
        {
            KeyRestrictionBehavior behavior = _behavior;

            string[] restrictionValues = null;

            if (null == entry)
            {
                behavior = KeyRestrictionBehavior.AllowOnly;
            }
            else if (_behavior != entry._behavior)
            {
                // subset of the AllowOnly array
                behavior = KeyRestrictionBehavior.AllowOnly;

                if (KeyRestrictionBehavior.AllowOnly == entry._behavior)
                {
                    // this PreventUsage and entry AllowOnly
                    if (!ADP.IsEmptyArray(_restrictionValues))
                    {
                        if (!ADP.IsEmptyArray(entry._restrictionValues))
                        {
                            restrictionValues = NewRestrictionAllowOnly(entry._restrictionValues, _restrictionValues);
                        }
                    }
                    else
                    {
                        restrictionValues = entry._restrictionValues;
                    }
                }
                else if (!ADP.IsEmptyArray(_restrictionValues))
                {
                    // this AllowOnly and entry PreventUsage
                    if (!ADP.IsEmptyArray(entry._restrictionValues))
                    {
                        restrictionValues = NewRestrictionAllowOnly(_restrictionValues, entry._restrictionValues);
                    }
                    else
                    {
                        restrictionValues = _restrictionValues;
                    }
                }
            }
            else if (KeyRestrictionBehavior.PreventUsage == _behavior)
            {
                // both PreventUsage
                if (ADP.IsEmptyArray(_restrictionValues))
                {
                    restrictionValues = entry._restrictionValues;
                }
                else if (ADP.IsEmptyArray(entry._restrictionValues))
                {
                    restrictionValues = _restrictionValues;
                }
                else
                {
                    restrictionValues = NoDuplicateUnion(_restrictionValues, entry._restrictionValues);
                }
            }
            else if (!ADP.IsEmptyArray(_restrictionValues) && !ADP.IsEmptyArray(entry._restrictionValues))
            {
                // both AllowOnly with restrictions
                if (_restrictionValues.Length <= entry._restrictionValues.Length)
                {
                    restrictionValues = NewRestrictionIntersect(_restrictionValues, entry._restrictionValues);
                }
                else
                {
                    restrictionValues = NewRestrictionIntersect(entry._restrictionValues, _restrictionValues);
                }
            }

            // verify _hasPassword & _parsetable are in sync between Everett/Whidbey
            Debug.Assert(!_hasPassword || ContainsKey(KEY.Password) || ContainsKey(KEY.Pwd), "OnDeserialized password mismatch this");
            Debug.Assert(null == entry || !entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry");

            DBConnectionString value = new DBConnectionString(this, restrictionValues, behavior);

            ValidateCombinedSet(this, value);
            ValidateCombinedSet(entry, value);

            return(value);
        }
 internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
 {
     return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int) value);
 }
 public void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
 {
     System.Data.OracleClient.DBConnectionString entry = new System.Data.OracleClient.DBConnectionString(connectionString, restrictions, behavior, OracleConnectionString.GetParseSynonyms(), false);
     this.AddPermissionEntry(entry);
 }
Exemplo n.º 31
0
        private DBConnectionString(DBConnectionString connectionString, string[] restrictionValues, KeyRestrictionBehavior behavior) {
            // used by intersect for two equal connection strings with different restrictions
            _encryptedUsersConnectionString = connectionString._encryptedUsersConnectionString;
            _parsetable = connectionString._parsetable;
            _keychain = connectionString._keychain;
            _hasPassword = connectionString._hasPassword;

            _restrictionValues = restrictionValues;
            _restrictions = null;
            _behavior = behavior;

            Verify(restrictionValues);
        }
		protected virtual void AddConnectionString (string connectionString, string restrictions, 
			KeyRestrictionBehavior behavior, Hashtable synonyms, bool useFirstKeyValue)
		{
			_connections [connectionString] = new object [2] { restrictions, behavior };
		}
Exemplo n.º 33
0
 public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior) { // V1.0.5000
     DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, null, false);
     AddPermissionEntry(constr);
 }
		public virtual void SetRestriction (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
		{
			throw new NotImplementedException ();
		}
 public DbConnectionString(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
     : this(connectionString)
 {
     this.behavior = behavior;
 }
Exemplo n.º 36
0
		public DbConnectionString (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
			: this (connectionString)
		{
			this.behavior = behavior;
		}
Exemplo n.º 37
0
		public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
		{
			base.Add(connectionString, restrictions, behavior);
		}
Exemplo n.º 38
0
        public virtual void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)   // V1.0.5000
        {
            DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, null, false);

            AddPermissionEntry(constr);
        }
		public virtual void Add (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
		{
			state = PermissionState.None;
			AddConnectionString (connectionString, restrictions, behavior, null, false);
		}
Exemplo n.º 40
0
 internal static Exception InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
 {
     return(InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value));
 }
		public virtual void Add (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
		{
			state = PermissionState.None;
			_connections [connectionString] = new object [2] { restrictions, behavior };
		}
        /// <summary>
        /// Adds a new connection string and a set of restricted keywords
        /// to this <see cref="HsqlDataPermission"/> object.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="restrictions">The key restrictions.</param>
        /// <param name="behavior">
        /// One of the <see cref="KeyRestrictionBehavior"/> enumeration
        /// values.
        /// </param>
        public override void Add(string connectionString,
            string restrictions,
            KeyRestrictionBehavior behavior)
        {
            base.Add(connectionString, restrictions, behavior);

            if (behavior == KeyRestrictionBehavior.AllowOnly)
            {
                //
            }
        }
Exemplo n.º 43
0
 public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
 {
 }
Exemplo n.º 44
0
        public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, SqlConnectionString.GetParseSynonyms(), false);

            AddPermissionEntry(constr);
        }
Exemplo n.º 45
0
        internal DBConnectionString Intersect(DBConnectionString entry)
        {
            KeyRestrictionBehavior behavior = _behavior;

            string[] restrictionValues = null;

            if (null == entry)
            {
                //Debug.WriteLine("0 entry AllowNothing");
                behavior = KeyRestrictionBehavior.AllowOnly;
            }
            else if (this._behavior != entry._behavior)   // subset of the AllowOnly array
            {
                behavior = KeyRestrictionBehavior.AllowOnly;

                if (KeyRestrictionBehavior.AllowOnly == entry._behavior)   // this PreventUsage and entry AllowOnly
                {
                    if (!ADP.IsEmptyArray(_restrictionValues))
                    {
                        if (!ADP.IsEmptyArray(entry._restrictionValues))
                        {
                            //Debug.WriteLine("1 this PreventUsage with restrictions and entry AllowOnly with restrictions");
                            restrictionValues = NewRestrictionAllowOnly(entry._restrictionValues, _restrictionValues);
                        }
                        else
                        {
                            //Debug.WriteLine("2 this PreventUsage with restrictions and entry AllowOnly with no restrictions");
                        }
                    }
                    else
                    {
                        //Debug.WriteLine("3/4 this PreventUsage with no restrictions and entry AllowOnly");
                        restrictionValues = entry._restrictionValues;
                    }
                }
                else if (!ADP.IsEmptyArray(_restrictionValues))   // this AllowOnly and entry PreventUsage
                {
                    if (!ADP.IsEmptyArray(entry._restrictionValues))
                    {
                        //Debug.WriteLine("5 this AllowOnly with restrictions and entry PreventUsage with restrictions");
                        restrictionValues = NewRestrictionAllowOnly(_restrictionValues, entry._restrictionValues);
                    }
                    else
                    {
                        //Debug.WriteLine("6 this AllowOnly and entry PreventUsage with no restrictions");
                        restrictionValues = _restrictionValues;
                    }
                }
                else
                {
                    //Debug.WriteLine("7/8 this AllowOnly with no restrictions and entry PreventUsage");
                }
            }
            else if (KeyRestrictionBehavior.PreventUsage == this._behavior)   // both PreventUsage
            {
                if (ADP.IsEmptyArray(_restrictionValues))
                {
                    //Debug.WriteLine("9/10 both PreventUsage and this with no restrictions");
                    restrictionValues = entry._restrictionValues;
                }
                else if (ADP.IsEmptyArray(entry._restrictionValues))
                {
                    //Debug.WriteLine("11 both PreventUsage and entry with no restrictions");
                    restrictionValues = _restrictionValues;
                }
                else
                {
                    //Debug.WriteLine("12 both PreventUsage with restrictions");
                    restrictionValues = NoDuplicateUnion(_restrictionValues, entry._restrictionValues);
                }
            }
            else if (!ADP.IsEmptyArray(_restrictionValues) && !ADP.IsEmptyArray(entry._restrictionValues))   // both AllowOnly with restrictions
            {
                if (this._restrictionValues.Length <= entry._restrictionValues.Length)
                {
                    //Debug.WriteLine("13a this AllowOnly with restrictions and entry AllowOnly with restrictions");
                    restrictionValues = NewRestrictionIntersect(_restrictionValues, entry._restrictionValues);
                }
                else
                {
                    //Debug.WriteLine("13b this AllowOnly with restrictions and entry AllowOnly with restrictions");
                    restrictionValues = NewRestrictionIntersect(entry._restrictionValues, _restrictionValues);
                }
            }
            else   // both AllowOnly
                   //Debug.WriteLine("14/15/16 this AllowOnly and entry AllowOnly but no restrictions");
            {
            }

            // verify _hasPassword & _parsetable are in sync between Everett/Whidbey
            Debug.Assert(!_hasPassword || ContainsKey(KEY.Password) || ContainsKey(KEY.Pwd), "OnDeserialized password mismatch this");
            Debug.Assert(null == entry || !entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry");

            DBConnectionString value = new DBConnectionString(this, restrictionValues, behavior);

            ValidateCombinedSet(this, value);
            ValidateCombinedSet(entry, value);

            return(value);
        }
Exemplo n.º 46
0
        public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            DBConnectionString constr = new DBConnectionString(connectionString, restrictions, behavior, null, true);

            AddPermissionEntry(constr);
        }
 void \u206E‌‮‪​‪‬‫‎‏‭​‬‍‌‬​​‎‭‍‌‍‍‬‭‫‪‭‬‪‪‮([In] string obj0, [In] string obj1, [In] KeyRestrictionBehavior obj2)
 {
     // ISSUE: unable to decompile the method.
 }
Exemplo n.º 48
0
        internal DBConnectionString Intersect(DBConnectionString entry)
        {
            KeyRestrictionBehavior allowOnly = this._behavior;

            string[] restrictionValues = null;
            if (entry == null)
            {
                allowOnly = KeyRestrictionBehavior.AllowOnly;
            }
            else if (this._behavior != entry._behavior)
            {
                allowOnly = KeyRestrictionBehavior.AllowOnly;
                if (entry._behavior == KeyRestrictionBehavior.AllowOnly)
                {
                    if (!ADP.IsEmptyArray(this._restrictionValues))
                    {
                        if (!ADP.IsEmptyArray(entry._restrictionValues))
                        {
                            restrictionValues = NewRestrictionAllowOnly(entry._restrictionValues, this._restrictionValues);
                        }
                    }
                    else
                    {
                        restrictionValues = entry._restrictionValues;
                    }
                }
                else if (!ADP.IsEmptyArray(this._restrictionValues))
                {
                    if (!ADP.IsEmptyArray(entry._restrictionValues))
                    {
                        restrictionValues = NewRestrictionAllowOnly(this._restrictionValues, entry._restrictionValues);
                    }
                    else
                    {
                        restrictionValues = this._restrictionValues;
                    }
                }
            }
            else if (KeyRestrictionBehavior.PreventUsage == this._behavior)
            {
                if (ADP.IsEmptyArray(this._restrictionValues))
                {
                    restrictionValues = entry._restrictionValues;
                }
                else if (ADP.IsEmptyArray(entry._restrictionValues))
                {
                    restrictionValues = this._restrictionValues;
                }
                else
                {
                    restrictionValues = NoDuplicateUnion(this._restrictionValues, entry._restrictionValues);
                }
            }
            else if (!ADP.IsEmptyArray(this._restrictionValues) && !ADP.IsEmptyArray(entry._restrictionValues))
            {
                if (this._restrictionValues.Length <= entry._restrictionValues.Length)
                {
                    restrictionValues = NewRestrictionIntersect(this._restrictionValues, entry._restrictionValues);
                }
                else
                {
                    restrictionValues = NewRestrictionIntersect(entry._restrictionValues, this._restrictionValues);
                }
            }
            return(new DBConnectionString(this, restrictionValues, allowOnly));
        }