Example #1
0
        public SDK(String userName, SecureString password, Uri gateway, string client, MeisterSupport.Languages language = MeisterSupport.Languages.CultureBased)
        {
            var credentials = Encoding.ASCII.GetBytes(userName + ":" + MeisterSupport.ToUnSecureString(password));

            reportSdk.AuthenticationHeaderValue = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));
            reportSdk.Gateway  = gateway;
            reportSdk.Client   = client;
            reportSdk.Language = language;
        }
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            string us = RetrieveContent(this.UserName.Text, userName);

            us = us.ToUpper();
            string pw = RetrieveContent(this.Password.Text, password);
            string cl = RetrieveContent(this.SAPClient.Text, sap_client);
            string od = RetrieveContent(this.OD4Mode.Checked.ToString(), od4, false, true);

            MeisterSupport.Languages lang;
            Enum.TryParse <MeisterSupport.Languages>(this.LoginLanguage.SelectedValue, out lang);
            bool bod4 = false;

            bool.TryParse(od, out bod4);
            Uri u = new Uri(RetrieveContent(this.SAPGateway.Text, gtw_url, true));

            if (!(string.IsNullOrEmpty(us) && string.IsNullOrEmpty(pw) && string.IsNullOrEmpty(cl) && string.IsNullOrEmpty(u.AbsoluteUri)))
            {
                SDK sdk = new SDK(us, MeisterSupport.ToSecureString(pw), u, cl, lang);
                if (sdk.Authenticate().StatusCode == System.Net.HttpStatusCode.OK)
                {
                    this.isAuthenticated   = true;
                    Session[userName]      = us;
                    Session[authenticated] = true;
                    Session[od4]           = bod4;
                    Session[password]      = pw;
                    Session[sap_client]    = cl;
                    Session[gtw_url]       = u.AbsoluteUri;
                    Session[the_sdk]       = sdk;
                    Session[language]      = Language.ToString();
                    this.Response.Redirect("~/main.aspx");
                }
                else
                {
                    this.FailureText.Text = sdk.HttpsStatusDescription();
                }
            }
        }