Ejemplo n.º 1
0
 /// <summary>
 /// Create an Instance of a CredentialService
 /// </summary>
 /// <param name="dragonchainId">dragonchainId associated with these credentials</param>
 /// <param name="authKey">authKey to use with these credentials</param>
 /// <param name="authKeyId">authKeyId to use with these credentials</param>
 /// <param name="hmacAlgo">hmac algorithm to use</param>
 /// <param name="credentialManager">manager to retrieve Dragonchain credentials from config provider</param>
 /// <param name="logger"></param>
 public CredentialService(string dragonchainId, string authKey = "", string authKeyId = "", string endpointUrl = "", HmacAlgorithm hmacAlgo = HmacAlgorithm.SHA256, ICredentialManager credentialManager = null, ILogger <DragonchainClient> logger = null)
 {
     _logger       = logger ?? new NullLogger <DragonchainClient>();
     DragonchainId = dragonchainId;
     if (!string.IsNullOrWhiteSpace(authKey) && !string.IsNullOrWhiteSpace(authKeyId))
     {
         _logger.LogDebug("Auth Key/Id and endpoint URL provided explicitly, will not search env/disk");
         _credentials = new DragonchainCredentials {
             AuthKey = authKey, AuthKeyId = authKeyId, EndpointUrl = endpointUrl
         };
     }
     else
     {
         try
         {
             _credentials = credentialManager.GetDragonchainCredentials(dragonchainId);
         }
         catch
         {  // don't require credentials to be present on construction
             _credentials = new DragonchainCredentials {
                 AuthKey = string.Empty, AuthKeyId = string.Empty, EndpointUrl = string.Empty
             };
         }
     }
     _hmacAlgo = hmacAlgo;
 }