//-----------------------------------------------------------------------
//
// Copyright (c) Andrew Arnott. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
///
/// Describes the parameters to be fed into creating a response to an access token request.
///
public class AccessTokenParameters : IDisposable {
///
/// Initializes a new instance of the class.
///
public AccessTokenParameters() {
this.IncludeRefreshToken = true;
this.AccessTokenLifetime = TimeSpan.FromHours(1);
}
///
/// Gets or sets the access token lifetime.
///
///
/// A positive timespan.
///
///
/// Note that within this lifetime, authorization may not be revokable.
/// Short lifetimes are recommended (e.g. one hour), particularly when the client is not authenticated or
/// the resources to which access is being granted are sensitive.
///
public TimeSpan AccessTokenLifetime { get; set; }
///
/// Gets or sets the crypto service provider with the asymmetric private key to use for signing access tokens.
///
/// A crypto service provider instance that contains the private key.
/// Must not be null, and must contain the private key.
///
/// The public key in the private/public key pair will be used by the resource
/// servers to validate that the access token is minted by a trusted authorization server.
///
public RSACryptoServiceProvider AccessTokenSigningKey { get; set; }
///
/// Gets or sets the key to encrypt the access token.
///
public RSACryptoServiceProvider ResourceServerEncryptionKey { get; set; }
///
/// Gets or sets a value indicating whether to provide the client with a refresh token, when applicable.
///
/// The default value is true.
/// >
/// The refresh token will never be provided when this value is false.
/// The refresh token may be provided when this value is true.
///
public bool IncludeRefreshToken { get; set; }
#region Implementation of IDisposable
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
/// 2
public void Dispose() {
this.Dispose(true);
GC.SuppressFinalize(this);
}
///
/// Releases unmanaged and - optionally - managed resources
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (this.ResourceServerEncryptionKey != null) {
IDisposable value = this.ResourceServerEncryptionKey;
value.Dispose();
}
if (this.AccessTokenSigningKey != null) {
IDisposable value = this.AccessTokenSigningKey;
value.Dispose();
}
}
}
#endregion
}
}