Package com.bj58.spat.gaea.client.proxy

Examples of com.bj58.spat.gaea.client.proxy.ServiceProxy


*/
public class PathMatcherTest {

    @Test
    public void test() {
        PathMatcher pathMatcher = new AntPathMatcher();

        String pattern = "/{a}/{b}/{c}";

        String sample = "/aa/bb/cc";

        Assert.assertTrue(pathMatcher.match(pattern, sample));

    }
View Full Code Here


    }


    @Test
    public void testPathMatch(){
        PathMatcher pathMatcher = new AntPathMatcher();
        String registeredPath = "/me/hello/{name}";
        String url = "/me/hello/renjun";
        Assert.assertTrue(pathMatcher.match(registeredPath, url));

        Map<String, String> values = pathMatcher.extractUriTemplateVariables(registeredPath, url);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals("renjun", values.get("name"));

        System.out.println("OK testpathMatch");
View Full Code Here

        InputStream in = new BufferedInputStream(request.getInputStream());
        String content_type = request.getContentType();

        File tempDir = new File(config.getLocation());

        MultiPartInputStreamParser mpis = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        mpis.setDeleteOnExit(true);
        return mpis;
    }
View Full Code Here

        InputStream in = new BufferedInputStream(super.getInputStream());
        String content_type = super.getContentType();

        File tempDir = new File(config.getLocation());

        multiParser = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        multiParser.setDeleteOnExit(true);

        Collection<Part> parts = multiParser.getParts();

        int keyCount = queryStrings.size();
View Full Code Here

*/
public class EnterpriseUserTest {

  @Test
  public void TestUser() throws Exception {
    SESUser user = new SESUser();
    user.setUserID(1L);
    user.setState(1);

    Serializer serializer = new Serializer();
    byte[] buffer = serializer.Serialize(user);
    assertNotNull(buffer);
    Object obj = serializer.Derialize(buffer, SimpleClass.class);
View Full Code Here

        }
        if (args.length != typeAry.length) {
            throw new Exception("argument count error!");
        }

        ServiceProxy proxy = ServiceProxy.getProxy(serviceName);
        Parameter[] paras = new Parameter[args.length];
        List<Integer> outParas = new ArrayList<Integer>();

        if (typeAry != null) {
            for (int i = 0; i < typeAry.length; i++) {
                if (args[i] instanceof Out) {
                    paras[i] = new Parameter(args[i], clsAry[i], typeAry[i], ParaType.Out);
                    outParas.add(i);
                } else {
                    paras[i] = new Parameter(args[i], clsAry[i], typeAry[i], ParaType.In);
                }
            }
        }
        Parameter returnPara = new Parameter(null, methodInfo.getReturnType(), methodInfo.getGenericReturnType());
        String methodName = methodInfo.getName();
        OperationContract ann = methodInfo.getAnnotation(OperationContract.class);
        if (ann != null) {
            if (!ann.methodName().equals(AnnotationUtil.DEFAULT_VALUE)) {
                methodName = "$" + ann.methodName();
            }
        }
        InvokeResult result = proxy.invoke(returnPara, lookup, methodName, paras);

        if (result != null && result.getOutPara() != null) {
            for (int i = 0; i < outParas.size() && i < result.getOutPara().length; i++) {
                Object op = args[outParas.get(i)];
                if(op instanceof Out){
View Full Code Here

          return true;
        }
         
        //----发送客户端公钥去服务器端、并获取服务器端公钥--start---------------------
        SecureKey sk = new SecureKey();//生成客户端公/私 钥     
        ServiceProxy proxy = ServiceProxy.getProxy(serviceConfig.getServicename());
        HandclaspProtocol handclaspProtocol = new HandclaspProtocol("1",sk.getStringPublicKey());
        Protocol publicKeyProtocol = proxy.createProtocol(handclaspProtocol);
         
        try {
          scoket.registerRec(publicKeyProtocol.getSessionID());
          scoket.send(publicKeyProtocol.toBytes());//过程2
          logger.info("send client publicKey sucess!");
        } finally {
          //scoket.dispose();
        }
           
        handclaspProtocol = null;
        /**
        * 过程3,接收服务器端生成公钥
        */
        byte[] receivePublicBuffer = scoket.receive(publicKeyProtocol.getSessionID(), server.getCurrUserCount());
        if(null == receivePublicBuffer){
          logger.warn("获取服务器公钥失败!");
            return false;
        }
           
        Protocol serverPublicProtocol = publicKeyProtocol.fromBytes(receivePublicBuffer);
        HandclaspProtocol _handclaspProtocol = null;
           
        if (serverPublicProtocol.getSDPType() == SDPType.Handclasp) {
          _handclaspProtocol = (HandclaspProtocol)serverPublicProtocol.getSdpEntity();
            logger.debug("get server publicKey time:" + (System.currentTimeMillis() - startTime) + "ms");
               
        } else if (serverPublicProtocol.getSDPType() == SDPType.Exception) {
            ExceptionProtocol ep = (ExceptionProtocol)serverPublicProtocol.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else if(serverPublicProtocol.getSDPType() == SDPType.Reset){
          throw new RebootException("this server is reboot!");
        } else {
            throw new Exception("userdatatype error!");
        }
           
        logger.info("receive server publicKey sucess!");
        publicKeyProtocol = null;
           
        String keyInfo = serviceConfig.getSecureKey().getInfo();//授权文件
        if(null == keyInfo || "".equals(keyInfo)){
          logger.warn("获取授权文件失败!");
           return false;
        }
           
        String ciphertext = sk.encryptByPublicKeyString(keyInfo, _handclaspProtocol.getData());
        _handclaspProtocol = null;
        serverPublicProtocol = null;
        //----发送客户端公钥去服务器端、并获取服务器端公钥--end---------------------
        //---发送授权文件到服务器端认证--------------------start-------------------------------
        HandclaspProtocol handclaspProtocol_ = new HandclaspProtocol("2",ciphertext);
        Protocol protocol_mw = proxy.createProtocol(handclaspProtocol_);
         
        try {
          scoket.registerRec(protocol_mw.getSessionID());
          scoket.send(protocol_mw.toBytes());//过程4
          logger.info("send keyInfo sucess!");
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

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

    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
 
  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

TOP

Related Classes of com.bj58.spat.gaea.client.proxy.ServiceProxy

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.