ISecurityUtility

Namespace: ASPSecurityKit
Assembly: ASPSecurityKit.dll

Summary

Defines utility methods required by security operations.

Methods

OpResultToStatusCode(result)

Summary

Gets an HTTP status code representing the specified operation result. Multiple results can be represented by the same HTTP status code as the former represents a precise reason of failure (“why”) while the latter represents the outcome (“what”).

Returns

The HTTP status code representing the specified operation result.

Parameters
Name Type Description
result ASPSecurityKit.OpResult The operation result.
Remarks

The implementations should expose a public mapper dictionary and use that to perform mapping as the default one does using OpResultToHttpStatusCodeMapper. This way consuming applications can extend/override the mappings as per requirements.

NewSecret()

Summary

Creates a random secret.

Returns

The random secret.

Parameters

This method has no parameters.

FromUnixTime(elapsedSeconds)

Summary

Gets the DateTime value representing the specified Unix time. A Unix time is expressed in seconds elapsed since 1970-01-01 12:00:00 AM.

Returns

The DateTime value representing the specified Unix time.

Parameters
Name Type Description
elapsedSeconds System.String A Unix time value expressed in seconds elapsed since 1970-01-01 12:00:00 AM.
Exceptions
Type Description
System.ArgumentNullException When elapsedSeconds is null or whitespace.
System.FormatException When elapsedSeconds is not a valid integer.

IsSlidRecently(expiration,slideByMinutes,updateIntervalInMinutes)

Summary

Determines whether the specified expiration time was slid recently.

Returns

true if the specified expiration time was slid recently; otherwise, false.

Parameters
Name Type Description
expiration System.Nullable{System.DateTime} The expiration time.
slideByMinutes System.Int32 The time in minutes the expiration is set to slide by.
updateIntervalInMinutes System.Int32 The time in minutes after which the expiration time should be slid. The default is one (1 minute).

IsValidHost(host,pattern)

Summary

Determines whether the given host is valid for the specified pattern.

Returns

true if the given host is valid for the specified pattern; otherwise, false.

Parameters
Name Type Description
host System.String The host.
pattern System.String The pattern.
Exceptions
Type Description
System.ArgumentNullException When host or pattern is null or whitespace.