summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-09-25 16:57:17 -0700
committerAndrew <andrewarnott@gmail.com>2008-09-25 16:57:17 -0700
commit50e34bfe7224576e901efa6748598d31c36df3a5 (patch)
tree4c9f820f54bb5578addbf064136f712dcf35c5c7 /src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs
parenta9fb696c40441e06ef817d7e28bae74c6a6cb6e4 (diff)
downloadDotNetOpenAuth-50e34bfe7224576e901efa6748598d31c36df3a5.zip
DotNetOpenAuth-50e34bfe7224576e901efa6748598d31c36df3a5.tar.gz
DotNetOpenAuth-50e34bfe7224576e901efa6748598d31c36df3a5.tar.bz2
Fixed lots of StyleCop issues and refacted Consumer/Service Provider a bit.
Diffstat (limited to 'src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs')
-rw-r--r--src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs b/src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs
index b54da20..fb2590a 100644
--- a/src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs
+++ b/src/DotNetOAuth/ChannelElements/StandardTokenGenerator.cs
@@ -6,33 +6,62 @@
namespace DotNetOAuth.ChannelElements {
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
using System.Security.Cryptography;
+ /// <summary>
+ /// A cryptographically strong random string generator for tokens and secrets.
+ /// </summary>
internal class StandardTokenGenerator : ITokenGenerator {
- RandomNumberGenerator cryptoProvider = new RNGCryptoServiceProvider();
+ /// <summary>
+ /// The cryptographically strong random string generator for tokens and secrets.
+ /// </summary>
+ private RandomNumberGenerator cryptoProvider = new RNGCryptoServiceProvider();
#region ITokenGenerator Members
+ /// <summary>
+ /// Generates a new token to represent a not-yet-authorized request to access protected resources.
+ /// </summary>
+ /// <param name="consumerKey">The consumer that requested this token.</param>
+ /// <returns>The newly generated token.</returns>
+ /// <remarks>
+ /// This method should not store the newly generated token in any persistent store.
+ /// This will be done in <see cref="ITokenManager.StoreNewRequestToken"/>.
+ /// </remarks>
public string GenerateRequestToken(string consumerKey) {
- return GenerateCryptographicallyStrongString();
+ return this.GenerateCryptographicallyStrongString();
}
+ /// <summary>
+ /// Generates a new token to represent an authorized request to access protected resources.
+ /// </summary>
+ /// <param name="consumerKey">The consumer that requested this token.</param>
+ /// <returns>The newly generated token.</returns>
+ /// <remarks>
+ /// This method should not store the newly generated token in any persistent store.
+ /// This will be done in <see cref="ITokenManager.ExpireRequestTokenAndStoreNewAccessToken"/>.
+ /// </remarks>
public string GenerateAccessToken(string consumerKey) {
- return GenerateCryptographicallyStrongString();
+ return this.GenerateCryptographicallyStrongString();
}
+ /// <summary>
+ /// Returns a cryptographically strong random string for use as a token secret.
+ /// </summary>
+ /// <returns>The generated string.</returns>
public string GenerateSecret() {
- return GenerateCryptographicallyStrongString();
+ return this.GenerateCryptographicallyStrongString();
}
#endregion
+ /// <summary>
+ /// Returns a new random string.
+ /// </summary>
+ /// <returns>The new random string.</returns>
private string GenerateCryptographicallyStrongString() {
byte[] buffer = new byte[20];
- cryptoProvider.GetBytes(buffer);
+ this.cryptoProvider.GetBytes(buffer);
return Convert.ToBase64String(buffer);
}
}