Package com.bj58.sfft.json.orgjson

Examples of com.bj58.sfft.json.orgjson.JSONObject


  }

  public void testConvertTochar() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    char actual = new JsonConvert().convertTochar(jsonObj.get("fchar"));
    junit.framework.Assert.assertEquals(te.getFchar(), actual);
  }
View Full Code Here


  }

  public void testConvertTodouble() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    double actual = new JsonConvert().convertTodouble(jsonObj
        .get("fdouble"));
    junit.framework.Assert.assertEquals(te.getFdouble(), actual);
  }
View Full Code Here

  }

  public void testConvertTofloat() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    float actual = new JsonConvert().convertTofloat(jsonObj.get("ffloat"));
    junit.framework.Assert.assertEquals(te.getFfloat(), actual);
  }
View Full Code Here

  }

  public void testConvertToint() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    int actual = new JsonConvert().convertToint(jsonObj.get("fint"));
    junit.framework.Assert.assertEquals(te.getFint(), actual);
  }
View Full Code Here

  }

  public void testConvertTolong() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    long actual = new JsonConvert().convertTolong(jsonObj.get("flong"));
    junit.framework.Assert.assertEquals(te.getFlong(), actual);
  }
View Full Code Here

  }

  public void testConvertToshort() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    short actual = new JsonConvert().convertToshort(jsonObj.get("fshort"));
    junit.framework.Assert.assertEquals(te.getFshort(), actual);
  }
View Full Code Here

  public void testConvertToT() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);

    JSONObject jsonObj = new JSONObject(jsonStr);

    TestEntityII actual = (TestEntityII) new JsonConvert().convertToT(
        jsonObj.get("fObject"), TestEntityII.class);

    junit.framework.Assert.assertEquals(
        ((TestEntityII) te.getFObject()).getId(), actual.getId());
    junit.framework.Assert.assertEquals(
        ((TestEntityII) te.getFObject()).getTitle(), actual.getTitle());
View Full Code Here

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

        //判断当前channel是否通过认证
        if(!sc.isRights()){
          //没有通过认证
          if(protocol != null && protocol.getSdpEntity() instanceof HandclaspProtocol){
            SecureKey sk = new SecureKey();
            HandclaspProtocol handclaspProtocol = (HandclaspProtocol)protocol.getSdpEntity();
            /**
             * 接收 客户端公钥
             */
            if("1".equals(handclaspProtocol.getType())){
              sk.initRSAkey();
              //客户端发送公钥数据
              String clientPublicKey = handclaspProtocol.getData();
              if(null == clientPublicKey || "".equals(clientPublicKey)){
                logger.warn("get client publicKey warn!");
              }
              //java 客户端
              if(protocol.getPlatformType() == PlatformType.Java){
                //服务器生成公/私钥,公钥传送给客户端
                sc.setServerPublicKey(sk.getStringPublicKey());
                sc.setServerPrivateKey(sk.getStringPrivateKey());
                sc.setClientPublicKey(clientPublicKey);
                handclaspProtocol.setData(sk.getStringPublicKey());//服务器端公钥
              }
             
              protocol.setSdpEntity(handclaspProtocol);
              response.setResponseBuffer(protocol.toBytes());
              context.setGaeaResponse(response);
              this.setInvokeAndFilter(context);
              logger.info("send server publieKey sucess!");
            }
            /**
             * 接收权限文件
             */
            else if("2".equals(handclaspProtocol.getType())){
              //客户端加密授权文件
              String clientSecureInfo = handclaspProtocol.getData();
              if(null == clientSecureInfo || "".equals(clientSecureInfo)){
                logger.warn("get client secureKey warn!");
              }
              //授权文件客户端原文(服务器私钥解密)
              String sourceInfo = sk.decryptByPrivateKey(clientSecureInfo, sc.getServerPrivateKey());
              //校验授权文件是否相同
              //判断是否合法,如果合法服务器端生成DES密钥,通过客户端提供的公钥进行加密传送给客户端
              if(global.containsSecureMap(sourceInfo)){
                logger.info("secureKey is ok!");
                String desKey = StringUtils.getRandomNumAndStr(8);
                //设置当前channel属性
                sc.setDesKey(desKey);
                sc.setRights(true);
                handclaspProtocol.setData(sk.encryptByPublicKey(desKey, sc.getClientPublicKey()));
                protocol.setSdpEntity(handclaspProtocol);
                response.setResponseBuffer(protocol.toBytes());
                context.setGaeaResponse(response);
              }else{
                logger.error("It's bad secureKey!");
View Full Code Here

    System.out.println("state:" + this.getState().toString());
    System.out.println("errorMsg:" + this.getErrorMsg());
    System.out.println("MessageBodyBase:");
   
    if(sdp.getClass() == RequestProtocol.class) {
      RequestProtocol request = (RequestProtocol)this.sdp;
      System.out.println("Server.Lookup:" + request.getLookup());
      System.out.println("Server.MethodName:" + request.getMethodName());
      System.out.println("Server.ParaKVList:");
      for(KeyValuePair kv : request.getParaKVList()){
        System.out.println("key:" + kv.getKey() + "---value:"+kv.getValue());
      }
    }
        super.printStackTrace();
        System.out.println("--------------------------end------------------------------");
View Full Code Here

TOP

Related Classes of com.bj58.sfft.json.orgjson.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.