Skip to content

Commit

Permalink
Fixed two bugs. First in the key generation window and the other in t…
Browse files Browse the repository at this point in the history
…he registration client.
  • Loading branch information
Shawn Jackson committed Jul 6, 2012
1 parent 1381adb commit 866ef4c
Show file tree
Hide file tree
Showing 18 changed files with 575 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ private void btnGenerateKeys_Click(object sender, System.Windows.RoutedEventArgs
keysToGenerate = 1; // Can only generate 1 local hardware locked key at a time.
}

licenseGenerationOptions.LicenseSetId = ((LicenseSet) cboLicenseSet.SelectedValue).LicenseSetId;

worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
object[] data = args.Argument as object[];
Expand Down
4 changes: 2 additions & 2 deletions Common/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,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("0.4.1203.3113")] // Rule: *.*.YYMM.DDhh
[assembly: AssemblyFileVersion("0.4.1203.3113")] // Rule: *.*.YYMM.DDhh
[assembly: AssemblyVersion("0.4.1207.0519")] // Rule: *.*.YYMM.DDhh
[assembly: AssemblyFileVersion("0.4.1207.0519")] // Rule: *.*.YYMM.DDhh
28 changes: 18 additions & 10 deletions Core/Services/RegisterService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using WaveTech.Scutex.Model;
using System;
using WaveTech.Scutex.Model;
using WaveTech.Scutex.Model.Interfaces.Services;

namespace WaveTech.Scutex.Services
Expand Down Expand Up @@ -30,17 +31,24 @@ public RegisterResult Register(string licenseKey, LicenseBase scutexLicense, Scu

if (keyData.LicenseKeyType != LicenseKeyTypes.Enterprise && keyData.LicenseKeyType != LicenseKeyTypes.HardwareLockLocal)
{
if (keyData.LicenseKeyType == LicenseKeyTypes.HardwareLock)
cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, _hardwareFingerprintService.GetHardwareFingerprint(FingerprintTypes.Default));
else
cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, null);

if (cl.IsLicensed && cl.IsActivated)
try
{
registerResult.Result = ProcessCodes.ActivationSuccess;
registerResult.ClientLicense = cl;
if (keyData.LicenseKeyType == LicenseKeyTypes.HardwareLock)
cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, _hardwareFingerprintService.GetHardwareFingerprint(FingerprintTypes.Default));
else
cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, null);

if (cl.IsLicensed && cl.IsActivated)
{
registerResult.Result = ProcessCodes.ActivationSuccess;
registerResult.ClientLicense = cl;
}
else
{
registerResult.Result = ProcessCodes.ActivationFailed;
}
}
else
catch
{
registerResult.Result = ProcessCodes.ActivationFailed;
}
Expand Down
12 changes: 12 additions & 0 deletions Generators/LargeStaticKeyGenerator/KeyGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
Expand Down Expand Up @@ -259,16 +260,27 @@ public bool ValidateLicenseKey(string licenseKey, LicenseBase scutexLicense)
var licSetPH = placeholerLocations.Where(x => x.Value.ValidationType == ValidationTypes.LicenseSet).SingleOrDefault();
int licenseSetIdValue1 = int.Parse(decodedLicenseKey.Substring(licSetPH.Key, licSetPH.Value.Length));

Debug.WriteLine(string.Format("Decoded Key: {0}", decodedLicenseKey));
Debug.WriteLine(string.Format("LicenseSet Placeholder: {0}", licSetPH));
Debug.WriteLine(string.Format("LicenseSet Placeholder Key: {0}", licSetPH.Key));
Debug.WriteLine(string.Format("LicenseSet Placeholder Length: {0}", licSetPH.Value.Length));
Debug.WriteLine(string.Format("LicenseSetId Value: {0}", licenseSetIdValue1));
Debug.WriteLine(string.Format("LicenseSets: {0}", scutexLicense.LicenseSets.First().LicenseSetId));

ls = scutexLicense.LicenseSets.Where(x => x.LicenseSetId == licenseSetIdValue1).SingleOrDefault();
}
catch
{
throw new ScutexLicenseException(Resources.ErrorMsg_VerifyLicenseKey);
}

Debug.WriteLine(string.Format("LicenseSet: {0}", ls));

if (ls == null)
throw new ScutexLicenseException(Resources.ErrorMsg_VerifyLicenseKey);

Debug.WriteLine(string.Format("LicenseSet Types: {0}", ls.SupportedLicenseTypes));

// If the LicenseSet does not support the key type supplied then throw an error
if (!ls.SupportedLicenseTypes.IsSet(typeFlag))
throw new ScutexLicenseException(Resources.ErrorMsg_VerifyLicenseKey);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
8 changes: 8 additions & 0 deletions Samples/CSharp/Scutex.Samples.CSharp.WpfApplication/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="Scutex.Samples.CSharp.WpfApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions Samples/CSharp/Scutex.Samples.CSharp.WpfApplication/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Scutex.Samples.CSharp.WpfApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Window x:Class="Scutex.Samples.CSharp.WpfApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>

</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WaveTech.Scutex.Licensing;
using WaveTech.Scutex.Model;

namespace Scutex.Samples.CSharp.WpfApplication
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

LicensingManager licensingManager = new LicensingManager(null);
ScutexLicense license = licensingManager.Validate(InteractionModes.Gui);


bool wasPressed = license.InterfaceInteraction.TryButtonClicked;
Console.WriteLine(Guid.NewGuid().ToString());
Console.WriteLine("Test Product");
Console.WriteLine();

Console.WriteLine(String.Format("Is Product Licensed: {0}", license.IsLicensed));
Console.WriteLine(String.Format("Is Trial Valid: {0}", license.IsTrialValid));
Console.WriteLine(String.Format("Is Trial Expired: {0}", license.IsTrialExpired));
Console.WriteLine(String.Format("Is Trial Fault Reason: {0}", license.TrialFaultReason));
Console.WriteLine(String.Format("Is Trial Remaining: {0}", license.TrialRemaining));
Console.WriteLine(String.Format("Is Trial Elapsed: {0}", license.TrialUsed));
Console.WriteLine(String.Format("Is Trial First Run: {0}", license.WasTrialFristRun));

Console.WriteLine();
Console.WriteLine("Press ENTER to exit.");
Console.ReadLine();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using WaveTech.Scutex.Model;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Scutex.Samples.CSharp.WpfApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Scutex.Samples.CSharp.WpfApplication")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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: License("31|30|39|36|34|31|31|38|35|35|39|33|30|33|39|36|35|31|39|35|37|35|37|37|33|35|36|38|34|31|37|31|35|32|30|31|34|31|33|34|32|32|38|34|38|34|36|36|33|35|38|37|35|38|39|35|31|36|39|38|31|30|30|39|37|38|31|32|30|39|33|30|30|36|37|34|38|39|38|30|35|38|33|39|32|35|32|31|38|39|35|33|34|30|33|33|30|37|33|35|39|30|33|37|30|32|38|35|33|38|35|33|33|30|35|37|36|35|33|33|34|30|30|35|39|30|37|39|38|30|39|38|38|38|39|39|39|31|36|35|38|30|31|39|30|38|36|35|39|38|31|30|30|33|37|35|35|35|38|34|38|35|33|38|33|37|32|32|32|33|35|31|34|36|39|33|35|38|35|39|32|39|38|38|38|35|35|35|35|30|36|31|30|32|31|36|32|32|30|30|36|38|32|35|38|37|31|33|30|36|37|38|32|38|35|35|30|38|34|36|38|34|38|34|36|31|39|34|35|33|37|37|7c|36|35|35|33|37", "38|45|2d|41|36|2d|30|36|2d|44|33|2d|33|35|2d|34|34|2d|33|45|2d|36|37|2d|30|34|2d|46|35|2d|38|32|2d|32|39|2d|46|36|2d|44|46|2d|36|46|2d|44|36|2d|31|46|2d|42|37|2d|35|33|2d|35|36")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 866ef4c

Please sign in to comment.