/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// </summary> /// <param name="host">The host.</param> /// <param name="mimeFormat"></param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true, IWebProxy proxy = null) { if (string.IsNullOrEmpty(host)) { throw new RedmineException("Host is not defined!"); } PageSize = 25; Uri uriResult; if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult) || !(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)) { host = "http://" + host; } if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult)) { throw new RedmineException("The host is not valid!"); } this.host = host; this.mimeFormat = mimeFormat; Proxy = proxy; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; if (!verifyServerCert) { ServicePointManager.ServerCertificateValidationCallback += RemoteCertValidate; } }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager" /> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable /// REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different /// ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to /// each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the /// default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="apiKey">The API key.</param> /// <param name="mimeFormat">The MIME format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> /// <param name="proxy">The proxy.</param> /// <param name="securityProtocolType">Use this parameter to specify a SecurityProtcolType. Note: it is recommended to leave this parameter at its default value as this setting also affects the calling application process.</param> /// <param name="timeout">The webclient timeout. Default is 100 seconds.</param> public RedmineManager(string host, string apiKey, MimeFormat mimeFormat = MimeFormat.Xml, bool verifyServerCert = true, IWebProxy proxy = null, SecurityProtocolType securityProtocolType = default, TimeSpan?timeout = null) : this(host, mimeFormat, verifyServerCert, proxy, securityProtocolType, timeout : timeout) { ApiKey = apiKey; }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager" /> class. /// </summary> /// <param name="host">The host.</param> /// <param name="mimeFormat">The MIME format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> /// <param name="proxy">The proxy.</param> /// <param name="securityProtocolType">Use this parameter to specify a SecurityProtcolType. Note: it is recommended to leave this parameter at its default value as this setting also affects the calling application process.</param> /// <exception cref="Redmine.Net.Api.Exceptions.RedmineException"> /// Host is not defined! /// or /// The host is not valid! /// </exception> public RedmineManager(string host, MimeFormat mimeFormat = MimeFormat.Xml, bool verifyServerCert = true, IWebProxy proxy = null, SecurityProtocolType securityProtocolType = default(SecurityProtocolType)) { if (string.IsNullOrEmpty(host)) { throw new RedmineException("Host is not defined!"); } PageSize = 25; if (default(SecurityProtocolType) == securityProtocolType) { securityProtocolType = ServicePointManager.SecurityProtocol; } Host = host; MimeFormat = mimeFormat; Proxy = proxy; SecurityProtocolType = securityProtocolType; ServicePointManager.SecurityProtocol = securityProtocolType; if (!verifyServerCert) { ServicePointManager.ServerCertificateValidationCallback += RemoteCertValidate; } }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="login">The login.</param> /// <param name="password">The password.</param> /// <param name="mimeFormat"></param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, string login, string password, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true, IWebProxy proxy = null) : this(host, mimeFormat, verifyServerCert, proxy) { cache = new CredentialCache { { new Uri(host), "Basic", new NetworkCredential(login, password) } }; string token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", login, password))); basicAuthorization = string.Format("Basic {0}", token); }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager" /> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable /// REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different /// ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to /// each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the /// default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="login">The login.</param> /// <param name="password">The password.</param> /// <param name="mimeFormat">The MIME format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> /// <param name="proxy">The proxy.</param> /// <param name="securityProtocolType">Use this parameter to specify a SecurityProtcolType. Note: it is recommended to leave this parameter at its default value as this setting also affects the calling application process.</param> /// <param name="timeout">The webclient timeout. Default is 100 seconds.</param> public RedmineManager(string host, string login, string password, MimeFormat mimeFormat = MimeFormat.Xml, bool verifyServerCert = true, IWebProxy proxy = null, SecurityProtocolType securityProtocolType = default, TimeSpan?timeout = null) : this(host, mimeFormat, verifyServerCert, proxy, securityProtocolType, timeout : timeout) { cache = new CredentialCache { { new Uri(host), "Basic", new NetworkCredential(login, password) } }; var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0}:{1}", login, password))); basicAuthorization = string.Format(CultureInfo.InvariantCulture, "Basic {0}", token); }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="login">The login.</param> /// <param name="password">The password.</param> /// <param name="mimeFormat">The Mime format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, string login, string password, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true) : this(host, mimeFormat, verifyServerCert) { PageSize = 25; Uri uriResult; if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult) || !(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)) { host = "http://" + host; } if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult)) { throw new RedmineException("The host is not valid!"); } cache = new CredentialCache { { uriResult, "Basic", new NetworkCredential(login, password) } }; basicAuthorization = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(login + ":" + password)); }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager" /> class. /// </summary> /// <param name="host">The host.</param> /// <param name="mimeFormat">The MIME format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> /// <param name="proxy">The proxy.</param> /// <param name="securityProtocolType">Use this parameter to specify a SecurityProtcolType. Note: it is recommended to leave this parameter at its default value as this setting also affects the calling application process.</param> /// <param name="scheme">http or https. Default is https.</param> /// <param name="timeout">The webclient timeout. Default is 100 seconds.</param> /// <exception cref="Redmine.Net.Api.Exceptions.RedmineException"> /// Host is not defined! /// or /// The host is not valid! /// </exception> public RedmineManager(string host, MimeFormat mimeFormat = MimeFormat.Xml, bool verifyServerCert = true, IWebProxy proxy = null, SecurityProtocolType securityProtocolType = default, string scheme = "https", TimeSpan?timeout = null) { if (string.IsNullOrEmpty(host)) { throw new RedmineException("Host is not defined!"); } PageSize = 25; Scheme = scheme; Host = host; MimeFormat = mimeFormat; Timeout = timeout; Proxy = proxy; if (mimeFormat == MimeFormat.Xml) { Format = "xml"; Serializer = new XmlRedmineSerializer(); } else { Format = "json"; Serializer = new JsonRedmineSerializer(); } if (securityProtocolType == default) { securityProtocolType = ServicePointManager.SecurityProtocol; } SecurityProtocolType = securityProtocolType; ServicePointManager.SecurityProtocol = securityProtocolType; if (!verifyServerCert) { ServicePointManager.ServerCertificateValidationCallback += RemoteCertValidate; } }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// </summary> /// <param name="host">The host.</param> /// <param name="mimeFormat"></param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true) { PageSize = 25; Uri uriResult; if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult) || !(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)) { host = "http://" + host; } if (!Uri.TryCreate(host, UriKind.Absolute, out uriResult)) { throw new RedmineException("The host is not valid!"); } this.host = host; this.mimeFormat = mimeFormat; if (!verifyServerCert) { ServicePointManager.ServerCertificateValidationCallback += RemoteCertValidate; } }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="apiKey">The API key.</param> /// <param name="mimeFormat">The Mime format.</param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, string apiKey, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true) : this(host, mimeFormat, verifyServerCert) { PageSize = 25; this.apiKey = apiKey; }
/// <summary> /// Initializes a new instance of the <see cref="RedmineManager"/> class. /// Most of the time, the API requires authentication. To enable the API-style authentication, you have to check Enable REST API in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different ways: /// using your regular login/password via HTTP Basic authentication. /// using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to each request in one of the following way: /// passed in as a "key" parameter /// passed in as a username with a random password via HTTP Basic authentication /// passed in as a "X-Redmine-API-Key" HTTP header (added in Redmine 1.1.0) /// You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout. /// </summary> /// <param name="host">The host.</param> /// <param name="apiKey">The API key.</param> /// <param name="mimeFormat"></param> /// <param name="verifyServerCert">if set to <c>true</c> [verify server cert].</param> public RedmineManager(string host, string apiKey, MimeFormat mimeFormat = MimeFormat.xml, bool verifyServerCert = true, IWebProxy proxy = null) : this(host, mimeFormat, verifyServerCert, proxy) { this.apiKey = apiKey; }