diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-05-31 08:00:50 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-05-31 08:00:50 -0700 |
commit | ad60330d66985c4892b7e0b7ddb424be9ca867c8 (patch) | |
tree | 5efdb30c9b14e1928828b76c8a66822779a17198 /samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs | |
parent | 52a77983f11cfbb948a574585ba8069dcbcbd89b (diff) | |
download | DotNetOpenAuth-ad60330d66985c4892b7e0b7ddb424be9ca867c8.zip DotNetOpenAuth-ad60330d66985c4892b7e0b7ddb424be9ca867c8.tar.gz DotNetOpenAuth-ad60330d66985c4892b7e0b7ddb424be9ca867c8.tar.bz2 |
More work toward a working authorization server.
Diffstat (limited to 'samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs')
-rw-r--r-- | samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs b/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs index be6f885..15d791e 100644 --- a/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs +++ b/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs @@ -1,4 +1,5 @@ -using DotNetOpenAuth.OAuth.ChannelElements; +using DotNetOpenAuth.Messaging.Bindings; +using DotNetOpenAuth.OAuth.ChannelElements; namespace OAuthServiceProvider.Code { using System; @@ -8,47 +9,28 @@ namespace OAuthServiceProvider.Code { 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 IConsumerDescription GetClient(string clientIdentifier) - { - throw new NotImplementedException(); - } - - #endregion - public byte[] Secret { - get { throw new NotImplementedException(); } + get { return secret; } } public DotNetOpenAuth.Messaging.Bindings.INonceStore VerificationCodeNonceStore { - get { throw new NotImplementedException(); } + get { return this.nonceStore; } } - private class ConsumerDescription : IConsumerDescription { - public string Key { - get { throw new NotImplementedException(); } - } - - public string Secret { - get { throw new NotImplementedException(); } - } - - public System.Security.Cryptography.X509Certificates.X509Certificate2 Certificate { - get { throw new NotImplementedException(); } + public IConsumerDescription GetClient(string clientIdentifier) { + var consumerRow = Global.DataContext.OAuthConsumers.SingleOrDefault( + consumerCandidate => consumerCandidate.ConsumerKey == clientIdentifier); + if (consumerRow == null) { + throw new ArgumentOutOfRangeException("clientIdentifier"); } - public Uri Callback { - get { throw new NotImplementedException(); } - } - - public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat { - get { throw new NotImplementedException(); } - } - - public int VerificationCodeLength { - get { throw new NotImplementedException(); } - } + return consumerRow; } + + #endregion } }
\ No newline at end of file |