Search in sources :

Example 21 with MockSource

use of streamer.debug.MockSource in project cloudstack by apache.

the class ServerClipboardCapabilitiesPDU method main.

/**
     * 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");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_CLIP_CAPS (7)
    0x07, //  CLIPRDR_HEADER::msgType = CB_CLIP_CAPS (7)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::dataLen = 0x10 = 16 bytes
    0x10, //  CLIPRDR_HEADER::dataLen = 0x10 = 16 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x10 = 16 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x10 = 16 bytes
    0x00, //  CLIPRDR_CAPS::cCapabilitiesSets = 1
    0x01, //  CLIPRDR_CAPS::cCapabilitiesSets = 1
    0x00, //  CLIPRDR_CAPS::pad1
    0x00, //  CLIPRDR_CAPS::pad1
    0x00, //  CLIPRDR_CAPS_SET::capabilitySetType = CB_CAPSTYPE_GENERAL (1)
    0x01, //  CLIPRDR_CAPS_SET::capabilitySetType = CB_CAPSTYPE_GENERAL (1)
    0x00, //  CLIPRDR_CAPS_SET::lengthCapability = 0x0c = 12 bytes
    0x0c, //  CLIPRDR_CAPS_SET::lengthCapability = 0x0c = 12 bytes
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::version = CB_CAPS_VERSION_2 (2)
    0x02, //  CLIPRDR_GENERAL_CAPABILITY::version = CB_CAPS_VERSION_2 (2)
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::version = CB_CAPS_VERSION_2 (2)
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::version = CB_CAPS_VERSION_2 (2)
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::capabilityFlags = 0x0000000e = 0x02 |0x04 |0x08 = CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS
    0x0e, //  CLIPRDR_GENERAL_CAPABILITY::capabilityFlags = 0x0000000e = 0x02 |0x04 |0x08 = CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::capabilityFlags = 0x0000000e = 0x02 |0x04 |0x08 = CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS
    0x00, //  CLIPRDR_GENERAL_CAPABILITY::capabilityFlags = 0x0000000e = 0x02 |0x04 |0x08 = CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    Element clip_cap = new ServerClipboardCapabilitiesPDU("clip_cap", state);
    Element sink = new MockSink("sink", new ByteBuffer[] {});
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, clip_cap, sink);
    pipeline.link("source", "router >clipboard_capabilities", "clip_cap", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state
    if (!state.serverUseLongFormatNames || !state.serverStreamFileClipEnabled || !state.serverFileClipNoFilePaths || state.serverCanLockClipdata)
        throw new RuntimeException("Server clipboard capabilities packet parsed incorrectly.");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) Pipeline(streamer.Pipeline)

Example 22 with MockSource

use of streamer.debug.MockSource in project cloudstack by apache.

the class ServerFormatDataResponsePDU method main.

/**
     * 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");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_RESPONSE (5)
    0x05, //  CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_RESPONSE (5)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x01, //  CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x18, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x72, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x6c, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x64, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    state.serverRequestedFormat = new ClipboardDataFormat(ClipboardDataFormat.CB_FORMAT_UNICODETEXT, "");
    Element format_data_response = new ServerFormatDataResponsePDU("format_data_response", state);
    ByteBuffer clipboardAdapterPacket = new ByteBuffer(0);
    clipboardAdapterPacket.putMetadata(AwtClipboardAdapter.CLIPBOARD_CONTENT, "hello world");
    Element sink = new MockSink("sink", new ByteBuffer[] { clipboardAdapterPacket });
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, format_data_response, sink);
    pipeline.link("source", "router >format_data_response", "format_data_response >clipboard", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Example 23 with MockSource

use of streamer.debug.MockSource in project cloudstack by apache.

the class ServerFormatListPDU method main.

/**
     * 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");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_FORMAT_LIST (2)
    0x02, //  CLIPRDR_HEADER::msgType = CB_FORMAT_LIST (2)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::dataLen = 0xe0 = 224 bytes
    (byte) 0xe0, //  CLIPRDR_HEADER::dataLen = 0xe0 = 224 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0xe0 = 224 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0xe0 = 224 bytes
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc08a = 49290
    (byte) 0x8a, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc08a = 49290
    (byte) 0xc0, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc08a = 49290
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc08a = 49290
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x52, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x69, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x63, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x68, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x20, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x54, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x65, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x78, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x74, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x20, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x46, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x6f, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x72, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x6d, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x61, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x74, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc145 = 49477
    0x45, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc145 = 49477
    (byte) 0xc1, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc145 = 49477
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc145 = 49477
    0x00, 0x52, 0x00, 0x69, 0x00, 0x63, 0x00, 0x68, 0x00, 0x20, 0x00, 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x74, 0x00, 0x20, 0x00, 0x57, 0x00, 0x69, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x74, 0x00, 0x20, 0x00, 0x4f, 0x00, 0x62, 0x00, 0x6a, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x73, 0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format Without Objects"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Rich Text Format Without Objects"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc143 = 49475
    0x43, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc143 = 49475
    (byte) 0xc1, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc143 = 49475
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc143 = 49475
    0x00, 0x52, 0x00, 0x54, 0x00, 0x46, 0x00, 0x20, 0x00, 0x41, 0x00, 0x73, 0x00, 0x20, 0x00, 0x54, 0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x65, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x78, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x74, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "RTF As Text"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 1
    0x01, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 1
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 1
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 1
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0x0d = 13
    0x0d, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0x0d = 13
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0x0d = 13
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0x0d = 13
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc004 = 49156
    0x04, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc004 = 49156
    (byte) 0xc0, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc004 = 49156
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc004 = 49156
    0x00, //  "Native"
    0x4e, //  "Native"
    0x00, //  "Native"
    0x61, //  "Native"
    0x00, //  "Native"
    0x74, //  "Native"
    0x00, //  "Native"
    0x69, //  "Native"
    0x00, //  "Native"
    0x76, //  "Native"
    0x00, //  "Native"
    0x65, //  "Native"
    0x00, //  "Native"
    0x00, //  "Native"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc00e = 49166
    0x0e, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc00e = 49166
    (byte) 0xc0, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc00e = 49166
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 0xc00e = 49166
    0x00, 0x4f, 0x00, 0x62, 0x00, 0x6a, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, 0x44, 0x00, 0x65, 0x00, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x69, 0x00, 0x70, 0x00, 0x74, 0x00, 0x6f, 0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Object Descriptor"
    0x72, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Object Descriptor"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Object Descriptor"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = "Object Descriptor"
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 3
    0x03, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 3
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 3
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 3
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 16
    0x10, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 16
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 16
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 16
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 7
    0x07, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 7
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 7
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatId = 7
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00, //  CLIPRDR_LONG_FORMAT_NAME::formatName = ""
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    state.serverUseLongFormatNames = true;
    Element format_list = new ServerFormatListPDU("format_list", state);
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { // CLIPRDR_HEADER::msgType = CB_FORMAT_LIST_RESPONSE (3)
    0x03, // CLIPRDR_HEADER::msgType = CB_FORMAT_LIST_RESPONSE (3)
    0x00, // CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x01, // CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x00, // CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, // CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, // CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, // CLIPRDR_HEADER::dataLen = 0 bytes
    0x00 }, new byte[] { // CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_REQUEST (4)
    0x04, // CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_REQUEST (4)
    0x00, // CLIPRDR_HEADER::msgFlags = 0
    0x00, // CLIPRDR_HEADER::msgFlags = 0
    0x00, // CLIPRDR_HEADER::dataLen = 4 bytes
    0x04, // CLIPRDR_HEADER::dataLen = 4 bytes
    0x00, // CLIPRDR_HEADER::dataLen = 4 bytes
    0x00, // CLIPRDR_HEADER::dataLen = 4 bytes
    0x00, // CLIPRDR_FORMAT_DATA_REQUEST::requestedFormatId
    0x0d, // CLIPRDR_FORMAT_DATA_REQUEST::requestedFormatId
    0x00, // CLIPRDR_FORMAT_DATA_REQUEST::requestedFormatId
    0x00, // CLIPRDR_FORMAT_DATA_REQUEST::requestedFormatId
    0x00 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, format_list, sink);
    pipeline.link("source", "router >format_list", "format_list", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state
    if (!(state.serverClipboardDataFormats.containsKey(49475) && state.serverClipboardDataFormats.containsKey("Rich Text Format")))
        throw new RuntimeException("Server format list packet parsed incorrectly.");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) Pipeline(streamer.Pipeline)

Example 24 with MockSource

use of streamer.debug.MockSource in project cloudstack by apache.

the class ServerMonitorReadyPDU method main.

/**
     * 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");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_MONITOR_READY (1)
    0x01, //  CLIPRDR_HEADER::msgType = CB_MONITOR_READY (1)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    Element monitor_ready = new ServerMonitorReadyPDU("monitor_ready", state);
    Element sink = new MockSink("sink", new ByteBuffer[] {});
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, monitor_ready, sink);
    pipeline.link("source", "router >monitor_ready", "monitor_ready", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state
    if (!state.serverReady)
        throw new RuntimeException("Server monitor ready packet parsed incorrectly.");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) Pipeline(streamer.Pipeline)

Example 25 with MockSource

use of streamer.debug.MockSource in project cloudstack by apache.

the class ServerNtlmsspChallenge method main.

/**
     * 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");
    /* @formatter:off */
    byte[] packet = new byte[] { // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    (byte) 0x82, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x01, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x02, // TAG: [0] (constructed) LEN: 3 bytes
    (byte) 0xa0, // TAG: [0] (constructed) LEN: 3 bytes
    0x03, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x02, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x01, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x03, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0xa1, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0x81, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0xfa, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    (byte) 0xf7, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    (byte) 0xf4, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0xa0, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0x81, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0xf1, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    0x04, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    (byte) 0xee, // "NTLMSSP\0"
    0x4e, // "NTLMSSP\0"
    0x54, // "NTLMSSP\0"
    0x4c, // "NTLMSSP\0"
    0x4d, // "NTLMSSP\0"
    0x53, // "NTLMSSP\0"
    0x53, // "NTLMSSP\0"
    0x50, // "NTLMSSP\0"
    0x00, // MessageType (CHALLENGE)
    0x02, // MessageType (CHALLENGE)
    0x00, // MessageType (CHALLENGE)
    0x00, // MessageType (CHALLENGE)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x1e, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x1e, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x38, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // NegotiateFlags
    0x35, // NegotiateFlags
    (byte) 0x82, // NegotiateFlags
    (byte) 0x8a, // NegotiateFlags
    (byte) 0xe2, //  ServerChallenge
    0x52, //  ServerChallenge
    (byte) 0xbe, //  ServerChallenge
    (byte) 0x83, //  ServerChallenge
    (byte) 0xd1, //  ServerChallenge
    (byte) 0xf8, //  ServerChallenge
    (byte) 0x80, //  ServerChallenge
    0x16, //  ServerChallenge
    0x6a, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    (byte) 0x98, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    (byte) 0x98, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x56, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x06, // Version (6.3, build 9431) , NTLM current revision: 15
    0x03, // Version (6.3, build 9431) , NTLM current revision: 15
    (byte) 0xd7, // Version (6.3, build 9431) , NTLM current revision: 15
    0x24, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x0f, // Target name value: "WIN-LO419B2LSR0"
    0x57, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x49, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4e, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x2d, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4c, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4f, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x34, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x31, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x39, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x42, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x32, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4c, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x53, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x52, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x30, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Item Type: NetBIOS domain name (0x0002, LE)
    0x02, // Item Type: NetBIOS domain name (0x0002, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, //  Item Type: NetBIOS computer name (0x0001, LE)
    0x01, //  Item Type: NetBIOS computer name (0x0001, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: DNS domain name (0x0004, LE)
    0x04, // Item Type: DNS domain name (0x0004, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: DNS computer name (0x0003, LE)
    0x03, // Item Type: DNS computer name (0x0003, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: Timestamp (0x0007, LE)
    0x07, // Item Type: Timestamp (0x0007, LE)
    0x00, //  Item Length: 8 (LE)
    0x08, //  Item Length: 8 (LE)
    0x00, // TODO
    (byte) 0x99, // TODO
    0x4f, // TODO
    0x02, // TODO
    (byte) 0xd8, // TODO
    (byte) 0xf4, // TODO
    (byte) 0xaf, // TODO
    (byte) 0xce, // TODO
    0x01, // Attribute: End of list
    0x00, 0x00, 0x00, 0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet, new byte[] { 1, 2, 3 }));
    NtlmState state = new NtlmState();
    Element ntlmssp_challenge = new ServerNtlmsspChallenge("ntlmssp_challenge", state);
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers());
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, ntlmssp_challenge, sink, mainSink);
    pipeline.link("source", "ntlmssp_challenge", "mainSink");
    pipeline.link("ntlmssp_challenge >" + OTOUT, "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state challenge
    byte[] challenge = new byte[] { 0x52, (byte) 0xbe, (byte) 0x83, (byte) 0xd1, (byte) 0xf8, (byte) 0x80, 0x16, 0x6a };
    if (state.serverChallenge == null)
        throw new RuntimeException("Challenge was not extracted from server NTLMSSP Challenge packet.");
    if (!Arrays.equals(challenge, state.serverChallenge))
        throw new RuntimeException("Challenge was extracted from server NTLMSSP Challenge packet is not equal to expected. Actual value: " + state.serverChallenge + ", expected value: " + challenge + ".");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Aggregations

Element (streamer.Element)25 Pipeline (streamer.Pipeline)25 PipelineImpl (streamer.PipelineImpl)25 MockSource (streamer.debug.MockSource)25 MockSink (streamer.debug.MockSink)24 BaseElement (streamer.BaseElement)10 ScreenDescription (common.ScreenDescription)5 ByteBuffer (streamer.ByteBuffer)5 FakeSink (streamer.debug.FakeSink)2 SSLState (streamer.ssl.SSLState)1