/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="endpoint">The endpoint of metrics backend servers.</param> /// <param name="certificateThumbprint">The thumbprint of the certificate used to publish metrics data to the MDM.</param> /// <param name="certificateStoreLocation">The certificate store location.</param> /// <param name="certificate">The certificate used to authenticate with MDM.</param> /// <param name="timeout">The time to wait before the request times out. The timeout value can range from 30 seconds to 5 minutes.</param> /// <param name="mdmEnvironment">The global environment to be targeted by the instance.</param> /// <exception cref="ArgumentNullException"> /// endpoint /// or /// certificateThumbprint /// </exception> private ConnectionInfo( Uri endpoint, string certificateThumbprint, StoreLocation certificateStoreLocation, X509Certificate2 certificate, TimeSpan timeout, MdmEnvironment mdmEnvironment) { if (certificate != null && !string.IsNullOrWhiteSpace(certificateThumbprint)) { throw new ArgumentException($"Either {nameof(certificate)} or {nameof(certificateThumbprint)} can be specified, but not both."); } if (timeout < MinTimeout || timeout > MaxTimeout) { throw new ArgumentException($"The timeout value for a request must be between {MinTimeout} and {MaxTimeout}."); } if (certificate == null && string.IsNullOrWhiteSpace(certificateThumbprint)) { this.UseAadUserAuthentication = true; } Logger.Log( LoggerLevel.Info, LogId, "Created", "A new connection was created. Endpoint:{0}, CertThumbprint:{1}, CertStore:{2}, TimeoutMs:{3}", endpoint, certificate != null ? certificate.Thumbprint : certificateThumbprint, certificateStoreLocation, timeout.TotalMilliseconds); this.Endpoint = endpoint; this.CertificateThumbprint = certificateThumbprint; this.CertificateStoreLocation = certificateStoreLocation; this.Certificate = certificate; this.Timeout = timeout; if (mdmEnvironment != MdmEnvironment.Production && mdmEnvironment != MdmEnvironment.Int) { throw new ArgumentException($"The parameter {nameof(mdmEnvironment)} has an invalid value {mdmEnvironment}"); } this.mdmEnvironmentMapIndex = (int)mdmEnvironment; }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="certificateThumbprint">The thumbprint of the certificate used to publish metrics data to the MDM.</param> /// <param name="certificateStoreLocation">The certificate store location.</param> /// <param name="timeout">The time to wait before the request times out. The timeout value can range from 30 seconds to 5 minutes.</param> /// <param name="mdmEnvironment">The global environment to be targeted by the instance.</param> public ConnectionInfo(string certificateThumbprint, StoreLocation certificateStoreLocation, TimeSpan timeout, MdmEnvironment mdmEnvironment = MdmEnvironment.Production) : this(null, certificateThumbprint, certificateStoreLocation, null, timeout, mdmEnvironment) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="timeout">The time to wait before the request times out. The timeout value can range from 30 seconds to 5 minutes.</param> /// <param name="mdmEnvironment">The global environment to be targeted by the instance.</param> public ConnectionInfo(TimeSpan timeout, MdmEnvironment mdmEnvironment = MdmEnvironment.Production) : this(null, null, StoreLocation.LocalMachine, null, timeout, mdmEnvironment) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="mdmEnvironment">The global environment to be targeted by the instance.</param> public ConnectionInfo(MdmEnvironment mdmEnvironment = MdmEnvironment.Production) : this(null, null, StoreLocation.LocalMachine, null, DefaultTimeout, mdmEnvironment) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="certificate">The certificate used to authenticate with MDM.</param> /// <param name="mdmEnvironment">The global environment to be targeted by the instance.</param> public ConnectionInfo(X509Certificate2 certificate, MdmEnvironment mdmEnvironment = MdmEnvironment.Production) : this(null, null, StoreLocation.LocalMachine, certificate, DefaultTimeout, mdmEnvironment) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="certificateThumbprint">The certificate thumbprint.</param> /// <param name="mdmEnvironment">The to be targeted by the instance.</param> public ConnectionInfo(string certificateThumbprint, MdmEnvironment mdmEnvironment = MdmEnvironment.Production) : this(null, certificateThumbprint, StoreLocation.LocalMachine, null, DefaultTimeout, mdmEnvironment) { }