Table of Contents

Class AccessKeyOptions

Namespace
Codebelt.SharedKernel.Security
Assembly
Codebelt.SharedKernel.dll

Provides options to be used with AccessKey>.

public class AccessKeyOptions : IValidatableParameterObject, IParameterObject
Inheritance
object
AccessKeyOptions
Implements

Examples

The following example constructs an AccessKeyOptions instance with a custom DesiredTolerance and a bounded validity window, then validates the configuration before it is consumed by an AccessKey constructor. Use AccessKeyOptions whenever the default CoordinatedUniversalTime.MinValue / MaxValue / 30-second tolerance is not appropriate for the issuing system.

using System;
using Codebelt.SharedKernel;
using Codebelt.SharedKernel.Security;

namespace KeyIssuanceSample;

public static class OptionsFactory
{
    public static AccessKeyOptions CreateHourlyOptions()
    {
        var now = DateTime.UtcNow;
        return new AccessKeyOptions
        {
            ValidFrom = new CoordinatedUniversalTime(now),
            Expires = new CoordinatedUniversalTime(now.AddHours(1)),
            DesiredTolerance = TimeSpan.FromMinutes(1)
        };
    }
}

Constructors

AccessKeyOptions()

Initializes a new instance of the AccessKeyOptions class.

public AccessKeyOptions()

Properties

DesiredTolerance

Gets or sets the desired tolerance for potential clock skew variations. Default is 30 seconds.

public ClockSkew DesiredTolerance { get; set; }

Property Value

ClockSkew

The desired tolerance for potential clock skew variations.

Expires

Gets or sets the expiry date and time of the access key. Default is MaxValue (e.g., no expiration).

public CoordinatedUniversalTime Expires { get; set; }

Property Value

CoordinatedUniversalTime

The expiry date and time of the access key.

ValidFrom

Gets or sets the date and time from which the access key is valid. Default is MinValue (e.g., always valid).

public CoordinatedUniversalTime ValidFrom { get; set; }

Property Value

CoordinatedUniversalTime

The date and time from which the access key is valid.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

InvalidOperationException

ValidFrom is null -or- Expires is null -or- DesiredTolerance is null -or- ValidFrom is greater than Expires.

See Also