//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
using DotNetOpenAuth.Messaging;
///
/// A simple in-memory copy of an authorization state.
///
[Serializable]
public class AuthorizationState : IAuthorizationState {
///
/// Initializes a new instance of the class.
///
/// The scopes of access being requested or that was obtained.
public AuthorizationState(IEnumerable scopes = null) {
this.Scope = new HashSet(OAuthUtilities.ScopeStringComparer);
if (scopes != null) {
this.Scope.AddRange(scopes);
}
}
///
/// Gets or sets the callback URL used to obtain authorization.
///
/// The callback URL.
public Uri Callback { get; set; }
///
/// Gets or sets the long-lived token used to renew the short-lived .
///
/// The refresh token.
public string RefreshToken { get; set; }
///
/// Gets or sets the access token.
///
/// The access token.
public string AccessToken { get; set; }
///
/// Gets or sets the access token UTC expiration date.
///
///
public DateTime? AccessTokenExpirationUtc { get; set; }
///
/// Gets or sets the access token issue date UTC.
///
/// The access token issue date UTC.
public DateTime? AccessTokenIssueDateUtc { get; set; }
///
/// Gets the scope the token is (to be) authorized for.
///
/// The scope.
public HashSet Scope { get; private set; }
///
/// Gets or sets a value indicating whether this instance is deleted.
///
///
/// true if this instance is deleted; otherwise, false.
///
public bool IsDeleted { get; set; }
///
/// Deletes this authorization, including access token and refresh token where applicable.
///
///
/// This method is invoked when an authorization attempt fails, is rejected, is revoked, or
/// expires and cannot be renewed.
///
public virtual void Delete() {
this.IsDeleted = true;
}
///
/// Saves any changes made to this authorization object's properties.
///
///
/// This method is invoked after DotNetOpenAuth changes any property.
///
public virtual void SaveChanges() {
}
}
}