FormsAuthentication.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Namespace: System.Web.Security
  3. * Class: FormsAuthentication
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: ??%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.Web;
  15. using System.Web.Configuration;
  16. namespace System.Web.Security
  17. {
  18. public sealed class FormsAuthentication
  19. {
  20. private static formsCookieName;
  21. private static formsCookiePath;
  22. private static bool isIntialized = false;
  23. public FormsAuthentication()
  24. {
  25. }
  26. public static string FormsCookieName
  27. {
  28. get
  29. {
  30. Initialize();
  31. return formsCookieName;
  32. }
  33. }
  34. public static string FormsCookiePath
  35. {
  36. get
  37. {
  38. Initialize();
  39. return formsCookiePath;
  40. }
  41. }
  42. [MonoTODO]
  43. public static bool Authenticate(string name, string password)
  44. {
  45. if(name != null && password != null)
  46. {
  47. Initialize();
  48. AuthenticationConfig cfg = (AuthenticatonConfig)HttpContext.Current.GetConfig("system.web/authentication");
  49. Hashtable db = cfg.Credentials;
  50. if(db == null)
  51. {
  52. //TraceBack("No_user_database");
  53. return false;
  54. }
  55. string passwd = (String)(db[name.ToLower()]);
  56. if(passwd == null)
  57. {
  58. //Traceback("No_user_in_databse")
  59. return false;
  60. }
  61. throw new NotImplementedException();
  62. /*
  63. switch(cfg.PasswordFormat)
  64. {
  65. }*/
  66. }
  67. return false;
  68. }
  69. [MonoTODO]
  70. public static FormsAuthenticationTicket Decrypt(string encryptedTicket)
  71. {
  72. if(encryptedTicket == null || encryptedTicket.Length == 0)
  73. {
  74. throw new HttpException(HttpRuntime.FormatResourceString("InvalidArgumentValue", "encryptedTicket"));
  75. }
  76. Initialize();
  77. //Traceback("Decrypting cookie:" + encryptedTicket);
  78. byte[] bytes = HexStringToBytesArray(encryptedTicket);
  79. if(bytes == null || bytes.Length == 0)
  80. {
  81. throw new HttpException(HttpRuntime.FormatResourceString("InvalidArgumentValue", "encryptedTicket"));
  82. }
  83. throw new NotImplementedException();
  84. }
  85. private byte[] HexStringToBytesArray(string str)
  86. {
  87. throw new NotImplementedException();
  88. }
  89. private static void Traceback(string str)
  90. {
  91. // throw new NotImplementedException();
  92. }
  93. }
  94. }