OleDbPermission.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. [Serializable]
  38. public sealed class OleDbPermission : DBDataPermission {
  39. #region Fields
  40. private string _provider;
  41. #endregion // Fields
  42. #region Constructors
  43. #if NET_1_1
  44. [Obsolete ("use OleDbPermission(PermissionState.None)", true)]
  45. #endif
  46. public OleDbPermission ()
  47. : base (PermissionState.None)
  48. {
  49. }
  50. public OleDbPermission (PermissionState state)
  51. : base (state)
  52. {
  53. }
  54. #if NET_1_1
  55. [Obsolete ("use OleDbPermission(PermissionState.None)", true)]
  56. #endif
  57. public OleDbPermission (PermissionState state, bool allowBlankPassword)
  58. : base (state)
  59. {
  60. AllowBlankPassword = allowBlankPassword;
  61. }
  62. // required for Copy method
  63. internal OleDbPermission (DBDataPermission permission)
  64. : base (permission)
  65. {
  66. }
  67. // easier (and common) permission creation from attribute class
  68. internal OleDbPermission (DBDataPermissionAttribute attribute)
  69. : base (attribute)
  70. {
  71. }
  72. #endregion
  73. #region Properties
  74. #if NET_2_0
  75. [Obsolete ()]
  76. [EditorBrowsableAttribute (EditorBrowsableState.Never)]
  77. #endif
  78. public string Provider {
  79. get {
  80. if (_provider == null)
  81. return String.Empty;
  82. return _provider;
  83. }
  84. set { _provider = value; }
  85. }
  86. #endregion
  87. #region Methods
  88. public override IPermission Copy ()
  89. {
  90. return new OleDbPermission (this);
  91. }
  92. #if !NET_2_0
  93. // methods required to support Provider were removed in Fx 2.0
  94. // i.e. Provider isn't included in the XML output
  95. public override void FromXml (SecurityElement securityElement)
  96. {
  97. base.FromXml (securityElement);
  98. // Provider
  99. }
  100. [MonoTODO ("is it worth to implement as it is being removed ?")]
  101. public override IPermission Intersect (IPermission target)
  102. {
  103. return base.Intersect (target);
  104. }
  105. public override SecurityElement ToXml ()
  106. {
  107. SecurityElement se = base.ToXml ();
  108. // add Provider
  109. return se;
  110. }
  111. [MonoTODO ("is it worth to implement as it is being removed ?")]
  112. public override IPermission Union (IPermission target)
  113. {
  114. return base.Union (target);
  115. }
  116. #endif
  117. #endregion
  118. }
  119. }