The Labs \ Source Viewer \ SSCLI \ System.Net \ Authorization

  1. //------------------------------------------------------------------------------
  2. // <copyright file="Authorization.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net
  16. {
  17.     /// <devdoc>
  18.     /// <para>Used for handling and completing a custom authorization.</para>
  19.     /// </devdoc>
  20.     public class Authorization
  21.     {
  22.        
  23.         private string m_Message;
  24.         private bool m_Complete;
  25.         private string[] m_ProtectionRealm;
  26.         private string m_ConnectionGroupId;
  27.         private bool m_MutualAuth;
  28.        
  29.         /// <devdoc>
  30.         /// <para>
  31.         /// Creates a new instance of the <see cref='System.Net.Authorization'/> class with the specified
  32.         /// authorization token.
  33.         /// </para>
  34.         /// </devdoc>
  35.         public Authorization(string token)
  36.         {
  37.             m_Message = ValidationHelper.MakeStringNull(token);
  38.             m_Complete = true;
  39.         }
  40.        
  41.         /// <devdoc>
  42.         /// <para>
  43.         /// Creates a new instance of the <see cref='System.Net.Authorization'/> class with the specified
  44.         /// authorization token and completion status.
  45.         /// </para>
  46.         /// </devdoc>
  47.         public Authorization(string token, bool finished)
  48.         {
  49.             m_Message = ValidationHelper.MakeStringNull(token);
  50.             m_Complete = finished;
  51.         }
  52.        
  53.         /// <devdoc>
  54.         /// <para>
  55.         /// Creates a new instance of the <see cref='System.Net.Authorization'/> class with the specified
  56.         /// authorization token, completion status, and connection m_ConnectionGroupId identifier.
  57.         /// </para>
  58.         /// </devdoc>
  59.         public Authorization(string token, bool finished, string connectionGroupId) : this(token, finished, connectionGroupId, false)
  60.         {
  61.         }
  62.         //
  63.         internal Authorization(string token, bool finished, string connectionGroupId, bool mutualAuth)
  64.         {
  65.             m_Message = ValidationHelper.MakeStringNull(token);
  66.             m_ConnectionGroupId = ValidationHelper.MakeStringNull(connectionGroupId);
  67.             m_Complete = finished;
  68.             m_MutualAuth = mutualAuth;
  69.         }
  70.        
  71.         /// <devdoc>
  72.         /// <para>Gets
  73.         /// the response returned to the server in response to an authentication
  74.         /// challenge.</para>
  75.         /// </devdoc>
  76.         public string Message {
  77.             get { return m_Message; }
  78.         }
  79.        
  80.         // used to specify if this Authorization needs a special private server connection,
  81.         // identified by this string
  82.         /// <devdoc>
  83.         /// <para>[To be supplied.]</para>
  84.         /// </devdoc>
  85.         public string ConnectionGroupId {
  86.             get { return m_ConnectionGroupId; }
  87.         }
  88.        
  89.         /// <devdoc>
  90.         /// <para>Gets the completion status of the authorization.</para>
  91.         /// </devdoc>
  92.         public bool Complete {
  93.             get { return m_Complete; }
  94.         }
  95.         internal void SetComplete(bool complete)
  96.         {
  97.             m_Complete = complete;
  98.         }
  99.        
  100.         /// <devdoc>
  101.         /// <para>Gets or sets the prefix for Uris that can be authenticated with the <see cref='System.Net.Authorization.Message'/> property.</para>
  102.         /// </devdoc>
  103.         public string[] ProtectionRealm {
  104.             get { return m_ProtectionRealm; }
  105.             set {
  106.                 string[] newValue = ValidationHelper.MakeEmptyArrayNull(value);
  107.                 m_ProtectionRealm = newValue;
  108.             }
  109.         }
  110.        
  111.         //
  112.         //
  113.         public bool MutuallyAuthenticated {
  114.             get { return Complete && m_MutualAuth; }
  115.             set { m_MutualAuth = value; }
  116.         }
  117.        
  118.     }
  119.     // class Authorization
  120.    
  121. }
  122. // namespace System.Net

Developer Fusion