Esempio n. 1
0
        /// <inheritdoc/>
        public IObjectSigner Build(Action <ObjectSignerBuilder> configurator = null)
        {
            var builder = new ObjectSignerBuilder();

            configurator?.Invoke(builder);

            return(new ObjectSigner(builder));
        }
 /// <summary>
 /// Setup a delegate to convert an object to a string
 /// </summary>
 /// <param name="source"><see cref="ObjectSignerBuilder"/> instance that the operation is applied to</param>
 /// <param name="objectToStringSerialiser">Delegate to serialise an object into a string</param>
 /// <returns></returns>
 public static ObjectSignerBuilder WithStringBasedSerialiser(this ObjectSignerBuilder source, Func <object, string> objectToStringSerialiser)
 {
     source.WithBinarySerialiser(input => Encoding.UTF8.GetBytes(objectToStringSerialiser(input)));
     return(source);
 }
 /// <summary>
 /// Use the HMACSHA512 ComputeHash method for signature generation
 /// </summary>
 /// <param name="source"><see cref="ObjectSignerBuilder"/> instance that the operation is applied to</param>
 /// <param name="secret">Secret key for the HMAC instance to use</param>
 /// <returns><see cref="ObjectSignerBuilder"/> instance to fluently build with</returns>
 public static ObjectSignerBuilder WithHmac512SignatureProvider(this ObjectSignerBuilder source, byte[] secret)
 {
     return(AddDisposableSignatureProvider(source, new HMACSHA512(secret)));
 }
 private static ObjectSignerBuilder AddDisposableSignatureProvider(ObjectSignerBuilder source, HashAlgorithm algorithm)
 {
     return(source
            .WithSignatureProvider(algorithm.ComputeHash)
            .OnDispose(() => algorithm.Dispose()));
 }
Esempio n. 5
0
 public ObjectSigner(ObjectSignerBuilder builder)
 {
     _builder = builder;
 }