SessionSecurityTokenHandler.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // SessionSecurityTokenHandler.cs
  3. //
  4. // Author:
  5. // Noesis Labs ([email protected])
  6. //
  7. // Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. #if NET_4_5
  29. using System;
  30. using System.Collections.Generic;
  31. using System.Collections.ObjectModel;
  32. using System.IdentityModel.Selectors;
  33. using System.Security.Claims;
  34. using System.Xml;
  35. namespace System.IdentityModel.Tokens
  36. {
  37. public class SessionSecurityTokenHandler : SecurityTokenHandler
  38. {
  39. public static readonly ReadOnlyCollection<CookieTransform> DefaultCookieTransforms;
  40. public static readonly TimeSpan DefaultLifetime = TimeSpan.FromHours (10);
  41. private bool canValidateToken;
  42. private bool canWriteToken;
  43. private string cookieElementName;
  44. private string cookieNamespace;
  45. private Type tokenType;
  46. public override bool CanValidateToken { get { return canValidateToken; } }
  47. public override bool CanWriteToken { get { return canWriteToken; } }
  48. public virtual string CookieElementName { get { return cookieElementName; } }
  49. public virtual string CookieNamespace { get { return cookieNamespace; } }
  50. public static TimeSpan DefaultTokenLifetime { get { return SessionSecurityTokenHandler.DefaultLifetime; } }
  51. public virtual TimeSpan TokenLifetime { get; set; }
  52. public override Type TokenType { get { return tokenType; } }
  53. public ReadOnlyCollection<CookieTransform> Transforms { get; private set; }
  54. public SessionSecurityTokenHandler ()
  55. : this (SessionSecurityTokenHandler.DefaultCookieTransforms)
  56. { }
  57. public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms)
  58. : this (transforms, SessionSecurityTokenHandler.DefaultLifetime)
  59. { }
  60. public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms, TimeSpan tokenLifetime) {
  61. Transforms = transforms;
  62. TokenLifetime = tokenLifetime;
  63. }
  64. [MonoTODO]
  65. protected virtual byte[] ApplyTransforms (byte[] cookie, bool outbound) {
  66. throw new NotImplementedException ();
  67. }
  68. [MonoTODO]
  69. public override bool CanReadToken (XmlReader reader) {
  70. throw new NotImplementedException ();
  71. }
  72. [MonoTODO]
  73. public virtual SessionSecurityToken CreateSessionSecurityToken (ClaimsPrincipal principal, string context, string endpointId, DateTime validFrom, DateTime validTo) {
  74. throw new NotImplementedException ();
  75. }
  76. [MonoTODO]
  77. public override SecurityToken CreateToken (SecurityTokenDescriptor tokenDescriptor) {
  78. throw new NotImplementedException ();
  79. }
  80. [MonoTODO]
  81. public override string[] GetTokenTypeIdentifiers () {
  82. throw new NotImplementedException ();
  83. }
  84. [MonoTODO]
  85. public override void LoadCustomConfiguration (XmlNodeList customConfigElements) {
  86. throw new NotImplementedException ();
  87. }
  88. [MonoTODO]
  89. public override SecurityToken ReadToken (XmlReader reader) {
  90. throw new NotImplementedException ();
  91. }
  92. [MonoTODO]
  93. public virtual SecurityToken ReadToken (byte[] token, SecurityTokenResolver tokenResolver) {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO]
  97. public override SecurityToken ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) {
  98. throw new NotImplementedException ();
  99. }
  100. [MonoTODO]
  101. protected void SetTransforms (IEnumerable<CookieTransform> transforms) {
  102. throw new NotImplementedException ();
  103. }
  104. [MonoTODO]
  105. protected virtual void ValidateSession (SessionSecurityToken securityToken) {
  106. throw new NotImplementedException ();
  107. }
  108. [MonoTODO]
  109. public override ReadOnlyCollection<ClaimsIdentity> ValidateToken (SecurityToken token) {
  110. throw new NotImplementedException ();
  111. }
  112. [MonoTODO]
  113. public virtual ReadOnlyCollection<ClaimsIdentity> ValidateToken (SessionSecurityToken token, string endpointId) {
  114. throw new NotImplementedException ();
  115. }
  116. [MonoTODO]
  117. public virtual byte[] WriteToken (SessionSecurityToken sessionToken) {
  118. throw new NotImplementedException ();
  119. }
  120. [MonoTODO]
  121. public override void WriteToken (XmlWriter writer, SecurityToken token) {
  122. throw new NotImplementedException ();
  123. }
  124. }
  125. }
  126. #endif