| | 1 | | namespace Songhay.Models; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// Defines Authorization Information for OAuth 1.0. |
| | 5 | | /// </summary> |
| | 6 | | public class OpenAuthorizationData |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Initializes a new instance of the <see cref="OpenAuthorizationData"/> class. |
| | 10 | | /// </summary> |
| | 11 | | public OpenAuthorizationData() |
| 0 | 12 | | : this(null, null) |
| 0 | 13 | | { |
| 0 | 14 | | } |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Initializes a new instance of the <see cref="OpenAuthorizationData"/> class. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="data">The data.</param> |
| | 20 | | public OpenAuthorizationData(NameValueCollection data) |
| 0 | 21 | | : this(null, data) |
| 0 | 22 | | { |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Initializes a new instance of the <see cref="OpenAuthorizationData" /> class. |
| | 27 | | /// </summary> |
| | 28 | | /// <param name="nonce">The nonce.</param> |
| | 29 | | /// <param name="data">The data.</param> |
| 0 | 30 | | public OpenAuthorizationData(string? nonce, NameValueCollection? data) |
| 0 | 31 | | { |
| 0 | 32 | | Nonce = string.IsNullOrWhiteSpace(nonce) |
| 0 | 33 | | ? Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString())) |
| 0 | 34 | | : nonce; |
| 0 | 35 | | SignatureMethod = "HMAC-SHA1"; |
| 0 | 36 | | var timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); |
| 0 | 37 | | TimeStamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString(); |
| 0 | 38 | | Version = "1.0"; |
| | 39 | |
|
| 0 | 40 | | if (data == null) return; |
| 0 | 41 | | ConsumerKey = data["TwitterConsumerKey"]; |
| 0 | 42 | | ConsumerSecret = data["TwitterConsumerSecret"]; |
| 0 | 43 | | Token = data["TwitterToken"]; |
| 0 | 44 | | TokenSecret = data["TwitterTokenSecret"]; |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Initializes a new instance of the <see cref="OpenAuthorizationData" /> class. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="nonce">The nonce.</param> |
| 0 | 51 | | public OpenAuthorizationData(string nonce) : this() |
| 0 | 52 | | { |
| 0 | 53 | | Nonce = nonce; |
| 0 | 54 | | } |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Gets or sets the consumer key. |
| | 58 | | /// </summary> |
| 0 | 59 | | public string? ConsumerKey { get; set; } |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// Gets or sets the consumer secret. |
| | 63 | | /// </summary> |
| 0 | 64 | | public string? ConsumerSecret { get; set; } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Gets the nonce. |
| | 68 | | /// </summary> |
| 0 | 69 | | public string? Nonce { get; set; } |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// Gets or sets the time stamp. |
| | 73 | | /// </summary> |
| 0 | 74 | | public string? TimeStamp { get; set; } |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// Gets or sets the token. |
| | 78 | | /// </summary> |
| 0 | 79 | | public string? Token { get; set; } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Gets or sets the token secret. |
| | 83 | | /// </summary> |
| 0 | 84 | | public string? TokenSecret { get; set; } |
| | 85 | |
|
| | 86 | | /// <summary> |
| | 87 | | /// Gets the signature method. |
| | 88 | | /// </summary> |
| 0 | 89 | | public string? SignatureMethod { get; set; } |
| | 90 | |
|
| | 91 | | /// <summary> |
| | 92 | | /// Gets or sets the version. |
| | 93 | | /// </summary> |
| 0 | 94 | | public string? Version { get; set; } |
| | 95 | | } |