Documentation Coverage Report
Current view: top level - Cqrs/Authentication - DefaultAuthenticationTokenHelper.cs Hit Total Coverage
Version: 2.2 Artefacts: 8 8 100.0 %
Date: 2017-09-22

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="Chinchilla Software Limited">
       4             : // //   Copyright Chinchilla Software Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using cdmdotnet.StateManagement;
      11             : 
      12             : namespace Cqrs.Authentication
      13             : {
      14             :         /// <summary>
      15             :         /// A helper for setting and retrieving authentication tokens of type 
      16             :         /// <see cref="SingleSignOnToken"/>, <see cref="SingleSignOnTokenWithUserRsn"/>, <see cref="SingleSignOnTokenWithCompanyRsn"/>, <see cref="SingleSignOnTokenWithUserRsnAndCompanyRsn"/>
      17             :         /// <see cref="int"/>, <see cref="Guid"/> or <see cref="string"/>.
      18             :         /// </summary>
      19             :         public class DefaultAuthenticationTokenHelper
      20             :                 : AuthenticationTokenHelper<SingleSignOnToken>
      21             :                 , IAuthenticationTokenHelper<SingleSignOnTokenWithUserRsn>
      22             :                 , IAuthenticationTokenHelper<SingleSignOnTokenWithCompanyRsn>
      23             :                 , IAuthenticationTokenHelper<SingleSignOnTokenWithUserRsnAndCompanyRsn>
      24             :                 , IAuthenticationTokenHelper<int>
      25             :                 , IAuthenticationTokenHelper<Guid>
      26             :                 , IAuthenticationTokenHelper<string>
      27           1 :         {
      28             :                 private const string CallContextPermissionScopeValueKey = "SingleSignOnTokenValue";
      29             : 
      30             :                 /// <summary>
      31             :                 /// Instantiate a new instance of <see cref="DefaultAuthenticationTokenHelper"/>
      32             :                 /// </summary>
      33           1 :                 public DefaultAuthenticationTokenHelper(IContextItemCollectionFactory factory)
      34             :                         : base(factory)
      35             :                 {
      36             :                         CacheKey = CallContextPermissionScopeValueKey;
      37             :                 }
      38             : 
      39             :                 /// <summary>
      40             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      41             :                 /// </summary>
      42           1 :                 public SingleSignOnTokenWithUserRsnAndCompanyRsn SetAuthenticationToken(SingleSignOnTokenWithUserRsnAndCompanyRsn token)
      43             :                 {
      44             :                         SetAuthenticationToken((SingleSignOnToken)token);
      45             :                         return token;
      46             :                 }
      47             : 
      48             :                 /// <summary>
      49             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      50             :                 /// </summary>
      51           1 :                 public SingleSignOnTokenWithCompanyRsn SetAuthenticationToken(SingleSignOnTokenWithCompanyRsn token)
      52             :                 {
      53             :                         SetAuthenticationToken((SingleSignOnToken)token);
      54             :                         return token;
      55             :                 }
      56             : 
      57             :                 /// <summary>
      58             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      59             :                 /// </summary>
      60           1 :                 public SingleSignOnTokenWithUserRsn SetAuthenticationToken(SingleSignOnTokenWithUserRsn token)
      61             :                 {
      62             :                         SetAuthenticationToken((SingleSignOnToken)token);
      63             :                         return token;
      64             :                 }
      65             : 
      66             :                 /// <summary>
      67             :                 /// Get the current <see cref="SingleSignOnTokenWithUserRsn">authentication token</see> for the current context/request.
      68             :                 /// </summary>
      69             :                 SingleSignOnTokenWithUserRsn IAuthenticationTokenHelper<SingleSignOnTokenWithUserRsn>.GetAuthenticationToken()
      70             :                 {
      71             :                         return Cache.GetData<SingleSignOnTokenWithUserRsn>(CallContextPermissionScopeValueKey);
      72             :                 }
      73             : 
      74             :                 /// <summary>
      75             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      76             :                 /// </summary>
      77           1 :                 public Guid SetAuthenticationToken(Guid token)
      78             :                 {
      79             :                         Cache.SetData(CacheKey, token);
      80             :                         return token;
      81             :                 }
      82             : 
      83             :                 /// <summary>
      84             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      85             :                 /// </summary>
      86           1 :                 public int SetAuthenticationToken(int token)
      87             :                 {
      88             :                         Cache.SetData(CacheKey, token);
      89             :                         return token;
      90             :                 }
      91             : 
      92             :                 /// <summary>
      93             :                 /// Set the provided <paramref name="token"/> for the current context/request.
      94             :                 /// </summary>
      95           1 :                 public string SetAuthenticationToken(string token)
      96             :                 {
      97             :                         Cache.SetData(CacheKey, token);
      98             :                         return token;
      99             :                 }
     100             : 
     101             :                 /// <summary>
     102             :                 /// Get the current <see cref="SingleSignOnTokenWithCompanyRsn">authentication token</see> for the current context/request.
     103             :                 /// </summary>
     104             :                 SingleSignOnTokenWithCompanyRsn IAuthenticationTokenHelper<SingleSignOnTokenWithCompanyRsn>.GetAuthenticationToken()
     105             :                 {
     106             :                         return Cache.GetData<SingleSignOnTokenWithCompanyRsn>(CallContextPermissionScopeValueKey);
     107             :                 }
     108             : 
     109             :                 /// <summary>
     110             :                 /// Get the current <see cref="SingleSignOnTokenWithUserRsnAndCompanyRsn">authentication token</see> for the current context/request.
     111             :                 /// </summary>
     112             :                 SingleSignOnTokenWithUserRsnAndCompanyRsn IAuthenticationTokenHelper<SingleSignOnTokenWithUserRsnAndCompanyRsn>.GetAuthenticationToken()
     113             :                 {
     114             :                         return Cache.GetData<SingleSignOnTokenWithUserRsnAndCompanyRsn>(CallContextPermissionScopeValueKey);
     115             :                 }
     116             : 
     117             :                 #region Implementation of IAuthenticationTokenHelper<int>
     118             : 
     119             :                 /// <summary>
     120             :                 /// Get the current <see cref="int">authentication token</see> for the current context/request.
     121             :                 /// </summary>
     122             :                 int IAuthenticationTokenHelper<int>.GetAuthenticationToken()
     123             :                 {
     124             :                         return Cache.GetData<int>(CallContextPermissionScopeValueKey);
     125             :                 }
     126             : 
     127             :                 #endregion
     128             : 
     129             :                 #region Implementation of IAuthenticationTokenHelper<Guid>
     130             : 
     131             :                 /// <summary>
     132             :                 /// Get the current <see cref="Guid">authentication token</see> for the current context/request.
     133             :                 /// </summary>
     134             :                 Guid IAuthenticationTokenHelper<Guid>.GetAuthenticationToken()
     135             :                 {
     136             :                         return Cache.GetData<Guid>(CallContextPermissionScopeValueKey);
     137             :                 }
     138             : 
     139             :                 #endregion
     140             : 
     141             :                 #region Implementation of IAuthenticationTokenHelper<string>
     142             : 
     143             :                 /// <summary>
     144             :                 /// Get the current <see cref="string">authentication token</see> for the current context/request.
     145             :                 /// </summary>
     146             :                 string IAuthenticationTokenHelper<string>.GetAuthenticationToken()
     147             :                 {
     148             :                         return Cache.GetData<string>(CallContextPermissionScopeValueKey);
     149             :                 }
     150             : 
     151             :                 #endregion
     152             :         }
     153             : }

Generated by: LCOV version 1.10