Table of Contents

Class StringExtensions

Namespace
Cuemon.Extensions.Net.Security
Assembly
Cuemon.Extensions.Net.dll

Extension methods for the System.String class.

public static class StringExtensions
Inheritance
Object
StringExtensions

Methods

ToSignedUri(String, Byte[], Nullable<DateTime>, Nullable<DateTime>, Action<SignedUriOptions>)

Converts the specified uriString to a signed and tampering protected System.Uri.

public static Uri ToSignedUri(this string uriString, byte[] secret, DateTime? start = null, DateTime? expiry = null, Action<SignedUriOptions> setup = null)

Parameters

uriString String

The URI to protect from tampering.

secret Byte[]

The secret key for the encryption.

start Nullable<DateTime>

The time, expressed as the Coordinated Universal Time (UTC), at which the signed URI becomes valid.

expiry Nullable<DateTime>

The time, expressed as the Coordinated Universal Time (UTC), at which the signed URI becomes invalid.

setup Action<SignedUriOptions>

The SignedUriOptions which may be configured.

Returns

Uri

A System.Uri that is equivalent to uriString but signed and protected from tampering.

Remarks

If either of start or expiry has a System.DateTime.Kind different from System.DateTimeKind.Utc, they will be adjusted without changing the value of the System.DateTime itself.

Exceptions

System.ArgumentNullException

uriString cannot be null - or - secret cannot be null.

System.ArgumentException

uriString cannot be empty or consist only of white-space characters.

See Also

ValidateSignedUri(String, Byte[], Action<SignedUriOptions>)

Reads and validates the specified signedUriString.

public static void ValidateSignedUri(this string signedUriString, byte[] secret, Action<SignedUriOptions> setup = null)

Parameters

signedUriString String

The signed URI that needs to be validated.

secret Byte[]

The secret key for the encryption.

setup Action<SignedUriOptions>

The SignedUriOptions which may be configured.

Exceptions

System.Security.SecurityException

signedUriString has an invalid signature.

See Also