2
0

FormsAuthenticationTicket.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // System.Web.Security.FormsAuthenticationTicket
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. namespace System.Web.Security
  11. {
  12. [Serializable]
  13. public sealed class FormsAuthenticationTicket
  14. {
  15. int version;
  16. string name;
  17. DateTime issueDate;
  18. DateTime expiration;
  19. bool isPersistent;
  20. string userData;
  21. string cookiePath;
  22. public FormsAuthenticationTicket (int version,
  23. string name,
  24. DateTime issueDate,
  25. DateTime expiration,
  26. bool isPersistent,
  27. string userData)
  28. {
  29. this.version = version;
  30. this.name = name;
  31. this.issueDate = issueDate;
  32. this.expiration = expiration;
  33. this.isPersistent = isPersistent;
  34. this.userData = userData;
  35. this.cookiePath = "/";
  36. }
  37. public FormsAuthenticationTicket (int version,
  38. string name,
  39. DateTime issueDate,
  40. DateTime expiration,
  41. bool isPersistent,
  42. string userData,
  43. string cookiePath)
  44. {
  45. this.version = version;
  46. this.name = name;
  47. this.issueDate = issueDate;
  48. this.expiration = expiration;
  49. this.isPersistent = isPersistent;
  50. this.userData = userData;
  51. this.cookiePath = cookiePath;
  52. }
  53. public FormsAuthenticationTicket (string name, bool isPersistent, int timeout)
  54. {
  55. this.version = 1;
  56. this.name = name;
  57. this.issueDate = DateTime.Now;
  58. this.isPersistent = isPersistent;
  59. if (isPersistent)
  60. expiration = issueDate.AddYears (50);
  61. else
  62. expiration = issueDate.AddMinutes ((double) timeout);
  63. this.userData = String.Empty;
  64. this.cookiePath = "/";
  65. }
  66. public string CookiePath
  67. {
  68. get {
  69. return cookiePath;
  70. }
  71. }
  72. public DateTime Expiration
  73. {
  74. get {
  75. return expiration;
  76. }
  77. }
  78. public bool Expired
  79. {
  80. get {
  81. return DateTime.Now > expiration;
  82. }
  83. }
  84. public bool IsPersistent
  85. {
  86. get {
  87. return isPersistent;
  88. }
  89. }
  90. public DateTime IssueDate
  91. {
  92. get {
  93. return issueDate;
  94. }
  95. }
  96. public string Name
  97. {
  98. get {
  99. return name;
  100. }
  101. }
  102. public string UserData
  103. {
  104. get {
  105. return userData;
  106. }
  107. }
  108. public int Version
  109. {
  110. get {
  111. return version;
  112. }
  113. }
  114. }
  115. }