blob: 125505a9e5c10a89161b983fb1fca67e4bfdc8bf (
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
|
//-----------------------------------------------------------------------
// <copyright file="MemoryTemporaryCredentialStorage.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// Non-persistent memory storage for temporary credentials.
/// Useful for installed apps (not redirection based web apps).
/// </summary>
public class MemoryTemporaryCredentialStorage : ITemporaryCredentialStorage {
/// <summary>
/// The identifier.
/// </summary>
private string identifier;
/// <summary>
/// The secret.
/// </summary>
private string secret;
#region ITemporaryCredentialStorage Members
/// <summary>
/// Saves the specified temporary credential for later retrieval.
/// </summary>
/// <param name="identifier">The identifier.</param>
/// <param name="secret">The secret.</param>
public void SaveTemporaryCredential(string identifier, string secret) {
this.identifier = identifier;
this.secret = secret;
}
/// <summary>
/// Obtains a temporary credential secret, if available.
/// </summary>
/// <returns>
/// The temporary credential secret if available; otherwise <c>null</c>.
/// </returns>
public KeyValuePair<string, string> RetrieveTemporaryCredential() {
return new KeyValuePair<string, string>(this.identifier, this.secret);
}
/// <summary>
/// Clears the temporary credentials from storage.
/// </summary>
/// <remarks>
/// DotNetOpenAuth calls this when the credentials are no longer needed.
/// </remarks>
public void ClearTemporaryCredential() {
this.identifier = null;
this.secret = null;
}
#endregion
}
}
|