-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from cyberark/ca-conjur-api-dotnet-v5-master
Update To Support v5 API
- Loading branch information
Showing
44 changed files
with
1,169 additions
and
1,037 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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// <copyright file="ApiConfigurationManager.cs" company="CyberArk Software Ltd."> | ||
// Copyright (c) 2020 CyberArk Software Ltd. All rights reserved. | ||
// </copyright> | ||
// <summary> | ||
// Configuration class for this API project | ||
// </summary> | ||
using System; | ||
using System.Configuration; | ||
|
||
namespace Conjur | ||
{ | ||
public sealed class ApiConfigurationManager | ||
{ | ||
public const string HTTP_REQUEST_TIMEOUT = "HTTP_REQUEST_TIMEOUT"; | ||
public const string TOKEN_REFRESH_TIMEOUT = "TOKEN_REFRESH_TIMEOUT"; | ||
|
||
private ApiConfigurationManager() | ||
{ | ||
} | ||
|
||
public static ApiConfigurationManager GetInstance() | ||
{ | ||
return Nested.Instance; | ||
} | ||
|
||
private object locker = new object(); | ||
|
||
private int? httpRequestTimeout = null; | ||
|
||
/// <summary> | ||
/// Gets/Sets the global http request timeout configuration. | ||
/// Request timeout configuration in milliseconds, default is: 100000. | ||
/// </summary> | ||
public int HttpRequestTimeout { | ||
get { | ||
if (httpRequestTimeout == null) { | ||
lock (locker) { | ||
if (httpRequestTimeout == null) { | ||
string value = ConfigurationManager.AppSettings.Get (HTTP_REQUEST_TIMEOUT); | ||
httpRequestTimeout = 100000; //100 seconds; WebRequest default timeout | ||
if (!string.IsNullOrWhiteSpace (value)) { | ||
httpRequestTimeout = Convert.ToInt32 (value); | ||
} | ||
} | ||
} | ||
} | ||
return httpRequestTimeout.Value; | ||
} | ||
set { | ||
httpRequestTimeout = value; | ||
} | ||
} | ||
|
||
private uint? tokenRefreshTimeout = null; | ||
|
||
/// <summary> | ||
/// Gets/Sets the global token refresh timeout configuration. | ||
/// Token refresh timeout configuration in milliseconds, default is: 420000 (7 minutes). | ||
/// </summary> | ||
public uint TokenRefreshTimeout { | ||
get { | ||
if (tokenRefreshTimeout == null) { | ||
lock (locker) { | ||
if (tokenRefreshTimeout == null) { | ||
string value = ConfigurationManager.AppSettings.Get (TOKEN_REFRESH_TIMEOUT); | ||
tokenRefreshTimeout = 420000; //7 minutes | ||
if (!string.IsNullOrWhiteSpace (value)) { | ||
tokenRefreshTimeout = Convert.ToUInt32 (value); | ||
} | ||
} | ||
} | ||
} | ||
return tokenRefreshTimeout.Value; | ||
} | ||
set { | ||
tokenRefreshTimeout = value; | ||
} | ||
} | ||
|
||
private class Nested | ||
{ | ||
internal static readonly ApiConfigurationManager Instance = new ApiConfigurationManager(); | ||
|
||
static Nested() | ||
{ | ||
} | ||
} | ||
} | ||
} |
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.