mirror of
https://github.com/bitwarden/server.git
synced 2025-06-28 14:46:14 -05:00
Cleaned up byte array logic
This commit is contained in:
parent
43f31a312b
commit
ea13f51776
@ -51,19 +51,19 @@ public static class LicenseExtensions
|
|||||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||||
.Where(p =>
|
.Where(p =>
|
||||||
{
|
{
|
||||||
var versionAttr = p.GetCustomAttribute<LicenseVersionAttribute>();
|
|
||||||
if (versionAttr is null || versionAttr.Version > license.Version)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var ignoreAttr = p.GetCustomAttribute<LicenseIgnoreAttribute>();
|
var ignoreAttr = p.GetCustomAttribute<LicenseIgnoreAttribute>();
|
||||||
if (ignoreAttr is null)
|
if (ignoreAttr is not null)
|
||||||
{
|
{
|
||||||
return true;
|
return !forHash && ignoreAttr.IncludeInSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !forHash && ignoreAttr.IncludeInSignature;
|
var versionAttr = p.GetCustomAttribute<LicenseVersionAttribute>();
|
||||||
|
if (versionAttr is not null)
|
||||||
|
{
|
||||||
|
return versionAttr.Version <= license.Version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
.OrderBy(p => p.Name)
|
.OrderBy(p => p.Name)
|
||||||
.Select(p => $"{p.Name}:{CoreHelpers.FormatLicenseSignatureValue(p.GetValue(license, null))}")
|
.Select(p => $"{p.Name}:{CoreHelpers.FormatLicenseSignatureValue(p.GetValue(license, null))}")
|
||||||
|
@ -9,17 +9,9 @@ public abstract class BaseLicense : ILicense
|
|||||||
[LicenseVersion(1)]
|
[LicenseVersion(1)]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
|
||||||
[LicenseIgnore(includeInSignature: true)]
|
|
||||||
public DateTime Issued { get; set; }
|
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
[LicenseVersion(1)]
|
||||||
public DateTime? Expires { get; set; }
|
public DateTime? Expires { get; set; }
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
|
||||||
[LicenseIgnore(includeInSignature: true)]
|
|
||||||
public DateTime? Refresh { get; set; }
|
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
[LicenseVersion(1)]
|
||||||
public int Version { get; set; }
|
public int Version { get; set; }
|
||||||
|
|
||||||
@ -32,11 +24,6 @@ public abstract class BaseLicense : ILicense
|
|||||||
[LicenseVersion(1)]
|
[LicenseVersion(1)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
|
||||||
[LicenseIgnore(includeInSignature: true)]
|
|
||||||
public string Hash { get; set; }
|
|
||||||
|
|
||||||
[LicenseVersion(1)]
|
|
||||||
[LicenseIgnore]
|
[LicenseIgnore]
|
||||||
public string Signature { get; set; }
|
public string Signature { get; set; }
|
||||||
|
|
||||||
@ -49,4 +36,13 @@ public abstract class BaseLicense : ILicense
|
|||||||
[LicenseIgnore]
|
[LicenseIgnore]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public abstract bool ValidLicenseVersion { get; }
|
public abstract bool ValidLicenseVersion { get; }
|
||||||
|
|
||||||
|
[LicenseIgnore(includeInSignature: true)]
|
||||||
|
public DateTime? Refresh { get; set; }
|
||||||
|
|
||||||
|
[LicenseIgnore(includeInSignature: true)]
|
||||||
|
public DateTime Issued { get; set; }
|
||||||
|
|
||||||
|
[LicenseIgnore(includeInSignature: true)]
|
||||||
|
public string Hash { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user