-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Enhance Serialization and Hardware Identification
## Key Changes * **Serialization Improvements:** Introduced a new serialization mechanism with `ILicenseSerializer` and `JsonLicenseSerializer` to enhance flexibility and support different serialization formats. * **Custom Hardware Identification:** Added `IHardwareIdentifier` interface and `DefaultHardwareIdentifier` to allow custom hardware identification logic. * **Simplified Offline Validation Logic:** Refactored offline validation in `LicenseManager` to provide a more streamlined approach and allow bypassing built-in validation logic using `SetBuiltInValidation(bool enable)`. * **Dependency Removal:** Removed the `DeviceId` NuGet package dependency. * **Saving Arguments Conflict:** Updated the `SaveLicense` method in `LicenseBuilder` to `SaveLicenseToPath` to fix conflicts caused by `privateKey` parameter. * **Updated Tests:** Updated the tests to reflect the changes in the library. ## Detailed Changes ### New Files * **Interfaces/IHardwareIdentifier.cs:** Defines the interface for custom hardware identification. * **Interfaces/ILicenseSerializer.cs:** Defines the interface for license serialization. * **Serialization/JsonLicenseSerializer.cs:** Provides a JSON implementation of the `ILicenseSerializer` interface. * **Serialization/Converters/JsonLicenseConverter.cs:** A custom JSON converter for handling license type inheritance. * **Utilities/DefaultHardwareIdentifier.cs:** Provides the default hardware identification logic. ### Modified Files * **LicenseBuilder.cs:** Changed `SaveLicense` to call `LicenseManager.SaveLicenseToPath`. * **LicenseGenerator.cs:** Now uses `IHardwareIdentifier` for retrieving hardware IDs. Has a new internal `SetHardwareIdentifier` method. * **LicenseManager.cs:** * Added `SetSerializer` and `SetHardwareIdentifier` methods. * Added `SetBuiltInValidation` method. * Renamed `SaveLicense` to `SaveLicenseToPath`. * Now uses `_serializer.Serialize` for serialization. * **LicenseValidator.cs:** * Added `SetSerializer` and `SetHardwareIdentifier` methods. * Uses injected `_serializer` for deserialization. * `ValidateNodeLockedLicense` method now uses the injected `_hardwareIdentifier`. * **Exceptions/InvalidLicenseFormatException.cs:** Added constructors with `innerException` parameter. * **Aegis.csproj:** * Updated version to 1.3.0. * Removed the `DeviceId` package reference. * **Utilities/HardwareUtils.cs:** Functionality moved to the new `DefaultHardwareIdentifier` class. File deleted. * **Utilities/LicenseUtils.cs:** No functional changes, but the `LoadLicenseSecrets` method documentation was updated. * **Utilities/SecurityUtils.cs:** No functional changes, but the `CalculateSha256Hash` method is now public. ## Upgrade Considerations * If you were relying on the specific hardware identification implementation of the previous version using `HardwareUtils`, you will need to inject your custom implementation of `IHardwareIdentifier` or use the new provided `DefaultHardwareIdentifier`. * If you were using a different serialization mechanism, you can now implement the `ILicenseSerializer` interface and inject it using `LicenseManager.SetSerializer`.
- Loading branch information
LSXPrime
authored and
LSXPrime
committed
Nov 20, 2024
1 parent
32c9374
commit 3de1c86
Showing
18 changed files
with
401 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Greetings | ||
|
||
on: pull_request_target | ||
|
||
jobs: | ||
greeting: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- uses: actions/first-interaction@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
pr-message: | | ||
Welcome to Aegis repository! We appreciate you taking the time to contribute. | ||
We're excited to review your pull request and look forward to collaborating with you. Please let us know if you have any questions or need any assistance. | ||
Thank you for your contribution! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. | ||
# | ||
# You can adjust the behavior by modifying this file. | ||
# For more information, see: | ||
# https://github.com/actions/stale | ||
name: Mark stale issues and pull requests | ||
|
||
on: | ||
schedule: | ||
- cron: '44 8 * * *' | ||
|
||
jobs: | ||
stale: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/stale@v5 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: | | ||
This issue has been automatically marked as stale because it has not had recent activity. | ||
It will be closed if no further activity occurs. | ||
If this issue is still relevant, please leave a comment indicating that you would like it to remain open. | ||
Thank you for your contributions. | ||
stale-pr-message: | | ||
This pull request has been automatically marked as stale because it has not had recent activity. | ||
It will be closed if no further activity occurs. | ||
If you are still working on this pull request, please leave a comment indicating that you would like it to remain open. | ||
Thank you for your contributions. | ||
stale-issue-label: 'no-issue-activity' | ||
stale-pr-label: 'no-pr-activity' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
namespace Aegis.Exceptions; | ||
|
||
public class InvalidLicenseFormatException(string message) : LicenseValidationException(message); | ||
public class InvalidLicenseFormatException : LicenseValidationException | ||
{ | ||
public InvalidLicenseFormatException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public InvalidLicenseFormatException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Aegis.Interfaces; | ||
|
||
public interface IHardwareIdentifier | ||
{ | ||
string GetHardwareIdentifier(); | ||
bool ValidateHardwareIdentifier(string hardwareIdentifier); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Aegis.Models; | ||
|
||
namespace Aegis.Interfaces; | ||
|
||
public interface ILicenseSerializer | ||
{ | ||
string Serialize(BaseLicense license); | ||
BaseLicense? Deserialize(string data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.