//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2.ChannelElements { using System; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; using Validation; /// /// The refresh token issued to a client by an authorization server that allows the client /// to periodically obtain new short-lived access tokens. /// internal class RefreshToken : AuthorizationDataBag { /// /// The name of the bucket for symmetric keys used to sign refresh tokens. /// internal const string RefreshTokenKeyBucket = "https://localhost/dnoa/oauth_refresh_token"; /// /// Initializes a new instance of the class. /// public RefreshToken() { } /// /// Initializes a new instance of the class. /// /// The authorization this refresh token should describe. internal RefreshToken(IAuthorizationDescription authorization) { Requires.NotNull(authorization, "authorization"); this.ClientIdentifier = authorization.ClientIdentifier; this.UtcCreationDate = authorization.UtcIssued; this.User = authorization.User; this.Scope.ResetContents(authorization.Scope); } /// /// Creates a formatter capable of serializing/deserializing a refresh token. /// /// The crypto key store. /// /// A DataBag formatter. Never null. /// internal static IDataBagFormatter CreateFormatter(ICryptoKeyStore cryptoKeyStore) { Requires.NotNull(cryptoKeyStore, "cryptoKeyStore"); return new UriStyleMessageFormatter(cryptoKeyStore, RefreshTokenKeyBucket, signed: true, encrypted: true); } } }