예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Association"/> class.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="secret">The secret.</param>
        /// <param name="totalLifeLength">How long the association will be useful.</param>
        /// <param name="issued">The UTC time of when this association was originally issued by the Provider.</param>
        protected Association(string handle, byte[] secret, TimeSpan totalLifeLength, DateTime issued)
        {
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(handle));
            Contract.Requires <ArgumentNullException>(secret != null);
            Contract.Requires <ArgumentOutOfRangeException>(totalLifeLength > TimeSpan.Zero);
            Contract.Requires <ArgumentException>(issued.Kind == DateTimeKind.Utc);
            Contract.Requires <ArgumentOutOfRangeException>(issued <= DateTime.UtcNow);
            Contract.Ensures(this.TotalLifeLength == totalLifeLength);

            this.Handle          = handle;
            this.SecretKey       = secret;
            this.TotalLifeLength = totalLifeLength;
            this.Issued          = OpenIdUtilities.CutToSecond(issued);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Association"/> class.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="secret">The secret.</param>
        /// <param name="totalLifeLength">How long the association will be useful.</param>
        /// <param name="issued">The UTC time of when this association was originally issued by the Provider.</param>
        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);

            this.Handle          = handle;
            this.SecretKey       = secret;
            this.TotalLifeLength = totalLifeLength;
            this.Issued          = OpenIdUtilities.CutToSecond(issued);
        }