Beispiel #1
0
        private string DecodeAuthorizationString()
        {
            string userPass = string.Empty;

            if (Request.Headers.Authorization == null)
            {
                // throw HttpResponseHelper.GetUnauthorizedResponseException("Auth Header is null!");
                string emailAddress = ConfigurationManager.AppSettings["Email"].ToString();
                string password     = ConfigurationManager.AppSettings["Password"].ToString();
                userPass = string.Format("{0}:{1}", emailAddress, password);
            }
            else
            {
                var authHeader = Request.Headers.Authorization;
                if (authHeader.Scheme.ToLower() != Constants.AUTH_HEADER.BASIC)
                {
                    throw HttpResponseHelper.GetUnauthorizedResponseException("Auth Header is not using BASIC scheme!");
                }
                var encodedUserPass = authHeader.Parameter;
                userPass = Encoding.UTF8.GetString(Convert.FromBase64String(encodedUserPass));
            }
            return(userPass);
        }