Okay, I've extended Rhino.Licensing to allow locking against a
machine. The license element now has an attribute named machine. To
support this, I've added the following overload to LicenseGenerator,
preserving the previous functionality (the test for which remains):
public string Generate(string name, Guid id, DateTime
expirationDate, string machineKey, LicenseType licenseType)
This allows a machine key to be specified in the license. The
intended usage is to issue a license immediately after purchase and
then issue another after activation, where activation sends
information about the machine on which the application is running. I
have added LicenseType.PendingActivation to indicate the state where
the user has purchased but not yet activated.
LicenseValidator is extended to read the machine key and has the
following new property for the machine key:
public string Machine { get; private set; }
Finally there is a new test in Can_generate_and_validate_key that
corresponds to the previous Gen_and_validate with simple extension for
the new machine feature:
[Fact]
public void Gen_and_validate_with_machine()
{
var guid = Guid.NewGuid();
var generator = new LicenseGenerator(public_and_private);
var expiration = DateTime.Now.AddDays(30);
var machine = Guid.NewGuid().ToString();
var key = generator.Generate("Oren Eini", guid, expiration,
machine, LicenseType.PendingActivation);
var path = Path.GetTempFileName();
File.WriteAllText(path, key);
var validator = new LicenseValidator(public_only, path);
validator.AssertValidLicense();
Assert.Equal(guid, validator.UserId);
Assert.Equal(expiration, validator.ExpirationDate);
Assert.Equal("Oren Eini", validator.Name);
Assert.Equal(machine, validator.Machine);
Assert.Equal(LicenseType.PendingActivation,
validator.LicenseType);
}
Changed files here:
http://groups.google.com/group/rhino-tools-dev/web/Rhino.Licensing%20with%20machine%20locking.zip?hl=all
SVN patch here:
http://groups.google.com/group/rhino-tools-dev/web/rhino%20licensing%20machine%20locking.patch?hl=all
Hope this is useful!
Sean