OleDbPermission.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // System.Data.OleDb.OleDbPermission
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. // Sebastien Pouliot <[email protected]>
  8. //
  9. // Copyright (C) Rodrigo Moya, 2002
  10. // Copyright (C) Tim Coleman, 2002
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System.ComponentModel;
  33. using System.Data.Common;
  34. using System.Security;
  35. using System.Security.Permissions;
  36. namespace System.Data.OleDb
  37. {
  38. [Serializable]
  39. public sealed class OleDbPermission : DBDataPermission
  40. {
  41. #region Fields
  42. private string _provider;
  43. #endregion // Fields
  44. #region Constructors
  45. #if NET_1_1
  46. [Obsolete ("use OleDbPermission(PermissionState.None)", true)]
  47. #endif
  48. public OleDbPermission ()
  49. : base (PermissionState.None)
  50. {
  51. }
  52. public OleDbPermission (PermissionState state)
  53. : base (state)
  54. {
  55. }
  56. #if NET_1_1
  57. [Obsolete ("use OleDbPermission(PermissionState.None)", true)]
  58. #endif
  59. public OleDbPermission (PermissionState state, bool allowBlankPassword)
  60. : base (state)
  61. {
  62. AllowBlankPassword = allowBlankPassword;
  63. }
  64. // required for Copy method
  65. internal OleDbPermission (DBDataPermission permission)
  66. : base (permission)
  67. {
  68. }
  69. // easier (and common) permission creation from attribute class
  70. internal OleDbPermission (DBDataPermissionAttribute attribute)
  71. : base (attribute)
  72. {
  73. }
  74. #endregion
  75. #region Properties
  76. #if NET_2_0
  77. [Obsolete ()]
  78. [BrowsableAttribute (false)]
  79. [EditorBrowsableAttribute (EditorBrowsableState.Never)]
  80. #endif
  81. public string Provider {
  82. get {
  83. if (_provider == null)
  84. return String.Empty;
  85. return _provider;
  86. }
  87. set { _provider = value; }
  88. }
  89. #endregion
  90. #region Methods
  91. public override IPermission Copy ()
  92. {
  93. return new OleDbPermission (this);
  94. }
  95. #if !NET_2_0
  96. // methods required to support Provider were removed in Fx 2.0
  97. // i.e. Provider isn't included in the XML output
  98. public override void FromXml (SecurityElement securityElement)
  99. {
  100. base.FromXml (securityElement);
  101. // Provider
  102. }
  103. [MonoTODO ("is it worth to implement as it is being removed ?")]
  104. public override IPermission Intersect (IPermission target)
  105. {
  106. return base.Intersect (target);
  107. }
  108. public override SecurityElement ToXml ()
  109. {
  110. SecurityElement se = base.ToXml ();
  111. // add Provider
  112. return se;
  113. }
  114. [MonoTODO ("is it worth to implement as it is being removed ?")]
  115. public override IPermission Union (IPermission target)
  116. {
  117. return base.Union (target);
  118. }
  119. #endif
  120. #endregion
  121. }
  122. }