NegotiateStream.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. //
  2. // System.Net.Security.NegotiateStream.cs
  3. //
  4. // Authors:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2004
  8. // (c) 2004 Novell, Inc. (http://www.novell.com)
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.IO;
  32. using System.Net;
  33. using System.Security.Principal;
  34. using System.Security.Permissions;
  35. using System.Security.Authentication.ExtendedProtection;
  36. using System.Threading;
  37. using System.Threading.Tasks;
  38. namespace System.Net.Security
  39. {
  40. public class NegotiateStream : AuthenticatedStream
  41. {
  42. #region Fields
  43. int readTimeout;
  44. int writeTimeout;
  45. #endregion // Fields
  46. #region Constructors
  47. [MonoTODO]
  48. public NegotiateStream (Stream innerStream)
  49. : base (innerStream, false)
  50. {
  51. }
  52. [MonoTODO]
  53. public NegotiateStream (Stream innerStream, bool leaveInnerStreamOpen)
  54. : base (innerStream, leaveInnerStreamOpen)
  55. {
  56. }
  57. #endregion // Constructors
  58. #region Properties
  59. public override bool CanRead {
  60. get { return InnerStream.CanRead; }
  61. }
  62. public override bool CanSeek {
  63. get { return InnerStream.CanSeek; }
  64. }
  65. [MonoTODO]
  66. public override bool CanTimeout {
  67. get { throw new NotImplementedException (); }
  68. }
  69. public override bool CanWrite {
  70. get { return InnerStream.CanWrite; }
  71. }
  72. [MonoTODO]
  73. public virtual TokenImpersonationLevel ImpersonationLevel {
  74. get { throw new NotImplementedException (); }
  75. }
  76. [MonoTODO]
  77. public override bool IsAuthenticated {
  78. get { throw new NotImplementedException (); }
  79. }
  80. [MonoTODO]
  81. public override bool IsEncrypted {
  82. get { throw new NotImplementedException (); }
  83. }
  84. [MonoTODO]
  85. public override bool IsMutuallyAuthenticated {
  86. get { throw new NotImplementedException (); }
  87. }
  88. [MonoTODO]
  89. public override bool IsServer {
  90. get { throw new NotImplementedException (); }
  91. }
  92. [MonoTODO]
  93. public override bool IsSigned {
  94. get { throw new NotImplementedException (); }
  95. }
  96. public override long Length {
  97. get { return InnerStream.Length; }
  98. }
  99. public override long Position {
  100. get { return InnerStream.Position; }
  101. set { InnerStream.Position = value; }
  102. }
  103. public override int ReadTimeout {
  104. get { return readTimeout; }
  105. set { readTimeout = value; }
  106. }
  107. [MonoTODO]
  108. public virtual IIdentity RemoteIdentity {
  109. get { throw new NotImplementedException (); }
  110. }
  111. public override int WriteTimeout {
  112. get { return writeTimeout; }
  113. set { writeTimeout = value; }
  114. }
  115. #endregion // Properties
  116. #region Methods
  117. [MonoTODO]
  118. public virtual IAsyncResult BeginAuthenticateAsClient (AsyncCallback asyncCallback, object asyncState)
  119. {
  120. throw new NotImplementedException ();
  121. }
  122. [MonoTODO]
  123. public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, ChannelBinding binding, string targetName, AsyncCallback asyncCallback, object asyncState)
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. [MonoTODO]
  128. public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, string targetName, AsyncCallback asyncCallback, object asyncState)
  129. {
  130. throw new NotImplementedException ();
  131. }
  132. [MonoTODO]
  133. public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
  134. {
  135. throw new NotImplementedException ();
  136. }
  137. [MonoTODO]
  138. public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, ChannelBinding binding, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. [MonoTODO]
  143. public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. [MonoTODO]
  148. public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback asyncCallback, object asyncState)
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO]
  153. public virtual IAsyncResult BeginAuthenticateAsServer (NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. [MonoTODO]
  158. public virtual IAsyncResult BeginAuthenticateAsServer (NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. [MonoTODO]
  163. public virtual IAsyncResult BeginAuthenticateAsServer (ExtendedProtectionPolicy policy, AsyncCallback asyncCallback, object asyncState)
  164. {
  165. throw new NotImplementedException ();
  166. }
  167. [MonoTODO]
  168. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. [MonoTODO]
  173. public virtual void AuthenticateAsClient ()
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. [MonoTODO]
  178. public virtual void AuthenticateAsClient (NetworkCredential credential, string targetName)
  179. {
  180. throw new NotImplementedException ();
  181. }
  182. [MonoTODO]
  183. public virtual void AuthenticateAsClient (NetworkCredential credential, ChannelBinding binding, string targetName)
  184. {
  185. throw new NotImplementedException ();
  186. }
  187. [MonoTODO]
  188. public virtual void AuthenticateAsClient (NetworkCredential credential, ChannelBinding binding, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
  189. {
  190. throw new NotImplementedException ();
  191. }
  192. [MonoTODO]
  193. public virtual void AuthenticateAsClient (NetworkCredential credential, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
  194. {
  195. throw new NotImplementedException ();
  196. }
  197. [MonoTODO]
  198. public virtual void AuthenticateAsServer ()
  199. {
  200. throw new NotImplementedException ();
  201. }
  202. [MonoTODO]
  203. public virtual void AuthenticateAsServer (ExtendedProtectionPolicy policy)
  204. {
  205. throw new NotImplementedException ();
  206. }
  207. [MonoTODO]
  208. public virtual void AuthenticateAsServer (NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
  209. {
  210. throw new NotImplementedException ();
  211. }
  212. [MonoTODO]
  213. public virtual void AuthenticateAsServer (NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
  214. {
  215. throw new NotImplementedException ();
  216. }
  217. [MonoTODO]
  218. protected override void Dispose (bool disposing)
  219. {
  220. if (disposing){
  221. // TODO
  222. }
  223. }
  224. [MonoTODO]
  225. public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
  226. {
  227. throw new NotImplementedException ();
  228. }
  229. [MonoTODO]
  230. public override int EndRead (IAsyncResult asyncResult)
  231. {
  232. throw new NotImplementedException ();
  233. }
  234. [MonoTODO]
  235. public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
  236. {
  237. throw new NotImplementedException ();
  238. }
  239. [MonoTODO]
  240. public override void EndWrite (IAsyncResult asyncResult)
  241. {
  242. throw new NotImplementedException ();
  243. }
  244. [MonoTODO]
  245. public override void Flush ()
  246. {
  247. InnerStream.Flush ();
  248. }
  249. [MonoTODO]
  250. public override int Read (byte[] buffer, int offset, int count)
  251. {
  252. throw new NotImplementedException ();
  253. }
  254. [MonoTODO]
  255. public override long Seek (long offset, SeekOrigin origin)
  256. {
  257. throw new NotImplementedException ();
  258. }
  259. [MonoTODO]
  260. public override void SetLength (long value)
  261. {
  262. throw new NotImplementedException ();
  263. }
  264. [MonoTODO]
  265. public override void Write (byte[] buffer, int offset, int count)
  266. {
  267. throw new NotImplementedException ();
  268. }
  269. public virtual Task AuthenticateAsClientAsync()
  270. {
  271. return Task.Factory.FromAsync(BeginAuthenticateAsClient, EndAuthenticateAsClient, null);
  272. }
  273. public virtual Task AuthenticateAsClientAsync(NetworkCredential credential, string targetName)
  274. {
  275. return Task.Factory.FromAsync(BeginAuthenticateAsClient, EndAuthenticateAsClient, credential, targetName, null);
  276. }
  277. public virtual Task AuthenticateAsClientAsync(
  278. NetworkCredential credential, string targetName,
  279. ProtectionLevel requiredProtectionLevel,
  280. TokenImpersonationLevel allowedImpersonationLevel)
  281. {
  282. return Task.Factory.FromAsync((callback, state) => BeginAuthenticateAsClient(credential, targetName, requiredProtectionLevel, allowedImpersonationLevel, callback, state), EndAuthenticateAsClient, null);
  283. }
  284. public virtual Task AuthenticateAsClientAsync(NetworkCredential credential, ChannelBinding binding, string targetName)
  285. {
  286. throw new NotImplementedException ();
  287. }
  288. public virtual Task AuthenticateAsClientAsync(
  289. NetworkCredential credential, ChannelBinding binding,
  290. string targetName, ProtectionLevel requiredProtectionLevel,
  291. TokenImpersonationLevel allowedImpersonationLevel)
  292. {
  293. throw new NotImplementedException ();
  294. }
  295. public virtual Task AuthenticateAsServerAsync()
  296. {
  297. return Task.Factory.FromAsync(BeginAuthenticateAsServer, EndAuthenticateAsServer, null);
  298. }
  299. public virtual Task AuthenticateAsServerAsync(ExtendedProtectionPolicy policy)
  300. {
  301. throw new NotImplementedException ();
  302. }
  303. public virtual Task AuthenticateAsServerAsync(NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
  304. {
  305. throw new NotImplementedException ();
  306. }
  307. public virtual Task AuthenticateAsServerAsync(
  308. NetworkCredential credential, ExtendedProtectionPolicy policy,
  309. ProtectionLevel requiredProtectionLevel,
  310. TokenImpersonationLevel requiredImpersonationLevel)
  311. {
  312. throw new NotImplementedException ();
  313. }
  314. #endregion // Methods
  315. }
  316. }