/** Example. */
  public static void main(String args[]) {

    try {
      System.setProperty("streamer.Link.debug", "true");
      System.setProperty("streamer.Element.debug", "true");
      System.setProperty("rdpclient.MockServer.debug", "true");

      Pipeline pipeline = new PipelineImpl("echo client");

      AprSocketWrapperImpl socketWrapper = new AprSocketWrapperImpl("socket", null);

      pipeline.add(socketWrapper);
      pipeline.add(new BaseElement("echo"));
      pipeline.add(new Queue("queue")); // To decouple input and output

      pipeline.link("socket", "echo", "queue", "socket");

      final byte[] mockData = new byte[] {0x01, 0x02, 0x03};
      MockServer server =
          new MockServer(
              new Packet[] {
                new Packet("Server hello") {
                  {
                    type = SERVER;
                    data = mockData;
                  }
                },
                new Packet("Client hello") {
                  {
                    type = CLIENT;
                    data = mockData;
                  }
                },
                new Packet("Server hello") {
                  {
                    type = SERVER;
                    data = mockData;
                  }
                },
                new Packet("Client hello") {
                  {
                    type = CLIENT;
                    data = mockData;
                  }
                }
              });
      server.start();
      InetSocketAddress address = server.getAddress();

      socketWrapper.connect(address);

    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }
Ejemplo n.º 2
0
  /** Example. */
  public static void main(String args[]) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");

    final String password = "******";

    Element source =
        new MockSource("source") {
          {
            bufs =
                ByteBuffer.convertByteArraysToByteBuffers(
                    // Request authentication and send 16 byte challenge
                    new byte[] {
                      0,
                      0,
                      0,
                      RfbConstants.VNC_AUTH,
                      1,
                      2,
                      3,
                      4,
                      5,
                      6,
                      7,
                      8,
                      9,
                      10,
                      11,
                      12,
                      13,
                      14,
                      15,
                      16
                    },
                    // Respond to challenge with AUTH_OK
                    new byte[] {0, 0, 0, RfbConstants.VNC_AUTH_OK});
          }
        };

    Element mainSink = new FakeSink("mainSink");
    final Vnc_3_3_Authentication auth = new Vnc_3_3_Authentication("auth", password);
    Element initSink =
        new MockSink("initSink") {
          {
            // Expect encoded password
            bufs =
                new ByteBuffer[] {
                  auth.encodePassword(
                      new ByteBuffer(
                          new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
                      password)
                };
          }
        };

    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, auth, mainSink);
    pipeline.add(initSink);
    pipeline.link("auth >otout", "initSink");

    pipeline.runMainLoop("source", STDOUT, false, false);
  }