Skip to content

Commit d2a810a

Browse files
author
Lee Fine
committed
ab#80665
1 parent 4dffbb9 commit d2a810a

3 files changed

Lines changed: 13 additions & 34 deletions

File tree

CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
using Org.BouncyCastle.Crypto;
3535
using Org.BouncyCastle.OpenSsl;
3636
using Org.BouncyCastle.Pkcs;
37+
using Keyfactor.Orchestrators.Common.Enums;
3738

3839
namespace Keyfactor.Extensions.Orchestrator.CitricAdc
3940
{
4041
// ReSharper disable once InconsistentNaming
4142
internal class CitrixAdcStore
4243
{
43-
private const uint Timeout = 3600;
44+
private const uint DefaultTimeout = 3600;
4445
public static readonly string StoreType = "CitrixAdc";
4546

4647
private readonly string _clientMachine;
@@ -51,6 +52,7 @@ internal class CitrixAdcStore
5152
public readonly string StorePath;
5253
private readonly string _username;
5354
private readonly bool _useSsl;
55+
private readonly uint _timeout;
5456

5557
private nitro_service _nss;
5658

@@ -61,6 +63,12 @@ public CitrixAdcStore(InventoryJobConfiguration config, string serverUserName, s
6163
Logger = LogHandler.GetClassLogger<CitrixAdcStore>();
6264
Logger.MethodEntry(LogLevel.Debug);
6365

66+
dynamic properties = JsonConvert.DeserializeObject(config.CertificateStoreDetails.Properties.ToString());
67+
if (!UInt32.TryParse((properties.timeout == null || string.IsNullOrEmpty(properties.timeout.Value) ? DefaultTimeout : properties.timeout.Value), out _timeout))
68+
{
69+
Logger.LogWarning($"Missing or invalid Custom Field 'timeout' value {properties.timeout.Value}. Value must be an integer. Will use default value of {DefaultTimeout.ToString()}");
70+
}
71+
6472
_clientMachine = config.CertificateStoreDetails.ClientMachine;
6573
StorePath = StripTrailingSlash(config.CertificateStoreDetails.StorePath);
6674
var o = new systemfile_args();
@@ -123,11 +131,11 @@ public CitrixAdcStore(ManagementJobConfiguration config, string serverUserName,
123131
// ReSharper disable once UnusedAutoPropertyAccessor.Local
124132
private ILogger Logger { get; }
125133

126-
public void Login(uint? timeout)
134+
public void Login()
127135
{
128136
Logger.MethodEntry(LogLevel.Debug);
129137
_nss ??= new nitro_service(_clientMachine, _useSsl ? "https" : "http");
130-
_nss.set_timeout(timeout == 0 ? Timeout : timeout);
138+
_nss.set_timeout(_timeout);
131139

132140
base_response response = null;
133141
try

CitrixAdcOrchestratorJobExtension/Inventory.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,11 @@ public JobResult ProcessJob(InventoryJobConfiguration jobConfiguration, SubmitIn
5555
ServerPassword = ResolvePamField("ServerPassword", jobConfiguration.ServerPassword);
5656
ServerUserName = ResolvePamField("ServerUserName", jobConfiguration.ServerUsername);
5757

58-
dynamic properties = JsonConvert.DeserializeObject(jobConfiguration.CertificateStoreDetails.Properties.ToString());
59-
UInt32 timeout = 0;
60-
if (!UInt32.TryParse((properties.timeout == null || string.IsNullOrEmpty(properties.timeout.Value) ? "0" : properties.timeout.Value), out timeout))
61-
{
62-
string err = $"Invalid Custom Field 'timeout' value {properties.timeout.Value}. Value must be numeric";
63-
_logger.LogError(err);
64-
return new JobResult
65-
{
66-
Result = OrchestratorJobStatusJobResult.Failure,
67-
JobHistoryId = jobConfiguration.JobHistoryId,
68-
FailureMessage =
69-
$"Site {jobConfiguration.CertificateStoreDetails.StorePath} on server {jobConfiguration.CertificateStoreDetails.ClientMachine}: {err}."
70-
};
71-
}
72-
7358
_logger.LogDebug("Entering ProcessJob");
7459
CitrixAdcStore store = new CitrixAdcStore(jobConfiguration, ServerUserName, ServerPassword);
7560

7661
_logger.LogDebug("Logging into Citrix...");
77-
store.Login(timeout);
62+
store.Login();
7863

7964
JobResult result = ProcessJob(store, jobConfiguration, submitInventoryUpdate);
8065

CitrixAdcOrchestratorJobExtension/Management.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,12 @@ public JobResult ProcessJob(ManagementJobConfiguration jobConfiguration)
6565
dynamic properties = JsonConvert.DeserializeObject(jobConfiguration.CertificateStoreDetails.Properties.ToString());
6666
var linkToIssuer = properties.linkToIssuer == null || string.IsNullOrEmpty(properties.linkToIssuer.Value) ? false : Convert.ToBoolean(properties.linkToIssuer.Value);
6767

68-
UInt32 timeout = 0;
69-
if (!UInt32.TryParse((properties.timeout == null || string.IsNullOrEmpty(properties.timeout.Value) ? "0" : properties.timeout.Value), out timeout))
70-
{
71-
string err = $"Invalid Custom Field 'timeout' value {properties.timeout.Value}. Value must be numeric";
72-
_logger.LogError(err);
73-
return new JobResult
74-
{
75-
Result = OrchestratorJobStatusJobResult.Failure,
76-
JobHistoryId = jobConfiguration.JobHistoryId,
77-
FailureMessage =
78-
$"Site {jobConfiguration.CertificateStoreDetails.StorePath} on server {jobConfiguration.CertificateStoreDetails.ClientMachine}: {err}."
79-
};
80-
}
81-
8268
ApplicationSettings.Initialize(this.GetType().Assembly.Location);
8369

8470
var store = new CitrixAdcStore(jobConfiguration, ServerUserName, ServerPassword);
8571

8672
_logger.LogDebug("Logging into Citrix...");
87-
store.Login(timeout);
73+
store.Login();
8874

8975
try
9076
{

0 commit comments

Comments
 (0)