Exemplo n.º 1
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override void OnDBPull(HTTPReq req)
    {
        JSon json = new JSon(req.response);

        if (json["error"] != null)
        {
            return;
        }

        if ((json.root is JSonObject) == false)
        {
            return;
        }


        JSonObject o = json.root as JSonObject;

        m_loginUsername = o["login_username"].value;

        m_loginPassword = o["login_password"].value;

        name = o["name"].value;

        m_rank = ( RANK )System.Enum.Parse(typeof(RANK), o["rank"].value, true);

        m_type = ( TYPE )System.Enum.Parse(typeof(TYPE), o["type"].value, true);
    }
Exemplo n.º 2
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override void OnDBPull(HTTPReq req)
    {
        JSon json = new JSon(req.response);

        if (json["error"] != null)
        {
            return;
        }

        if ((json.root is JSonObject) == false)
        {
            return;
        }


        JSonObject o = json.root as JSonObject;

        System.DateTime.TryParse(o["date_found"].value, out m_dateFound);


        name = o["name"].value;

        parentID = long.Parse(o["site_id"].value);

        m_coord.latitude.FromAngle(float.Parse(o["lat"].value), GPS.UNIT.DD);

        m_coord.longitude.FromAngle(float.Parse(o["lng"].value), GPS.UNIT.DD);

        m_coord.altitude = float.Parse(o["alt"].value);

        m_pic = o["pic"].value;
    }
Exemplo n.º 3
0
 public void Intialize()
 {
     ReadObj           = new JSonObject();
     WriteObj          = new JSonObject();
     SymmetricKey      = new SymmetricKeyGenerator();
     GeneratoreMachine = new PrimeNumberGenerator();
 }
Exemplo n.º 4
0
        public async Task <String> RetrieveDHSessionKey(String PublickKey)
        {
            String DecryptedServerNumber;
            String readString = await ActivitySocket.read();

            ReadObj = JsonParse.ReadObject(readString);
            if (FingerPrint.Verification(ReadObj.getServerPrimeNumber(), PublickKey, ReadObj.getFingerPrint()))
            {
                if (MacAlgProvider.VerifyHMAC(ReadObj.getServerPrimeNumber(), SymmetricKey.StrKeyBase64,
                                              ReadObj.getHmacHash()))
                {
                    DecryptedServerNumber = AesEncryption.AES_Decrypt(ReadObj.getServerPrimeNumber(),
                                                                      SymmetricKey.StrKeyBase64);
                }
                else
                {
                    throw new Exception("Integrity of SymmetricKey canot verified");
                }
            }

            else
            {
                throw new Exception("Integrity of RSA canot verified");
            }

            return(GeneratoreMachine.SessionDHGenerator(DecryptedServerNumber));
        }
Exemplo n.º 5
0
        public async Task <String> GetPublicKey()
        {
            String readString = await ActivitySocket.read();

            ReadObj = JsonParse.ReadObject(readString);
            return(ReadObj.getRSAPublicKey());
        }
Exemplo n.º 6
0
            public static JSon Deserialize(StringReader reader)
            {
                char car;

                do
                {
                    car = (char)reader.Peek();
                    JSon res = null;
                    switch (car)
                    {
                    case '{':
                        reader.Read();
                        res = new JSonObject();
                        break;

                    case '[':
                        reader.Read();
                        res = new JSonArray();
                        break;

                    case '"':
                        reader.Read();
                        res = new JSonString();
                        break;

                    case var x when(x >= '0' && x <= '9') || (x == '-'):
                        res = new JSonInt();

                        break;
                    }

                    if (res != null)
                    {
                        res.Parse(reader);
                        return(res);
                    }

                    reader.Read();
                } while (car == ' ' || car == '\n');

                return(null);
            }
Exemplo n.º 7
0
        protected void update_Click(object sender, EventArgs e)
        {
            if (mClaimType == "PR")
            {
                JSonObject jsonValue = new JSonObject();
                jsonValue.Put("GioiThieuChung", ckbPR_GioiThieuChung.Checked.ToString());
                jsonValue.Put("NguoiDuocBaoHiem", ckbPR_NguoiDuocBaoHiem.Checked.ToString());
                jsonValue.Put("DienBien", ckbPR_DienBien.Checked.ToString());
                jsonValue.Put("NguyenNhan", ckbPR_NguyenNhan.Checked.ToString());
                jsonValue.Put("PhamViBaoHiem", ckbPR_PhamViBaoHiem.Checked.ToString());
                jsonValue.Put("PhamViVaMucDoThietHai", ckbPR_PhamViVaMucDoThietHai.Checked.ToString());
                jsonValue.Put("DonBaoHiemKhac", ckbPR_DonBaoHiemKhac.Checked.ToString());
                jsonValue.Put("GiaTriThuHoi", ckbPR_GiaTriThuHoi.Checked.ToString());
                jsonValue.Put("TheQuyenTruyDoiBenThuBa", ckbPR_TheQuyenTruyDoiBenThuBa.Checked.ToString());
                jsonValue.Put("DuPhongBoiThuong", ckbPR_DuPhongBoiThuong.Checked.ToString());
                jsonValue.Put("TamUngBoiThuongText", ckbPR_TamUngBoiThuongText.Checked.ToString());
                jsonValue.Put("BaoCaoTiepTheo", ckbPR_BaoCaoTiepTheo.Checked.ToString());


                MucLucDTO mucLucDTO = MucLucDAO.getMucLuc(mClaimID, mClaimType);
                if (mucLucDTO == null)
                {
                    mucLucDTO           = new MucLucDTO();
                    mucLucDTO.ID_Claim  = mClaimID;
                    mucLucDTO.ClaimType = mClaimType;
                    mucLucDTO.JsonValue = jsonValue.ToString();

                    MucLucDAO.Insert(mucLucDTO);
                }
                else
                {
                    mucLucDTO.JsonValue = jsonValue.ToString();
                    MucLucDAO.Update(mucLucDTO);
                }

                Response.Write("<script> window.parent.closeAllDialog(); </script>");
                Response.Write("<script> window.parent.reloaData(); </script>");
            }
        }
Exemplo n.º 8
0
        public async Task <String> ReceiveDHEncryptedMessage(String PublicKey)
        {
            ReadObj = JsonParse.ReadObject(await ActivitySocket.read());

            if (FingerPrint.Verification(ReadObj.getEncryptedMessage(), PublicKey, ReadObj.getFingerPrint()))
            {
                if (MacAlgProvider.VerifyHMAC(ReadObj.getEncryptedMessage(), sessionKey.SessionKey,
                                              ReadObj.getHmacHash()))
                {
                    return(AesEncryption.AES_Decrypt(ReadObj.getEncryptedMessage(),
                                                     sessionKey.SessionKey));
                }
                else
                {
                    throw new Exception("Integrity of SymmetricKey canot verified");
                }
            }
            else
            {
                throw new Exception("Integrity of RSA canot verified");
            }
        }
Exemplo n.º 9
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override void OnDBPull(HTTPReq req)
    {
        JSon json = new JSon(req.response);

        if (json["error"] != null)
        {
            return;
        }

        if ((json.root is JSonObject) == false)
        {
            return;
        }


        JSonObject o = json.root as JSonObject;

        System.DateTime.TryParse(o["date_funded"].value, out m_dateFunded);

        name = o["name"].value;

        m_desc = o["dsc"].value;
    }
Exemplo n.º 10
0
 public static string Wrap(string obj, Type type)
 {
     var jObj=new JSonObject(type,obj);
     var wrappedObj = JsonConvert.SerializeObject(jObj);
     return wrappedObj;
 }
Exemplo n.º 11
0
 public static object Unwrap(JSonObject obj)
 {
     return obj.GetObj();
 }
Exemplo n.º 12
0
 public static Type GetType(JSonObject obj)
 {
     return obj.GetType();
 }
Exemplo n.º 13
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public bool Parse(string json)
    {
        if (string.IsNullOrEmpty(json))
        {
            return(false);
        }

        ControlStack ctrl = new ControlStack();

        JSonEntry cur = null;

        string name = null;

        m_root = null;


        for (int c = 0; c < json.Length; ++c)
        {
            //--------------------------------------------------------------------------------------------
            // register expression
            //--------------------------------------------------------------------------------------------

            if (char.IsWhiteSpace(json[c]) == false)
            {
                if (Semantics.hasProps(json[c], Semantics.PROP.ALL) == false)
                {
                    if (ctrl.expr.start == -1)
                    {
                        ctrl.expr.end = ctrl.expr.start = c;
                    }

                    else
                    {
                        ctrl.expr.end = c;
                    }

                    if (json[c] == QUOTE)
                    {
                        ++ctrl.expr.quotes; continue;
                    }
                }
            }
            else
            {
                continue;
            }

            //--------------------------------------------------------------------------------------------
            // register name or value
            //--------------------------------------------------------------------------------------------

            if (Semantics.hasProps(json[c], Semantics.PROP.CTRL) == true)
            {
                if ((ctrl.expr.quotes & 1) == 0)
                {
                    bool isName = (json[c] == COLON);

                    bool isValue = (isName == false);

                    bool valid = ctrl.expr.valid;

                    if ((isName) && (valid == false))
                    {
                        return(false);
                    }

                    if ((isName) && (cur is JSonObject) == false)
                    {
                        return(false);
                    }

                    if (valid)
                    {
                        string expr = json.Substring(ctrl.expr.start, ctrl.expr.end - ctrl.expr.start + 1).TrimEnd(' ', QUOTE, ' ').TrimStart(' ', QUOTE, ' ');

                        if (isName)
                        {
                            name = expr;
                        }

                        else if (isValue)
                        {
                            new JSonValue(name, cur).value = expr; name = null;
                        }
                    }

                    ctrl.expr.Reset();

                    if (Semantics.hasProps(json[c], Semantics.PROP.GRP) == false)
                    {
                        continue;
                    }
                }
            }

            //--------------------------------------------------------------------------------------------
            // register object or array
            //--------------------------------------------------------------------------------------------

            if (ctrl.expr.quotes == 0)
            {
                if (json[c] == BGN_OBJ)
                {
                    if ((cur == null) || ctrl.push(cur))
                    {
                        cur = new JSonObject(name, cur); if (m_root == null)
                        {
                            m_root = cur;
                        }
                        name = null; ctrl.expr.Reset(); continue;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (json[c] == BGN_ARR)
                {
                    if ((cur == null) || ctrl.push(cur))
                    {
                        cur = new JSonArray(name, cur); if (m_root == null)
                        {
                            m_root = cur;
                        }
                        name = null; ctrl.expr.Reset(); continue;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (json[c] == END_OBJ)
                {
                    if (cur == m_root)
                    {
                        break;
                    }
                    if ((cur is JSonObject) && ctrl.pop(ref cur))
                    {
                        ctrl.expr.Reset(); continue;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (json[c] == END_ARR)
                {
                    if (cur == m_root)
                    {
                        break;
                    }
                    if ((cur is JSonArray) && ctrl.pop(ref cur))
                    {
                        ctrl.expr.Reset(); continue;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }

        return((m_root != null) && (ctrl.empty));
    }
Exemplo n.º 14
0
 //Serialize the given Object in Json String format
 public static String WriteObject(JSonObject WriteObj)
 {
     return(JsonConvert.SerializeObject(WriteObj));
 }
Exemplo n.º 15
0
 public void Intialize()
 {
     ReadObj  = new JSonObject();
     WriteObj = new JSonObject();
 }