summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId/Association.cs')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Association.cs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Association.cs b/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
index a0f5bae..502afb3 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
@@ -8,12 +8,12 @@ namespace DotNetOpenAuth.OpenId {
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using DotNetOpenAuth.Configuration;
using DotNetOpenAuth.Messaging;
+ using Validation;
/// <summary>
/// Stores a secret used in signing and verifying messages.
@@ -24,8 +24,6 @@ namespace DotNetOpenAuth.OpenId {
/// (dumb associations).
/// </remarks>
[DebuggerDisplay("Handle = {Handle}, Expires = {Expires}")]
- [ContractVerification(true)]
- [ContractClass(typeof(AssociationContract))]
public abstract class Association {
/// <summary>
/// Initializes a new instance of the <see cref="Association"/> class.
@@ -37,10 +35,9 @@ namespace DotNetOpenAuth.OpenId {
protected Association(string handle, byte[] secret, TimeSpan totalLifeLength, DateTime issued) {
Requires.NotNullOrEmpty(handle, "handle");
Requires.NotNull(secret, "secret");
- Requires.InRange(totalLifeLength > TimeSpan.Zero, "totalLifeLength");
- Requires.True(issued.Kind == DateTimeKind.Utc, "issued");
- Requires.InRange(issued <= DateTime.UtcNow, "issued");
- Contract.Ensures(this.TotalLifeLength == totalLifeLength);
+ Requires.Range(totalLifeLength > TimeSpan.Zero, "totalLifeLength");
+ Requires.That(issued.Kind == DateTimeKind.Utc, "issued", "UTC time required.");
+ Requires.Range(issued <= DateTime.UtcNow, "issued");
this.Handle = handle;
this.SecretKey = secret;
@@ -93,7 +90,6 @@ namespace DotNetOpenAuth.OpenId {
/// </summary>
protected internal static TimeSpan DumbSecretLifetime {
get {
- Contract.Ensures(Contract.Result<TimeSpan>() > TimeSpan.Zero);
return OpenIdElement.Configuration.MaxAuthenticationTime;
}
}
@@ -104,7 +100,6 @@ namespace DotNetOpenAuth.OpenId {
/// </summary>
protected internal long SecondsTillExpiration {
get {
- Contract.Ensures(Contract.Result<long>() >= 0);
return Math.Max(0, (long)this.TimeTillExpiration.TotalSeconds);
}
}
@@ -130,7 +125,6 @@ namespace DotNetOpenAuth.OpenId {
/// </remarks>
private static TimeSpan MinimumUsefulAssociationLifetime {
get {
- Contract.Ensures(Contract.Result<TimeSpan>() > TimeSpan.Zero);
return OpenIdElement.Configuration.MaxAuthenticationTime;
}
}
@@ -164,7 +158,6 @@ namespace DotNetOpenAuth.OpenId {
public static Association Deserialize(string handle, DateTime expiresUtc, byte[] privateData) {
Requires.NotNullOrEmpty(handle, "handle");
Requires.NotNull(privateData, "privateData");
- Contract.Ensures(Contract.Result<Association>() != null);
expiresUtc = expiresUtc.ToUniversalTimeSafe();
TimeSpan remainingLifeLength = expiresUtc - DateTime.UtcNow;
@@ -191,8 +184,6 @@ namespace DotNetOpenAuth.OpenId {
/// in this byte array, as they are useful for fast database lookup and are persisted separately.
/// </remarks>
public byte[] SerializePrivateData() {
- Contract.Ensures(Contract.Result<byte[]>() != null);
-
// We may want to encrypt this secret using the machine.config private key,
// and add data regarding which Association derivative will need to be
// re-instantiated on deserialization.