blob: ee41957ae2d2326af13cf112a4504ae4fccb8d08 (
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
|
//-----------------------------------------------------------------------
// <copyright file="RefreshToken.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2.ChannelElements {
using System;
using System.Diagnostics.Contracts;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
/// <summary>
/// The refresh token issued to a client by an authorization server that allows the client
/// to periodically obtain new short-lived access tokens.
/// </summary>
internal class RefreshToken : AuthorizationDataBag {
/// <summary>
/// The name of the bucket for symmetric keys used to sign refresh tokens.
/// </summary>
internal const string RefreshTokenKeyBucket = "https://localhost/dnoa/oauth_refresh_token";
/// <summary>
/// Initializes a new instance of the <see cref="RefreshToken"/> class.
/// </summary>
public RefreshToken() {
}
/// <summary>
/// Initializes a new instance of the <see cref="RefreshToken"/> class.
/// </summary>
/// <param name="authorization">The authorization this refresh token should describe.</param>
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);
}
/// <summary>
/// Creates a formatter capable of serializing/deserializing a refresh token.
/// </summary>
/// <param name="cryptoKeyStore">The crypto key store.</param>
/// <returns>
/// A DataBag formatter. Never null.
/// </returns>
internal static IDataBagFormatter<RefreshToken> CreateFormatter(ICryptoKeyStore cryptoKeyStore) {
Requires.NotNull(cryptoKeyStore, "cryptoKeyStore");
Contract.Ensures(Contract.Result<IDataBagFormatter<RefreshToken>>() != null);
return new UriStyleMessageFormatter<RefreshToken>(cryptoKeyStore, RefreshTokenKeyBucket, signed: true, encrypted: true);
}
}
}
|