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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
//-----------------------------------------------------------------------
// <copyright file="EndUserAuthorizationSuccessAccessTokenResponse.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2.Messages {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2.ChannelElements;
/// <summary>
/// The message sent by the Authorization Server to the Client via the user agent
/// to indicate that user authorization was granted, carrying only an access token,
/// and to return the user to the Client where they started their experience.
/// </summary>
internal class EndUserAuthorizationSuccessAccessTokenResponse : EndUserAuthorizationSuccessResponseBase, IAuthorizationCarryingRequest, IHttpIndirectResponse {
/// <summary>
/// Initializes a new instance of the <see cref="EndUserAuthorizationSuccessAccessTokenResponse"/> class.
/// </summary>
/// <param name="clientCallback">The URL to redirect to so the client receives the message. This may not be built into the request message if the client pre-registered the URL with the authorization server.</param>
/// <param name="version">The protocol version.</param>
internal EndUserAuthorizationSuccessAccessTokenResponse(Uri clientCallback, Version version)
: base(clientCallback, version) {
Requires.NotNull(version, "version");
Requires.NotNull(clientCallback, "clientCallback");
this.TokenType = Protocol.AccessTokenTypes.Bearer;
}
/// <summary>
/// Initializes a new instance of the <see cref="EndUserAuthorizationSuccessAccessTokenResponse"/> class.
/// </summary>
/// <param name="clientCallback">The URL to redirect to so the client receives the message. This may not be built into the request message if the client pre-registered the URL with the authorization server.</param>
/// <param name="request">The authorization request from the user agent on behalf of the client.</param>
internal EndUserAuthorizationSuccessAccessTokenResponse(Uri clientCallback, EndUserAuthorizationRequest request)
: base(clientCallback, request) {
Requires.NotNull(clientCallback, "clientCallback");
Requires.NotNull(request, "request");
((IMessageWithClientState)this).ClientState = request.ClientState;
this.TokenType = Protocol.AccessTokenTypes.Bearer;
}
#region IAuthorizationCarryingRequest Members
/// <summary>
/// Gets or sets the verification code or refresh/access token.
/// </summary>
/// <value>The code or token.</value>
string IAuthorizationCarryingRequest.CodeOrToken {
get { return this.AccessToken; }
set { this.AccessToken = value; }
}
/// <summary>
/// Gets the type of the code or token.
/// </summary>
/// <value>The type of the code or token.</value>
CodeOrTokenType IAuthorizationCarryingRequest.CodeOrTokenType {
get { return CodeOrTokenType.AccessToken; }
}
/// <summary>
/// Gets or sets the authorization that the token describes.
/// </summary>
/// <value></value>
IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get; set; }
#endregion
#region IHttpIndirectResponse Members
/// <summary>
/// Gets a value indicating whether the payload for the message should be included
/// in the redirect fragment instead of the query string or POST entity.
/// </summary>
bool IHttpIndirectResponse.Include301RedirectPayloadInFragment {
get { return true; }
}
#endregion
/// <summary>
/// Gets or sets the token type.
/// </summary>
/// <value>Usually "bearer".</value>
/// <remarks>
/// Described in OAuth 2.0 section 7.1.
/// </remarks>
[MessagePart(Protocol.token_type, IsRequired = true)]
public string TokenType { get; internal set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
/// <value>The access token.</value>
[MessagePart(Protocol.access_token, IsRequired = true)]
public string AccessToken { get; set; }
/// <summary>
/// Gets or sets the scope of the <see cref="AccessToken"/> if one is given; otherwise the scope of the authorization code.
/// </summary>
/// <value>The scope.</value>
[MessagePart(Protocol.scope, IsRequired = false, Encoder = typeof(ScopeEncoder))]
public new ICollection<string> Scope {
get { return base.Scope; }
protected set { base.Scope = value; }
}
/// <summary>
/// Gets or sets the lifetime of the authorization.
/// </summary>
/// <value>The lifetime.</value>
[MessagePart(Protocol.expires_in, IsRequired = false, Encoder = typeof(TimespanSecondsEncoder))]
internal TimeSpan? Lifetime { get; set; }
}
}
|