Skip to content

Commit

Permalink
Set working dir to build.json file in Assembly Signer + Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
artemlos committed Oct 19, 2019
1 parent 184a409 commit 846b8e0
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 80 deletions.
2 changes: 2 additions & 0 deletions AssemblySigner/Program.cs
Expand Up @@ -99,6 +99,8 @@ static void Main(string[] args)
}
}

Directory.SetCurrentDirectory(Path.GetDirectoryName(pathToUserConfig));

foreach (var path in userConfig.Assemblies)
{
if(string.IsNullOrEmpty(path) || !File.Exists(path))
Expand Down
4 changes: 2 additions & 2 deletions AssemblySignerGUI/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
224 changes: 224 additions & 0 deletions Example/AssemblySigner/AssemblySigner.deps.json
@@ -0,0 +1,224 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.0",
"signature": "a9217a852f63b47f3759454186b45adc0895d176"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.0": {
"AssemblySigner/1.0.0": {
"dependencies": {
"Cryptolens.Licensing": "4.0.21"
},
"runtime": {
"AssemblySigner.dll": {}
}
},
"Cryptolens.Licensing/4.0.21": {
"dependencies": {
"Newtonsoft.Json": "11.0.2",
"System.Management": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/Cryptolens.Licensing.dll": {
"assemblyVersion": "4.0.21.1",
"fileVersion": "4.0.21.1"
}
}
},
"Microsoft.Win32.Registry/4.5.0": {
"dependencies": {
"System.Memory": "4.5.0",
"System.Security.AccessControl": "4.5.0",
"System.Security.Principal.Windows": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Win32.Registry.dll": {
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/unix/lib/netstandard2.0/Microsoft.Win32.Registry.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
},
"runtimes/win/lib/netstandard2.0/Microsoft.Win32.Registry.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
}
},
"Newtonsoft.Json/11.0.2": {
"runtime": {
"lib/netstandard2.0/Newtonsoft.Json.dll": {
"assemblyVersion": "11.0.0.0",
"fileVersion": "11.0.2.21924"
}
}
},
"System.CodeDom/4.5.0": {
"runtime": {
"lib/netstandard2.0/System.CodeDom.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.6.26515.6"
}
}
},
"System.Management/4.5.0": {
"dependencies": {
"Microsoft.Win32.Registry": "4.5.0",
"System.CodeDom": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/System.Management.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp2.0/System.Management.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
}
},
"System.Memory/4.5.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/System.Memory.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.6.26515.6"
}
}
},
"System.Runtime.CompilerServices.Unsafe/4.5.0": {
"runtime": {
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll": {
"assemblyVersion": "4.0.4.0",
"fileVersion": "0.0.0.0"
}
}
},
"System.Security.AccessControl/4.5.0": {
"dependencies": {
"System.Security.Principal.Windows": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/System.Security.AccessControl.dll": {
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp2.0/System.Security.AccessControl.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
}
},
"System.Security.Principal.Windows/4.5.0": {
"runtime": {
"lib/netstandard2.0/System.Security.Principal.Windows.dll": {
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp2.0/System.Security.Principal.Windows.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
},
"runtimes/win/lib/netcoreapp2.0/System.Security.Principal.Windows.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.1.1.0",
"fileVersion": "4.6.26515.6"
}
}
}
}
},
"libraries": {
"AssemblySigner/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Cryptolens.Licensing/4.0.21": {
"type": "package",
"serviceable": true,
"sha512": "sha512-CfL7Mrk1HHhqXl+2Vc2w6jzEcTV9Jz7o70DHJn6Nf9ohGA/E9B2OcHGX1x9dqeJFy6OW6v07OaiW3fMpI5+CIQ==",
"path": "cryptolens.licensing/4.0.21",
"hashPath": "cryptolens.licensing.4.0.21.nupkg.sha512"
},
"Microsoft.Win32.Registry/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-+FWlwd//+Tt56316p00hVePBCouXyEzT86Jb3+AuRotTND0IYn0OO3obs1gnQEs/txEnt+rF2JBGLItTG+Be6A==",
"path": "microsoft.win32.registry/4.5.0",
"hashPath": "microsoft.win32.registry.4.5.0.nupkg.sha512"
},
"Newtonsoft.Json/11.0.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-IvJe1pj7JHEsP8B8J8DwlMEx8UInrs/x+9oVY+oCD13jpLu4JbJU2WCIsMRn5C4yW9+DgkaO8uiVE5VHKjpmdQ==",
"path": "newtonsoft.json/11.0.2",
"hashPath": "newtonsoft.json.11.0.2.nupkg.sha512"
},
"System.CodeDom/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-gqpR1EeXOuzNQWL7rOzmtdIz3CaXVjSQCiaGOs2ivjPwynKSJYm39X81fdlp7WuojZs/Z5t1k5ni7HtKQurhjw==",
"path": "system.codedom/4.5.0",
"hashPath": "system.codedom.4.5.0.nupkg.sha512"
},
"System.Management/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Z6ac0qPGr3yJtwZEX1SRkhwWa0Kf5NJxx7smLboYsGrApQFECNFdqhGy252T4lrZ5Nwzhd9VQiaifndR3bfHdg==",
"path": "system.management/4.5.0",
"hashPath": "system.management.4.5.0.nupkg.sha512"
},
"System.Memory/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-m0psCSpUxTGfvwyO0i03ajXVhgBqyXlibXz0Mo1dtKGjaHrXFLnuQ8rNBTmWRqbfRjr4eC6Wah4X5FfuFDu5og==",
"path": "system.memory/4.5.0",
"hashPath": "system.memory.4.5.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YrzNWduCDHhUaSRBxHxL11UkM2fD6y8hITHis4/LbQZ6vj3vdRjoH3IoPWWC9uDXK2wHIqn+b5gv1Np/VKyM1g==",
"path": "system.runtime.compilerservices.unsafe/4.5.0",
"hashPath": "system.runtime.compilerservices.unsafe.4.5.0.nupkg.sha512"
},
"System.Security.AccessControl/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==",
"path": "system.security.accesscontrol/4.5.0",
"hashPath": "system.security.accesscontrol.4.5.0.nupkg.sha512"
},
"System.Security.Principal.Windows/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-U77HfRXlZlOeIXd//Yoj6Jnk8AXlbeisf1oq1os+hxOGVnuG+lGSfGqTwTZBoORFF6j/0q7HXIl8cqwQ9aUGqQ==",
"path": "system.security.principal.windows/4.5.0",
"hashPath": "system.security.principal.windows.4.5.0.nupkg.sha512"
}
}
}
Binary file added Example/AssemblySigner/AssemblySigner.dll
Binary file not shown.
9 changes: 9 additions & 0 deletions Example/AssemblySigner/AssemblySigner.runtimeconfig.dev.json
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\Artem Los\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\Artem Los\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}
9 changes: 9 additions & 0 deletions Example/AssemblySigner/AssemblySigner.runtimeconfig.json
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp2.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.0.0"
}
}
}
7 changes: 7 additions & 0 deletions Example/AssemblySigner/README.md
@@ -0,0 +1,7 @@
# Instructions

To sign the SoftwareUsingSDK project, please run

```
dotnet AssemblySigner.dll ..\SoftwareUsingSDK\bin\Debug\netcoreapp2.2\build.json
```
5 changes: 5 additions & 0 deletions Example/AssemblySigner/config.json
@@ -0,0 +1,5 @@
{
"ProductId": 5065,
"ActivateToken": "WyIxMDgzMSIsImQwVkJST1AreXAwdUZ4OXlOQnRCT2RLUGhCWU0zaWczaVhFZ2F6RkMiXQ==",
"DataObjectToken" : "WyIxMDg0MyIsIlhjUXUvVE4rMUhaZ1QzeDRQNmdCeTZ4OWJDMld3elc5NnZsbEtLbGQiXQ=="
}
60 changes: 32 additions & 28 deletions SDKExample/MathMethods.cs → Example/SDKExample/MathMethods.cs
Expand Up @@ -8,40 +8,44 @@ public class MathMethods
{
private Dictionary<string, bool> permittedMethods = new Dictionary<string, bool>();

public MathMethods(string licenseKey)
public MathMethods()
{


if (!licenseCheck())
{
// error occurred when verifying the license.
throw new ArgumentException("License verification failed.");
}
}

public bool Status()
private bool licenseCheck()
{
string RSA = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
return SKM.V3.Methods.Helpers.VerifySDKLicenseCertificate(Assembly.GetCallingAssembly(),RSA, null, null);
}

//private bool licenseCheck(string licenseKey)
//{

// // everything went fine if we are here!
// permittedMethods = new Dictionary<string, bool>();
var license = SKM.V3.Methods.Helpers.VerifySDKLicenseCertificate(RSA);

if(license == null)
{
return false;
}

// everything went fine if we are here!
permittedMethods = new Dictionary<string, bool>();

if (license.F5)
{
permittedMethods.Add("Abs", true);
}
if (license.F6)
{
permittedMethods.Add("Factorial", true);
}
if (license.F7)
{
permittedMethods.Add("Fibonacci", true);
}

return true;

// if (result.LicenseKey.F5)
// {
// permittedMethods.Add("Abs", true);
// }
// if (result.LicenseKey.F6)
// {
// permittedMethods.Add("Factorial", true);
// }
// if (result.LicenseKey.F7)
// {
// permittedMethods.Add("Fibonacci", true);
// }



//}
}

/// <summary>
/// Compute the absolute value of a number
Expand Down
11 changes: 11 additions & 0 deletions Example/SDKExample/SDKExample.csproj
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cryptolens.Licensing" Version="4.0.21" />
</ItemGroup>

</Project>

0 comments on commit 846b8e0

Please sign in to comment.