blob: bfc33aaba1979dd9841aebc721f84696644d0e61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
//-----------------------------------------------------------------------
// <copyright file="AuthorizationState.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
using DotNetOpenAuth.Messaging;
/// <summary>
/// A simple in-memory copy of an authorization state.
/// </summary>
[Serializable]
public class AuthorizationState : IAuthorizationState {
/// <summary>
/// Initializes a new instance of the <see cref="AuthorizationState"/> class.
/// </summary>
/// <param name="scopes">The scopes of access being requested or that was obtained.</param>
public AuthorizationState(IEnumerable<string> scopes = null) {
this.Scope = new HashSet<string>(OAuthUtilities.ScopeStringComparer);
if (scopes != null) {
this.Scope.AddRange(scopes);
}
}
/// <summary>
/// Gets or sets the callback URL used to obtain authorization.
/// </summary>
/// <value>The callback URL.</value>
public Uri Callback { get; set; }
/// <summary>
/// Gets or sets the long-lived token used to renew the short-lived <see cref="AccessToken"/>.
/// </summary>
/// <value>The refresh token.</value>
public string RefreshToken { get; set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
/// <value>The access token.</value>
public string AccessToken { get; set; }
/// <summary>
/// Gets or sets the access token UTC expiration date.
/// </summary>
/// <value></value>
public DateTime? AccessTokenExpirationUtc { get; set; }
/// <summary>
/// Gets or sets the access token issue date UTC.
/// </summary>
/// <value>The access token issue date UTC.</value>
public DateTime? AccessTokenIssueDateUtc { get; set; }
/// <summary>
/// Gets the scope the token is (to be) authorized for.
/// </summary>
/// <value>The scope.</value>
public HashSet<string> Scope { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is deleted.
/// </summary>
/// <value>
/// <c>true</c> if this instance is deleted; otherwise, <c>false</c>.
/// </value>
public bool IsDeleted { get; set; }
/// <summary>
/// Deletes this authorization, including access token and refresh token where applicable.
/// </summary>
/// <remarks>
/// This method is invoked when an authorization attempt fails, is rejected, is revoked, or
/// expires and cannot be renewed.
/// </remarks>
public virtual void Delete() {
this.IsDeleted = true;
}
/// <summary>
/// Saves any changes made to this authorization object's properties.
/// </summary>
/// <remarks>
/// This method is invoked after DotNetOpenAuth changes any property.
/// </remarks>
public virtual void SaveChanges() {
}
}
}
|