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 <see cref="SingleSignOnToken"/>
15 : /// </summary>
16 : public class DefaultSingleSignOnTokenFactory : SingleSignOnTokenFactory<SingleSignOnToken>, IDefaultSingleSignOnTokenFactory
17 1 : {
18 : #region Implementation of IDefaultSingleSignOnTokenFactory
19 :
20 : /// <summary>
21 : /// Renew the value of <see cref="ISingleSignOnToken.TimeOfExpiry"/>.
22 : /// </summary>
23 : /// <param name="token">The <see cref="ISingleSignOnToken"/> to renew.</param>
24 : /// <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>
25 : #pragma warning disable 1066 // I like the explicit nature of informing what the default value should be of any implementation if not provided.
26 : ISingleSignOnToken IDefaultSingleSignOnTokenFactory.RenewTokenExpiry(ISingleSignOnToken token, int timeoutInMinutes = 360)
27 : #pragma warning restore 1066
28 : {
29 : return RenewTokenExpiry(token, timeoutInMinutes);
30 : }
31 :
32 : #endregion
33 :
34 : /// <summary>
35 : /// Renew the value of <see cref="ISingleSignOnToken.TimeOfExpiry"/>.
36 : /// </summary>
37 : /// <param name="token">The <see cref="ISingleSignOnToken"/> to renew.</param>
38 : /// <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>
39 1 : public virtual TSingleSignOnToken RenewTokenExpiry<TSingleSignOnToken>(TSingleSignOnToken token, int timeoutInMinutes = 360)
40 : where TSingleSignOnToken : ISingleSignOnToken
41 : {
42 : token.TimeOfExpiry = DateTime.UtcNow.AddMinutes(timeoutInMinutes);
43 :
44 : return token;
45 : }
46 : }
47 : }
|