All Projects → junian → Standard.licensing

junian / Standard.licensing

Licence: mit
Easy-to-use licensing library for .NET Framework, Mono, .NET Core, and Xamarin products

Projects that are alternatives of or similar to Standard.licensing

Megaapiclient
MegaApiClient is a C# .Net library to access http://mega.co.nz / http://mega.nz cloud storage and file hosting service.
Stars: ✭ 151 (-36.82%)
Mutual labels:  netstandard, xamarin, netcore, mono
Portable-WebDAV-Library
Moved to codeberg.org - https://codeberg.org/DecaTec/Portable-WebDAV-Library - The Portable WebDAV Library is a strongly typed, async WebDAV client library which is fully compliant to RFC 4918, RFC 4331 and "Additional WebDAV Collection Properties". It is implemented as .NETStandard 1.1 library in oder to be used on any platform supporting .NETS…
Stars: ✭ 45 (-81.17%)
Mutual labels:  xamarin, mono, netcore, netstandard
PCLExt.FileStorage
Portable Storage APIs
Stars: ✭ 35 (-85.36%)
Mutual labels:  xamarin, mono, netstandard
Dryioc
DryIoc is fast, small, full-featured IoC Container for .NET
Stars: ✭ 555 (+132.22%)
Mutual labels:  netstandard, xamarin, netcore
Zipstorer
A Pure C# Class to Store Files in Zip
Stars: ✭ 139 (-41.84%)
Mutual labels:  netstandard, netcore, mono
Couchdb Net
EF Core-like CouchDB experience for .NET!
Stars: ✭ 50 (-79.08%)
Mutual labels:  netstandard, xamarin, netcore
Dbreeze
C# .NET MONO NOSQL ( key value store embedded ) ACID multi-paradigm database management system.
Stars: ✭ 383 (+60.25%)
Mutual labels:  netstandard, xamarin, netcore
Nlog
NLog - Advanced and Structured Logging for Various .NET Platforms
Stars: ✭ 5,296 (+2115.9%)
Mutual labels:  netstandard, xamarin, netcore
Csla
A home for your business logic in any .NET application.
Stars: ✭ 865 (+261.92%)
Mutual labels:  netstandard, xamarin, mono
Nlua
Bridge between Lua and the .NET.
Stars: ✭ 1,326 (+454.81%)
Mutual labels:  netstandard, xamarin, netcore
Activelogin.authentication
Support Swedish BankID (svenskt BankID) authentication in .NET.
Stars: ✭ 141 (-41%)
Mutual labels:  netstandard, netcore
Mvvmvalidation
Lightweight library that helps reduce boilerplate when implementing validation in XAML MVVM applications
Stars: ✭ 141 (-41%)
Mutual labels:  netstandard, xamarin
Opentouryo
”Open棟梁”は、長年の.NETアプリケーション開発実績にて蓄積したノウハウに基づき開発した.NET用アプリケーション フレームワークです。 (”OpenTouryo” , is an application framework for .NET which was developed using the accumulated know-how with a long track record in .NET application development.)
Stars: ✭ 233 (-2.51%)
Mutual labels:  netstandard, netcore
Azos
A to Z Sky Operating System / Microservice Chassis Framework
Stars: ✭ 137 (-42.68%)
Mutual labels:  netstandard, netcore
Keralua
C# Native bindings of Lua 5.4 (compatible with iOS/Mac/Android/.NET/.NET Core/UWP)
Stars: ✭ 147 (-38.49%)
Mutual labels:  xamarin, netcore
Managed Midi
[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).
Stars: ✭ 130 (-45.61%)
Mutual labels:  xamarin, mono
Mmalsharp
C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera.
Stars: ✭ 152 (-36.4%)
Mutual labels:  netcore, mono
Oss.core
.net core下的领域开源电商网站,类库使用的标准库项目,集成微信和支付宝。 暂时还在开发阶段
Stars: ✭ 128 (-46.44%)
Mutual labels:  netstandard, netcore
Fluentdispatch
🌊 .NET Standard 2.1 framework which makes easy to scaffold distributed systems and dispatch incoming load into units of work in a deterministic way.
Stars: ✭ 152 (-36.4%)
Mutual labels:  netstandard, netcore
Ffmediatoolkit
FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
Stars: ✭ 156 (-34.73%)
Mutual labels:  netstandard, netcore

NuGet NuGet Build status

Buy Me A Coffee

About

Easy-to-use licensing library for .NET Framework, Mono, .NET Core, and Xamarin products.

This is project is derived from Portable.Licensing library. The purpose of this fork is to add support for more .NET platforms, especially .NET Standard and .NET Core.

There is also a plan to decouple from Bouncy Castle library and use System.Security.Cryptography.Cng for modern .NET platforms.

Installation

Get Standard.Licensing from NuGet.

PM> Install-Package Standard.Licensing

Usage

Create a private and public key for your product

Standard.Licensing uses the Elliptic Curve Digital Signature Algorithm (ECDSA) to ensure the license cannot be altered after creation.

First you need to create a new public/private key pair for your product:

var keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create(); 
var keyPair = keyGenerator.GenerateKeyPair(); 
var privateKey = keyPair.ToEncryptedPrivateKeyString(passPhrase);  
var publicKey = keyPair.ToPublicKeyString();

Store the private key securely and distribute the public key with your product. Normally you create one key pair for each product, otherwise it is possible to use a license with all products using the same key pair. If you want your customer to buy a new license on each major release you can create a key pair for each release and product.

Create the license generator

Now we need something to generate licenses. This could be easily done with the LicenseFactory:

var license = License.New()  
    .WithUniqueIdentifier(Guid.NewGuid())  
    .As(LicenseType.Trial)  
    .ExpiresAt(DateTime.Now.AddDays(30))  
    .WithMaximumUtilization(5)  
    .WithProductFeatures(new Dictionary<string, string>  
        {  
            {"Sales Module", "yes"},  
            {"Purchase Module", "yes"},  
            {"Maximum Transactions", "10000"}  
        })  
    .LicensedTo("John Doe", "[email protected]")  
    .CreateAndSignWithPrivateKey(privateKey, passPhrase);

Now you can take the license and save it to a file:

File.WriteAllText("License.lic", license.ToString(), Encoding.UTF8);

or

license.Save(xmlWriter);

Validate the license in your application

The easiest way to assert the license is in the entry point of your application.

First load the license from a file or resource:

var license = License.Load(...);

Then you can assert the license:

using Standard.Licensing.Validation;

var validationFailures = license.Validate()  
                                .ExpirationDate()  
                                .When(lic => lic.Type == LicenseType.Trial)  
                                .And()  
                                .Signature(publicKey)  
                                .AssertValidLicense();

Standard.Licensing will not throw any Exception and just return an enumeration of validation failures.

Now you can iterate over possible validation failures:

foreach (var failure in validationFailures)
     Console.WriteLine(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);

Or simply check if there is any failure:

if (validationFailures.Any())
   // ...

Make sure to call validationFailures.ToList() or validationFailures.ToArray() before using the result multiple times.

Credits

License

This project is licensed under MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].