Remove SecurityToken internal class

This commit is contained in:
Hao Kung 2015-06-08 10:55:52 -07:00
parent a759bc5529
commit 6d206250b3
3 changed files with 7 additions and 22 deletions

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Identity.EntityFramework
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {
// TODO: Temporary change. // TODO: Temporary change.
// Can be reverted once https://github.com/aspnet/EntityFramework/issues/1960 is closed // Can be reverted once https://github.com/aspnet/EntityFramework/issues/2175 is closed
builder.ForSqlServer().UseIdentity(); builder.ForSqlServer().UseIdentity();
builder.Entity<TUser>(b => builder.Entity<TUser>(b =>

View File

@ -9,21 +9,6 @@ using System.Text;
namespace Microsoft.AspNet.Identity namespace Microsoft.AspNet.Identity
{ {
internal sealed class SecurityToken
{
private readonly byte[] _data;
public SecurityToken(byte[] data)
{
_data = (byte[])data.Clone();
}
internal byte[] GetDataNoClone()
{
return _data;
}
}
internal static class Rfc6238AuthenticationService internal static class Rfc6238AuthenticationService
{ {
private static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); private static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
@ -72,7 +57,7 @@ namespace Microsoft.AspNet.Identity
return (ulong)(delta.Ticks / _timestep.Ticks); return (ulong)(delta.Ticks / _timestep.Ticks);
} }
public static int GenerateCode(SecurityToken securityToken, string modifier = null) public static int GenerateCode(byte[] securityToken, string modifier = null)
{ {
if (securityToken == null) if (securityToken == null)
{ {
@ -81,13 +66,13 @@ namespace Microsoft.AspNet.Identity
// Allow a variance of no greater than 90 seconds in either direction // Allow a variance of no greater than 90 seconds in either direction
var currentTimeStep = GetCurrentTimeStepNumber(); var currentTimeStep = GetCurrentTimeStepNumber();
using (var hashAlgorithm = new HMACSHA1(securityToken.GetDataNoClone())) using (var hashAlgorithm = new HMACSHA1(securityToken))
{ {
return ComputeTotp(hashAlgorithm, currentTimeStep, modifier); return ComputeTotp(hashAlgorithm, currentTimeStep, modifier);
} }
} }
public static bool ValidateCode(SecurityToken securityToken, int code, string modifier = null) public static bool ValidateCode(byte[] securityToken, int code, string modifier = null)
{ {
if (securityToken == null) if (securityToken == null)
{ {
@ -96,7 +81,7 @@ namespace Microsoft.AspNet.Identity
// Allow a variance of no greater than 90 seconds in either direction // Allow a variance of no greater than 90 seconds in either direction
var currentTimeStep = GetCurrentTimeStepNumber(); var currentTimeStep = GetCurrentTimeStepNumber();
using (var hashAlgorithm = new HMACSHA1(securityToken.GetDataNoClone())) using (var hashAlgorithm = new HMACSHA1(securityToken))
{ {
for (var i = -2; i <= 2; i++) for (var i = -2; i <= 2; i++)
{ {

View File

@ -1505,9 +1505,9 @@ namespace Microsoft.AspNet.Identity
} }
// Two factor APIS // Two factor APIS
internal async Task<SecurityToken> CreateSecurityTokenAsync(TUser user) internal async Task<byte[]> CreateSecurityTokenAsync(TUser user)
{ {
return new SecurityToken(Encoding.Unicode.GetBytes(await GetSecurityStampAsync(user))); return Encoding.Unicode.GetBytes(await GetSecurityStampAsync(user));
} }
/// <summary> /// <summary>