Telerik.TestStudio.Jira.BugTracking.Base64String.prefix C# (CSharp) Method

prefix() public method

Insert the string in front of this Base64 encoded string
public prefix ( string plainText ) : Base64String
plainText string The plain text string to insert then re-encode the result.
return Base64String
        public Base64String prefix(string plainText)
        {
            return EncodeTo64(plainText + DecodeFrom64(this.base64value));
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Gets a JSON object from the JIRA server using an HTTP GET
        /// </summary>
        /// <param name="server">The URL of the server e.g. http://myserver.com</param>
        /// <param name="path">The REST path send the request to e.g. /rest/api/2/project</param>
        /// <param name="username">The user ID required for authentication. null or empty will use anonymous access.</param>
        /// <param name="password">The password required for authentication encoded using Base64. null or empty will use anonymous access.</param>
        /// <returns>A JSON object containing the results</returns>
        internal static JToken GetJson(string server, string path, string username, Base64String password, out string error)
        {
            JToken result;

            error = null;

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(server + path);

            httpWebRequest.ContentType     = "application/json";
            httpWebRequest.ProtocolVersion = HttpVersion.Version11;
            httpWebRequest.Method          = "GET";
            httpWebRequest.UserAgent       = agent;
            httpWebRequest.Proxy           = WebRequest.GetSystemWebProxy();

            // Add the required authentication header
            if (!string.IsNullOrEmpty(username) && password.Length > 0)
            {
                Base64String authInfo = password.prefix(username + ":");
                httpWebRequest.Headers["Authorization"] = "Basic " + authInfo;
            }
            try
            {
                HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (JsonTextReader streamReader = new JsonTextReader(new System.IO.StreamReader(httpResponse.GetResponseStream())))
                {
                    result = JToken.ReadFrom(streamReader);
                }
                return(result);
            }
            catch (WebException e)
            {
                error = e.Message;
                return(null);
            }
        }
All Usage Examples Of Telerik.TestStudio.Jira.BugTracking.Base64String::prefix