2 // SessionSecurityTokenHandler.cs
5 // Noesis Labs (Ryan.Melena@noesislabs.com)
7 // Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
30 using System.Collections.Generic;
31 using System.Collections.ObjectModel;
32 using System.IdentityModel.Selectors;
33 using System.Security.Claims;
36 namespace System.IdentityModel.Tokens
38 public class SessionSecurityTokenHandler : SecurityTokenHandler
40 public static readonly ReadOnlyCollection<CookieTransform> DefaultCookieTransforms;
41 public static readonly TimeSpan DefaultLifetime = TimeSpan.FromHours (10);
43 private bool canValidateToken;
44 private bool canWriteToken;
45 private string cookieElementName;
46 private string cookieNamespace;
47 private Type tokenType;
49 public override bool CanValidateToken { get { return canValidateToken; } }
50 public override bool CanWriteToken { get { return canWriteToken; } }
51 public virtual string CookieElementName { get { return cookieElementName; } }
52 public virtual string CookieNamespace { get { return cookieNamespace; } }
53 public static TimeSpan DefaultTokenLifetime { get { return SessionSecurityTokenHandler.DefaultLifetime; } }
54 public virtual TimeSpan TokenLifetime { get; set; }
55 public override Type TokenType { get { return tokenType; } }
56 public ReadOnlyCollection<CookieTransform> Transforms { get; private set; }
58 public SessionSecurityTokenHandler ()
59 : this (SessionSecurityTokenHandler.DefaultCookieTransforms)
62 public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms)
63 : this (transforms, SessionSecurityTokenHandler.DefaultLifetime)
66 public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms, TimeSpan tokenLifetime) {
67 Transforms = transforms;
68 TokenLifetime = tokenLifetime;
72 protected virtual byte[] ApplyTransforms (byte[] cookie, bool outbound) {
73 throw new NotImplementedException ();
77 public override bool CanReadToken (XmlReader reader) {
78 throw new NotImplementedException ();
82 public virtual SessionSecurityToken CreateSessionSecurityToken (ClaimsPrincipal principal, string context, string endpointId, DateTime validFrom, DateTime validTo) {
83 throw new NotImplementedException ();
87 public override SecurityToken CreateToken (SecurityTokenDescriptor tokenDescriptor) {
88 throw new NotImplementedException ();
92 public override string[] GetTokenTypeIdentifiers () {
93 throw new NotImplementedException ();
97 public override void LoadCustomConfiguration (XmlNodeList customConfigElements) {
98 throw new NotImplementedException ();
102 public override SecurityToken ReadToken (XmlReader reader) {
103 throw new NotImplementedException ();
107 public virtual SecurityToken ReadToken (byte[] token, SecurityTokenResolver tokenResolver) {
108 throw new NotImplementedException ();
112 public override SecurityToken ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) {
113 throw new NotImplementedException ();
117 protected void SetTransforms (IEnumerable<CookieTransform> transforms) {
118 throw new NotImplementedException ();
122 protected virtual void ValidateSession (SessionSecurityToken securityToken) {
123 throw new NotImplementedException ();
127 public override ReadOnlyCollection<ClaimsIdentity> ValidateToken (SecurityToken token) {
128 throw new NotImplementedException ();
132 public virtual ReadOnlyCollection<ClaimsIdentity> ValidateToken (SessionSecurityToken token, string endpointId) {
133 throw new NotImplementedException ();
137 public virtual byte[] WriteToken (SessionSecurityToken sessionToken) {
138 throw new NotImplementedException ();
142 public override void WriteToken (XmlWriter writer, SecurityToken token) {
143 throw new NotImplementedException ();