blob: 15d791ee09773b0dec8ae806eaeca32445bc8a49 (
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
|
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.OAuth.ChannelElements;
namespace OAuthServiceProvider.Code {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetOpenAuth.OAuthWrap;
internal class OAuth2AuthorizationServer : IAuthorizationServer {
private static readonly byte[] secret = new byte[] { 0x33, 0x55 }; // TODO: make this cryptographically strong and unique per app.
private readonly INonceStore nonceStore = new DatabaseNonceStore();
#region Implementation of IAuthorizationServer
public byte[] Secret {
get { return secret; }
}
public DotNetOpenAuth.Messaging.Bindings.INonceStore VerificationCodeNonceStore {
get { return this.nonceStore; }
}
public IConsumerDescription GetClient(string clientIdentifier) {
var consumerRow = Global.DataContext.OAuthConsumers.SingleOrDefault(
consumerCandidate => consumerCandidate.ConsumerKey == clientIdentifier);
if (consumerRow == null) {
throw new ArgumentOutOfRangeException("clientIdentifier");
}
return consumerRow;
}
#endregion
}
}
|