blob: 09acbc5c640a93eb5371f70eb205cf143a291916 (
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
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
|
//-----------------------------------------------------------------------
// <copyright file="AccessTokenFailedResponse.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2.Messages {
using System;
using System.Net;
using Messaging;
/// <summary>
/// A response from the Authorization Server to the Client to indicate that a
/// request for an access token renewal failed, probably due to an invalid
/// refresh token.
/// </summary>
/// <remarks>
/// This message type is shared by the Web App, Rich App, and Username/Password profiles.
/// </remarks>
internal class AccessTokenFailedResponse : MessageBase, IHttpDirectResponse {
/// <summary>
/// A value indicating whether this error response is in result to a request that had invalid client credentials which were supplied in the HTTP Authorization header.
/// </summary>
private readonly bool invalidClientCredentialsInAuthorizationHeader;
/// <summary>
/// Initializes a new instance of the <see cref="AccessTokenFailedResponse"/> class.
/// </summary>
/// <param name="request">The faulty request.</param>
internal AccessTokenFailedResponse(AccessTokenRequestBase request)
: base(request) {
}
/// <summary>
/// Initializes a new instance of the <see cref="AccessTokenFailedResponse"/> class.
/// </summary>
/// <param name="request">The faulty request.</param>
/// <param name="invalidClientCredentialsInAuthorizationHeader">A value indicating whether this error response is in result to a request that had invalid client credentials which were supplied in the HTTP Authorization header.</param>
internal AccessTokenFailedResponse(AccessTokenRequestBase request, bool invalidClientCredentialsInAuthorizationHeader)
: base(request)
{
this.invalidClientCredentialsInAuthorizationHeader = invalidClientCredentialsInAuthorizationHeader;
}
#region IHttpDirectResponse Members
/// <summary>
/// Gets the HTTP status code that the direct response should be sent with.
/// </summary>
HttpStatusCode IHttpDirectResponse.HttpStatusCode {
get { return this.invalidClientCredentialsInAuthorizationHeader ? HttpStatusCode.Unauthorized : HttpStatusCode.BadRequest; }
}
/// <summary>
/// Gets the HTTP headers to add to the response.
/// </summary>
/// <value>May be an empty collection, but must not be <c>null</c>.</value>
WebHeaderCollection IHttpDirectResponse.Headers {
get { return new WebHeaderCollection(); }
}
#endregion
/// <summary>
/// Gets or sets the error.
/// </summary>
/// <value>One of the values given in <see cref="Protocol.AccessTokenRequestErrorCodes"/>.</value>
[MessagePart(Protocol.error, IsRequired = true)]
internal string Error { get; set; }
/// <summary>
/// Gets or sets a human readable description of the error.
/// </summary>
/// <value>Human-readable text providing additional information, used to assist in the understanding and resolution of the error that occurred.</value>
[MessagePart(Protocol.error_description, IsRequired = false)]
internal string ErrorDescription { get; set; }
/// <summary>
/// Gets or sets the location of the web page that describes the error and possible resolution.
/// </summary>
/// <value>A URI identifying a human-readable web page with information about the error, used to provide the end-user with additional information about the error.</value>
[MessagePart(Protocol.error_uri, IsRequired = false)]
internal Uri ErrorUri { get; set; }
}
}
|