Skip to content

Commit

Permalink
Merge pull request #18 from aariste/dev
Browse files Browse the repository at this point in the history
V0.7.1
  • Loading branch information
aariste authored May 13, 2024
2 parents 7bfb1a5 + e7a8b7c commit d3ee623
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 268 deletions.
81 changes: 0 additions & 81 deletions AASAXUtilLib/AX/Framework/Tools/ModelManagement/AxUtilContext.cs

This file was deleted.

12 changes: 0 additions & 12 deletions AASAXUtilLib/AX/Framework/Tools/ModelManagement/ExecutionStatus.cs

This file was deleted.

120 changes: 0 additions & 120 deletions AASAXUtilLib/AX/Framework/Tools/ModelManagement/LicenseInfo.cs

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Security.Cryptography.X509Certificates;

namespace Microsoft.Dynamics.AX.Framework.Tools.ModelManagement
namespace AASAXUtilLib
{
public class AxUtil
{
Expand All @@ -15,57 +15,57 @@ public AxUtil()
public AxUtil(AxUtilContext context, AxUtilConfiguration config)
: this()
{
AxUtil.ValidateContextAndConfigNotNull(context, config);
this.Context = context;
this.Config = config;
ValidateContextAndConfigNotNull(context, config);
Context = context;
Config = config;
}

public AxUtilContext Context
{
get
{
return this.context;
return context;
}
set
{
AxUtil.ValidateContextNotNull(value);
this.context = value;
ValidateContextNotNull(value);
context = value;
}
}

public AxUtilConfiguration Config
{
get
{
return this.config;
return config;
}
set
{
AxUtil.ValidateConfigNotNull(value);
this.config = value;
ValidateConfigNotNull(value);
config = value;
}
}

public bool GenerateLicense(X509Certificate2Collection scollection)
{
if (scollection.Count == 0)
{
throw new System.NullReferenceException("No certificate loaded.");
throw new NullReferenceException("No certificate loaded.");
}

foreach (X509Certificate2 x509 in scollection)
{
X509Certificate2 certificate = x509;

return new LicenseGenerator(this.config, this.context).GenerateLicense(certificate);
return new LicenseGenerator(config, context).GenerateLicense(certificate);
}

return false;
}

public bool GenerateLicenseKeyVault(string keyVaultDNS, string keyName, string tenantId, string clientId, string clientSecret)
{
return new LicenseGenerator(this.config, this.context).GenerateLicenseKeyVault(keyVaultDNS, keyName, tenantId, clientId, clientSecret);
{
return new LicenseGenerator(config, context).GenerateLicenseKeyVault(keyVaultDNS, keyName, tenantId, clientId, clientSecret);
}

private static void ValidateContextNotNull(AxUtilContext context)
Expand All @@ -84,8 +84,8 @@ private static void ValidateContextAndConfigNotNull(
AxUtilContext context,
AxUtilConfiguration config)
{
AxUtil.ValidateContextNotNull(context);
AxUtil.ValidateConfigNotNull(config);
ValidateContextNotNull(context);
ValidateConfigNotNull(config);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Microsoft.Dynamics.AX.Framework.Tools.ModelManagement
namespace AASAXUtilLib
{
[Serializable]
public class AxUtilConfiguration
Expand Down
16 changes: 16 additions & 0 deletions AASAXUtilLib/AxUtilContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

namespace AASAXUtilLib
{
[Serializable]
public class AxUtilContext : MarshalByRefObject
{
private List<string> errors = new List<string>();

public virtual void ReportError(string errorText)
{
this.errors.Add(errorText);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
using Microsoft.Dynamics.AX.Framework.Tools.ModelManagement.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Microsoft.Dynamics.AX.Framework.Tools.ModelManagement
namespace AASAXUtilLib
{
internal class LicenseGenerator
{
Expand Down Expand Up @@ -171,22 +169,7 @@ private bool GenerateLicenseFileKeyVault(string keyVaultDNS, string keyName, str
return false;
}
return true;
}

private X509Certificate2 LoadCertificate()
{
X509Certificate2 certificate;
try
{
certificate = new X509Certificate2(this.licenseInfo.CertificatePath, this.licenseInfo.Password);
}
catch (CryptographicException ex)
{
this.context.ReportError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.CertificateLoadFailure, (object)ex.Message));
return (X509Certificate2)null;
}
return !this.ValidateCertificate(certificate) ? (X509Certificate2)null : certificate;
}
}

private string GenerateSignature(X509Certificate2 certificate)
{
Expand Down
Loading

0 comments on commit d3ee623

Please sign in to comment.