Package com.bj58.argo.internal

Examples of com.bj58.argo.internal.DefaultArgoDispatcher$Context


  private static String src = "afh425yqdsf*$#^Q@#%HFGKSHFKG@#$%SFDGSFGK@$TDSF";


  @Test
  public void testDecryptByPubKey() throws Exception {
    RSAHelper helper = RSAHelper.getInstance();
    byte[] destBuf = helper.encryptByPrivateKey(src.getBytes("utf-8"));
    byte[] srcBuf = helper.decryptByPublicKey(destBuf);
    Assert.assertEquals(src, new String(srcBuf, "utf-8"));
  }
View Full Code Here


    Assert.assertEquals(src, new String(srcBuf, "utf-8"));
  }

  @Test
  public void testDecryptByPriKey() throws Exception {
    RSAHelper helper = RSAHelper.getInstance();
    byte[] destBuf = helper.encryptByPublicKey(src.getBytes("utf-8"));
    byte[] srcBuf = helper.decryptByPrivateKey(destBuf);
    Assert.assertEquals(src, new String(srcBuf, "utf-8"));
  }
View Full Code Here

    Assert.assertEquals(src, new String(srcBuf, "utf-8"));
  }
 
  @Test
  public void testPublicKey() throws Exception {
    RSAHelper helper1 = RSAHelper.getInstance();
    String exponent = helper1.getPubExponent();
    String modulus = helper1.getPubModulus();
    System.out.println("-----------------------------------");
   
    byte[] expBuf = exponent.getBytes("utf-8");
    byte[] modBuf = modulus.getBytes("utf-8");
    for(int i=0; i<expBuf.length; i++) {
      System.out.print(expBuf[i] + ",");
    }
    System.out.println("\n-----------------------------------");
    for(int i=0; i<modBuf.length; i++) {
      System.out.print(modBuf[i] + ",");
    }
    System.out.println("\n-----------------------------------");
    System.out.println(exponent);
    System.out.println("-----------------------------------");
    System.out.println(modulus);
    System.out.println("-----------------------------------");
   
   
    byte[] buf = helper1.encryptByPrivateKey(src.getBytes("utf-8"));
    for(int i=0; i<buf.length; i++) {
      System.out.print((buf[i] < 0 ? buf[i] + 256 : buf[i]) + ",");
    }
   
   
   
    RSAHelper helper2 = RSAHelper.getInstance(modulus, exponent);
    byte[] destBuf = helper2.encryptByPublicKey(src.getBytes("utf-8"));
    byte[] srcBuf = helper1.decryptByPrivateKey(destBuf);
    Assert.assertEquals(src, new String(srcBuf, "utf-8"));
  }
View Full Code Here

  @Test
  public void testCustomKey() throws Exception {
    String modulus = new String(new byte[]{65,76,66,70,47,121,82,48,116,99,82,104,118,102,89,81,43,120,114,67,77,66,76,90,103,120,98,119,77,53,74,50,88,71,73,68,121,71,82,67,108,56,86,84,122,66,105,52,116,83,88,116,76,102,86,83,73,77,114,87,119,114,84,102,100,90,83,70,52,80,87,106,121,79,50,65,13,10,97,81,57,66,115,108,65,122,74,71,114,56,110,51,76,104,113,110,114,120,117,102,78,98,47,85,69,56,54,109,50,66,69,51,102,112,83,116,98,109,71,57,66,110,98,97,52,78,120,56,73,50,69,85,84,121,110,101,104,49,98,72,70,121,87,67,85,111,121,79,73,103,106,98,120,79,13,10,111,47,81,49,73,121,104,87,53,116,52,98,98,105,80,109,74,104,71,72,13,10}, "utf-8");
    String exponent = new String(new byte[]{65,81,65,66,13,10}, "utf-8");
   
    RSAHelper helper = RSAHelper.getInstance(modulus, exponent);
    byte[] destBuf = helper.encryptByPrivateKey(src.getBytes("utf-8"));
   
    for(int i=0; i<destBuf.length; i++) {
      System.out.print(destBuf[i] + ",");
    }
  }
View Full Code Here

        SecureContext sc = global.getGlobalSecureContext(context.getChannel().getNettyChannel());
        //判断当前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

      // 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,
View Full Code Here

            throw new InvokerException(ioe.getMessage(), ioe.getCause());
        } catch (XMLStreamException xse) {
            throw new InvokerException(xse.getMessage(), xse.getCause());
        }
        executor = new SCXMLExecutor(evaluator, new SimpleDispatcher(), new SimpleErrorReporter());
        Context rootCtx = evaluator.newContext(null);
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            rootCtx.setLocal(entry.getKey(), entry.getValue());
        }
        executor.setRootContext(rootCtx);
        try {
            executor.setStateMachine(scxml);
        }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Set<Entry<String, Object>> entrySet() {
        Set<Entry<String, Object>> entrySet = new HashSet<Entry<String, Object>>();
        Context current = leaf;
        while (current != null) {
            entrySet.addAll(current.getVars().entrySet());
            current = current.getParent();
        }
        return entrySet;
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Object get(final Object key) {
        if (key != null) {
            Context current = leaf;
            while (current != null) {
                if (current.getVars().containsKey(key.toString())) {
                    return current.getVars().get(key);
                }
                current = current.getParent();
            }
        }
        return null;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public void execute(ActionExecutionContext exctx) throws ModelException, SCXMLExpressionException {
        Context ctx = exctx.getContext(getParentEnterableState());
        Evaluator eval = exctx.getEvaluator();
        ctx.setLocal(getNamespacesKey(), getNamespaces());
        exctx.getAppLog().info(label + ": " + String.valueOf(eval.eval(ctx, expr)));
        ctx.setLocal(getNamespacesKey(), null);
    }
View Full Code Here

TOP

Related Classes of com.bj58.argo.internal.DefaultArgoDispatcher$Context

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.