Class StringExtensions
- Namespace
- Cuemon.Extensions.Net.Security
- Assembly
- Cuemon.Extensions.Net.dll
Extension methods for the String class.
public static class StringExtensions
- Inheritance
-
StringExtensions
Methods
ToSignedUri(String, Byte[], Nullable<DateTime>, Nullable<DateTime>, Action<SignedUriOptions>)
Converts the specified uriString
to a signed and tampering protected Uri.
public static Uri ToSignedUri(this string uriString, byte[] secret, DateTime? start = null, DateTime? expiry = null, Action<SignedUriOptions> setup = null)
Parameters
uriString
StringThe 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
Remarks
If either of start
or expiry
has a Kind different from Utc, they will be adjusted without changing the value of the DateTime itself.
Exceptions
- ArgumentNullException
uriString
cannot be null - or -secret
cannot be null.- 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
StringThe 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
- SecurityException
signedUriString
has an invalid signature.
- See Also