Documentation Coverage Report
Current view: top level - Cqrs/Authentication - SingleSignOnTokenFactory.cs Hit Total Coverage
Version: 2.2 Artefacts: 3 3 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             : 
      11             : namespace Cqrs.Authentication
      12             : {
      13             :         /// <summary>
      14             :         /// A factory for creating new authentication tokens of type <typeparamref name="TSingleSignOnToken"/>.
      15             :         /// </summary>
      16             :         /// <typeparam name="TSingleSignOnToken">The <see cref="Type"/> of <see cref="ISingleSignOnToken"/>.</typeparam>
      17             :         public class SingleSignOnTokenFactory<TSingleSignOnToken> : ISingleSignOnTokenFactory<TSingleSignOnToken>
      18             :                         where TSingleSignOnToken : ISingleSignOnToken, new()
      19           1 :         {
      20             :                 /// <summary>
      21             :                 /// Create a new <typeparamref name="TSingleSignOnToken"/>.
      22             :                 /// </summary>
      23             :                 /// <param name="timeoutInMinutes">The amount of time in minutes to set the <see cref="ISingleSignOnToken.TimeOfExpiry"/> to. This is from <see cref="DateTime.UtcNow"/></param>
      24           1 :                 public virtual TSingleSignOnToken CreateNew(int timeoutInMinutes = 360)
      25             :                 {
      26             :                         var token = new TSingleSignOnToken
      27             :                         {
      28             :                                 Token = Guid.NewGuid().ToString("N"),
      29             :                                 DateIssued = DateTime.UtcNow,
      30             :                                 TimeOfExpiry = DateTime.UtcNow.AddMinutes(timeoutInMinutes),
      31             :                         };
      32             : 
      33             :                         return RenewTokenExpiry(token, timeoutInMinutes);
      34             :                 }
      35             : 
      36             :                 /// <summary>
      37             :                 /// Renew the value of <see cref="ISingleSignOnToken.TimeOfExpiry"/>.
      38             :                 /// </summary>
      39             :                 /// <param name="token">The <see cref="ISingleSignOnToken"/> to renew.</param>
      40             :                 /// <param name="timeoutInMinutes">The amount of time in minutes to set the <see cref="ISingleSignOnToken.TimeOfExpiry"/> to. This is from <see cref="DateTime.UtcNow"/></param>
      41           1 :                 public virtual TSingleSignOnToken RenewTokenExpiry(TSingleSignOnToken token, int timeoutInMinutes = 360)
      42             :                 {
      43             :                         token.TimeOfExpiry = DateTime.UtcNow.AddMinutes(timeoutInMinutes);
      44             : 
      45             :                         return token;
      46             :                 }
      47             :         }
      48             : }

Generated by: LCOV version 1.10