//----------------------------------------------------------------------- // // 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; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2.ChannelElements; /// /// An access token minted by the authorization server that can be serialized for transmission to the client. /// public class AuthorizationServerAccessToken : AccessToken { /// /// Initializes a new instance of the class. /// public AuthorizationServerAccessToken() { } /// /// 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; } /// /// Serializes this instance to a simple string for transmission to the client. /// /// A non-empty string. protected internal override string Serialize() { ErrorUtilities.VerifyHost(this.AccessTokenSigningKey != null, AuthServerStrings.AccessTokenSigningKeyMissing); var formatter = CreateFormatter(this.AccessTokenSigningKey, this.ResourceServerEncryptionKey); return formatter.Serialize(this); } } }