Use of Rhino.Licensing

261 views
Skip to first unread message

Sean Kearon

unread,
Sep 16, 2009, 5:02:21 PM9/16/09
to Rhino Tools Dev
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?
~ 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).

Thanks

Sean

Ayende Rahien

unread,
Sep 16, 2009, 5:12:21 PM9/16/09
to rhino-t...@googlegroups.com
inline

On Thu, Sep 17, 2009 at 12:02 AM, Sean Kearon <kearo...@googlemail.com> 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.

Sean Kearon

unread,
Sep 16, 2009, 5:30:10 PM9/16/09
to Rhino Tools Dev
Thanks Ayende.

Sean

On 16 Sep, 22:12, Ayende Rahien <aye...@ayende.com> wrote:
> inline
>

Sean Kearon

unread,
Sep 17, 2009, 6:47:27 PM9/17/09
to Rhino Tools Dev
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

Ayende Rahien

unread,
Oct 21, 2009, 10:58:52 AM10/21/09
to rhino-t...@googlegroups.com
Can you send me a patch against the git version?
Reply all
Reply to author
Forward
0 new messages