mirror of
https://github.com/bitwarden/server
synced 2026-01-08 19:43:34 +00:00
[EC-826] Merge license sync feature branch to master (#2587)
* [EC-634] Extract GenerateLicenseAsync to a query (#2373) * [EC-637] Add license sync to server (#2453) * [EC-1036] Show correct license sync date (#2626) * Update method name per new pattern
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
using System.Text.Json;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.OrganizationConnectionConfigs;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Entities;
|
||||
|
||||
public class OrganizationConnection<T> : OrganizationConnection where T : new()
|
||||
public class OrganizationConnection<T> : OrganizationConnection where T : IConnectionConfig
|
||||
{
|
||||
public new T Config
|
||||
{
|
||||
get => base.GetConfig<T>();
|
||||
set => base.SetConfig<T>(value);
|
||||
set => base.SetConfig(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ public class OrganizationConnection : ITableObject<Guid>
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public T GetConfig<T>() where T : new()
|
||||
public T GetConfig<T>() where T : IConnectionConfig
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -38,8 +39,32 @@ public class OrganizationConnection : ITableObject<Guid>
|
||||
}
|
||||
}
|
||||
|
||||
public void SetConfig<T>(T config) where T : new()
|
||||
public void SetConfig<T>(T config) where T : IConnectionConfig
|
||||
{
|
||||
Config = JsonSerializer.Serialize(config);
|
||||
}
|
||||
|
||||
public bool Validate<T>(out string exception) where T : IConnectionConfig
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
exception = $"Connection disabled for organization {OrganizationId}";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Config))
|
||||
{
|
||||
exception = $"No saved Connection config for organization {OrganizationId}";
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = GetConfig<T>();
|
||||
if (config == null)
|
||||
{
|
||||
exception = $"Error parsing Connection config for organization {OrganizationId}";
|
||||
return false;
|
||||
}
|
||||
|
||||
return config.Validate(out exception);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user