示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Eboks.Account account = new Eboks.Account();
            account.UserId         = tbUserId.Text;
            account.Password       = tbPassword.Text;
            account.ActivationCode = tbActivationCode.Text;

            Eboks.Api api = new Eboks.Api();
            api.GetSessionForAccount(account);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Eboks.Account account = new Eboks.Account();
            account.UserId = tbUserId.Text;
            account.Password = tbPassword.Text;
            account.ActivationCode = tbActivationCode.Text;

            Eboks.Api api = new Eboks.Api();
            api.GetSessionForAccount(account);
        }
示例#3
0
        private string GetAuthHeader(Account account, Session session)
        {
            string date = DateTime.Now.ToString("R");

            string input = string.Format("{0}:{1}:P:{2}:DK:{3}:{4}",
                account.ActivationCode,
                session.DeviceId,
                account.UserId,
                account.Password,
                date);

            string challenge = Sha256Hash(input);
            challenge = Sha256Hash(challenge);

            return string.Format("logon deviceid=\"{0}\",datetime=\"{1}\",challenge=\"{2}\"", session.DeviceId, date, challenge);
        }
示例#4
0
 public List<string> GetFolders(Account account)
 {
     return null;
 }
示例#5
0
        public Session GetSessionForAccount(Account account)
        {
            RestClient client = new RestClient(BaseUrl);
            client.UserAgent = "eboks/35 CFNetwork/672.1.15 Darwin/14.0.0";

            var request = new RestRequest("/session", Method.PUT);
            request.RequestFormat = DataFormat.Xml;

            Session session = new Session();
            session.DeviceId = Guid.NewGuid().ToString();

            request.AddHeader("X-EBOKS-AUTHENTICATE", GetAuthHeader(account, session));
            //request.AddHeader("Content-Type", "application/xml");
            request.AddHeader("Accept", "*/*");

            var logon = new Logon();
            logon.App = new App();
            logon.App.Version = "1.4.1";
            logon.App.OS = "iOS";
            logon.App.OSVersion = "9.0.0";
            logon.App.Device = "iPhone";

            logon.User = new User();
            logon.User.Identity = account.UserId;
            logon.User.IdentityType = "P";
            logon.User.Nationality = "DK";
            logon.User.Pincode = account.Password;

            //request.AddBody(logon, "urn:eboks:mobile:1.0.0");

            /*
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + Environment.NewLine +
             "<register-request">" + Environment.NewLine +
             "    <name=\"someName\"/>" + Environment.NewLine +
             "</register-request>");

request.AddParameter("text/xml", registerSinkRequest, ParameterType.RequestBody);
            */

            string xml;

            var serializer = new XmlSerializer(logon.GetType(), "urn:eboks:mobile:1.0.0");

            var ns = new XmlSerializerNamespaces();
            ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            ns.Add("xsd", "http://www.w3.org/2001/XMLSchema");

            using(StringWriter textWriter = new Utf8StringWriter())
            {
                serializer.Serialize(textWriter, logon, ns);
                xml = textWriter.ToString();
            }




            IRestResponse response;

            response = client.Execute(request);

            return null;
        }