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
On Sep 16, 10:30 pm, Sean Kearon <[email protected]> wrote:
> Thanks Ayende.
>
> Sean
>
> On 16 Sep, 22:12, Ayende Rahien <[email protected]> wrote:
>
>
>
> > inline
>
> > On Thu, Sep 17, 2009 at 12:02 AM, Sean Kearon
> > <[email protected]>wrote:
>
> > > After much pain with commercial licensing tools, I'm looking at
> > > Rhino.Licensing and have a couple of questions:
>
> > > ~ What do I have to do to use the code as part of my commercial
> > > project - acks etc?
>
> > Attribution in the documentation would be nice, but is not required.
>
> > > ~ If I customise the code then should I share my customisations and,
> > > if so, how is best to do this? (I want to add the ability to lock to a
> > > machine).
>
> > Make the modifications, post a patch here, if this is good, I'll commit it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---