Package com.bj58.spat.gaea.client.secure

Examples of com.bj58.spat.gaea.client.secure.DESCoderHelper


    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


public class ProtocolHelperTest {

  @Test
  public void testFromBytes() throws Exception {
    RequestProtocol rp = new RequestProtocol("lookup", "methodname", null);
    Protocol p = new Protocol(101001, (byte)1, SDPType.Request, rp);
   
    byte[] buffer = p.toBytes();
   
    Protocol p2 = (Protocol)ProtocolHelper.fromBytes(buffer);
    Assert.assertEquals(rp.getLookup(), ((RequestProtocol)p2.getSdpEntity()).getLookup());
    Assert.assertEquals(rp.getMethodName(), ((RequestProtocol)p2.getSdpEntity()).getMethodName());
  }
View Full Code Here

  }
 
 
  @Test
  public void testToBytes() throws Exception {
    RequestProtocol rp = new RequestProtocol("lookup", "methodname", null);
    Protocol p = new Protocol(101001, (byte)1, SDPType.Request, rp);
   
    byte[] buffer = p.toBytes();
    StringBuilder sbBuf = new StringBuilder();
    for(byte b : buffer) {
View Full Code Here

    Object response = null;
    Protocol protocol = null;
   
    try {
        protocol = context.getGaeaRequest().getProtocol();
      RequestProtocol request = (RequestProtocol)protocol.getSdpEntity();
     
      sbInvokerMsg.append("protocol version:");
      sbInvokerMsg.append(protocol.getVersion());
      sbInvokerMsg.append("\nfromIP:");
      sbInvokerMsg.append(context.getChannel().getRemoteIP());
      sbInvokerMsg.append("\nlookUP:");
      sbInvokerMsg.append(request.getLookup());
      sbInvokerMsg.append("\nmethodName:");
      sbInvokerMsg.append(request.getMethodName());
      sbInvokerMsg.append("\nparams:");
     
      if(request.getParaKVList() != null){
        for (KeyValuePair kv : request.getParaKVList()) {
          if(kv != null) {
            sbInvokerMsg.append("\n--key:");
            sbInvokerMsg.append(kv.getKey());
            sbInvokerMsg.append("\n--value:");
            sbInvokerMsg.append(kv.getValue());
          } else {
            logger.error("KeyValuePair is null  Lookup:" + request.getLookup() + "--MethodName:" + request.getMethodName());
          }
        }
      }
     
      logger.debug(sbInvokerMsg.toString());
      logger.debug("begin get proxy factory");
     
      // get local proxy
      IProxyStub localProxy = Global.getSingleton().getProxyFactory().getProxy(request.getLookup());
      logger.debug("proxyFactory.getProxy finish");

      if (localProxy == null) {
        ServiceFrameException sfe = new ServiceFrameException(
            "method:ProxyHandle.invoke--msg:" + request.getLookup() + "." + request.getMethodName() + " not fond",
            context.getChannel().getRemoteIP(),
            context.getChannel().getLocalIP(),
            request,
            ErrorState.NotFoundServiceException,
            null);
        response = ExceptionHelper.createError(sfe);
        logger.error("localProxy is null", sfe);
      } else {
        logger.debug("begin localProxy.invoke");
        String swInvoderKey = "InvokeRealService_" + request.getLookup() + "." + request.getMethodName();
        sw.startNew(swInvoderKey, sbInvokerMsg.toString());
        sw.setFromIP(context.getChannel().getRemoteIP());
        sw.setLocalIP(context.getChannel().getLocalIP());
       
        //invoker real service
View Full Code Here

  }

  public void setGaeaRequest(GaeaRequest gaeaRequest) {
    this.gaeaRequest = gaeaRequest;
   
    RequestProtocol r = (RequestProtocol)gaeaRequest.getProtocol().getSdpEntity();
    this.stopWatch.setLookup(r.getLookup());
    this.stopWatch.setMethodName(r.getMethodName());
  }
View Full Code Here

      //当前服务启动权限认证,并且当前channel通过校验,则进行方法校验
      SecureContext securecontext = global.getGlobalSecureContext(context.getChannel().getNettyChannel());
      if(global.getGlobalSecureIsRights()){
        //当前服务启用权限认证,判断当前channel是否通过授权
        if(securecontext.isRights()){
          RequestProtocol request = (RequestProtocol)p.getSdpEntity();
          if(request != null){
            StringBuffer buff = new StringBuffer(request.getLookup() + "." +request.getMethodName());//接口实现类.方法名(参数序列)
            buff.append("(");
            List<KeyValuePair> list = request.getParaKVList();
            if(list != null){
              int i=0;
              for(KeyValuePair k : list){
                if(k != null){
                  if(i > 0){
View Full Code Here

      int outParaSize = gaeaResponse.getOutParaList().size();
      Object[] objArray = new Object[outParaSize];
      for(int i=0; i<outParaSize; i++) {
        objArray[i] = gaeaResponse.getOutParaList().get(i).getOutPara();
      }
            return new ResponseProtocol(gaeaResponse.getReturnValue(), objArray);
        } else {
            return new ResponseProtocol(gaeaResponse.getReturnValue(), null);
        }
  }
View Full Code Here

  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);
    Object expect = obj;
    assertNotNull(expect);
  }
View Full Code Here

*/
public class SerializerTest {

  @Test
  public void testByte() throws Exception {
    Serializer serializer = new Serializer();
    Byte[] b = null;
    byte[] buffer = serializer.Serialize(b);

    Object obj1 = serializer.Derialize(buffer, Byte[].class);

    Short[] s = new Short[] { 1, 2, 3 };
    byte[] bs = serializer.Serialize(s);

    Map<Byte, Object> map = new HashMap<Byte, Object>();
    map.put((byte) 1, "abc");
    map.put((byte) 2, 123456L);
    map.put((byte) 3, s);
    map.put((byte) 4, 123);
    map.put((byte) 5, null);

    byte[] buf3 = serializer.Serialize(map);
    Map<Byte, Object> obj3 = (Map<Byte, Object>) serializer.Derialize(buf3,
        Map.class);
    System.out.println(obj3.get(5));
  }
View Full Code Here

   */
  @Test
  public void TestObject() throws Exception {
    SimpleClass sc = SimpleClass.Get();
    Object data = sc;
    Serializer serializer = new Serializer();
    byte[] buffer = serializer.Serialize(data);
    assertNotNull(buffer);
    Object obj = serializer.Derialize(buffer, SimpleClass.class);

    Object expect = obj;
    assertNotNull(expect);
  }
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.client.secure.DESCoderHelper

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.