
//============================================================================================================
// Microsoft Updater Application Block for .NET
//  http://msdn.microsoft.com/library/en-us/dnbda/html/updater.asp
//	
// IValidator.cs
//
// Interface to define validator contract.
// 
// For more information see the Updater Application Block Implementation Overview. 
// 
//============================================================================================================
// Copyright (C) 2000-2001 Microsoft Corporation
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//============================================================================================================


using System;
using System.Xml;

namespace Microsoft.ApplicationBlocks.ApplicationUpdater.Interfaces

{
	/// <summary>
	/// The interface used to extend the validation support after downloading a file.
	/// </summary>
	public interface IValidator : IDisposable  //mstuart--added IDisposable since Validator will most likely be working w/files
	{
		/// <summary>
		/// Initialization method
		/// </summary>
		void Init( XmlNode config );

		/// <summary>
		/// Validate the file specified
		/// </summary>
		bool Validate( string filePath, string signature );

		/// <summary>
		/// Validate the given xml node
		/// </summary>
		/// <param name="xml">the xml to validate</param>
		/// <param name="signature">the keyed-hash signature to validate agains</param>
		/// <returns>true if xml node, hashed with our key, matches the signature</returns>
		bool Validate( XmlNode xml, string signature );

		/// <summary>
		/// Sign the given file by hashing the file with the given key, returning a byte array containing the hash signature
		/// </summary>
		/// <param name="filePath">full or relative path to file to sign</param>
		/// <param name="key">the byte array key used to sign the hash</param>
		/// <returns>a signed hash value for the whole file</returns>
		string Sign( string filePath, string key );

		/// <summary>
		/// Overload allows keyed-hashing of arbitrary xml node
		/// </summary>
		/// <param name="xml">the XmlNode containing contents to key-hash</param>
		/// <param name="key">the hashing key</param>
		/// <returns>a byte array containing the keyed hash</returns>
		string Sign( XmlNode xml, string key );

	}
}
