You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/01/03 11:17:59 UTC

[26/50] [abbrv] CLOUDSTACK-5344: Updated to allow rdp console to access hyper-v vm virtual framebuffer.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpClient.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpClient.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpClient.java
old mode 100644
new mode 100755
index ef05eda..afde706
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpClient.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpClient.java
@@ -16,13 +16,50 @@
 // under the License.
 package rdpclient;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import rdpclient.adapter.AwtRdpKeyboardAdapter;
+import rdpclient.adapter.AwtRdpMouseAdapter;
+import rdpclient.hyperv.ClientPreConnectionBlob;
+import rdpclient.ntlmssp.ClientNtlmsspNegotiate;
+import rdpclient.ntlmssp.ClientNtlmsspPubKeyAuth;
+import rdpclient.ntlmssp.ClientNtlmsspUserCredentials;
+import rdpclient.ntlmssp.NtlmState;
+import rdpclient.ntlmssp.ServerNtlmsspChallenge;
+import rdpclient.ntlmssp.ServerNtlmsspPubKeyPlus1;
+import rdpclient.rdp.ClientConfirmActivePDU;
+import rdpclient.rdp.ClientFastPathPDU;
+import rdpclient.rdp.ClientInfoPDU;
+import rdpclient.rdp.ClientMCSAttachUserRequest;
+import rdpclient.rdp.ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs;
+import rdpclient.rdp.ClientMCSConnectInitial;
+import rdpclient.rdp.ClientMCSErectDomainRequest;
+import rdpclient.rdp.ClientTpkt;
+import rdpclient.rdp.ClientX224ConnectionRequestPDU;
+import rdpclient.rdp.ClientX224DataPDU;
+import rdpclient.rdp.RdpConstants;
+import rdpclient.rdp.RdpState;
+import rdpclient.rdp.ServerBitmapUpdate;
+import rdpclient.rdp.ServerDemandActivePDU;
+import rdpclient.rdp.ServerFastPath;
+import rdpclient.rdp.ServerIOChannelRouter;
+import rdpclient.rdp.ServerLicenseErrorPDUValidClient;
+import rdpclient.rdp.ServerMCSAttachUserConfirmPDU;
+import rdpclient.rdp.ServerMCSConnectResponse;
+import rdpclient.rdp.ServerMCSPDU;
+import rdpclient.rdp.ServerPaletteUpdate;
+import rdpclient.rdp.ServerX224ConnectionConfirmPDU;
+import rdpclient.rdp.ServerX224DataPdu;
 import streamer.PipelineImpl;
 import streamer.Queue;
-import common.AwtCanvasAdapter;
+import streamer.ssl.SSLState;
+import streamer.ssl.UpgradeSocketToSSL;
 import common.AwtKeyEventSource;
 import common.AwtMouseEventSource;
 import common.BufferedImageCanvas;
 import common.ScreenDescription;
+import common.adapter.AwtCanvasAdapter;
 
 public class RdpClient extends PipelineImpl {
 
@@ -31,12 +68,32 @@ public class RdpClient extends PipelineImpl {
      */
     private static final String HANDSHAKE_END = "server_valid_client";
 
-    public RdpClient(String id, String userName, ScreenDescription screen, BufferedImageCanvas canvas) {
+    /**
+     * Create new RDP or HyperV cli
+     *
+     * @param id
+     *          id of this element
+     * @param userName
+     *          user name
+     * @param password
+     *          password
+     * @param pcb
+     *          pre-connection blob for HyperV server or null/empty string to
+     *          disable. Usually, HyperV VM ID, e.g.
+     *          "39418F90-6D03-468E-B796-91C60DD6653A".
+     * @param screen
+     *          screen description to fill
+     * @param canvas
+     *          canvas to draw on
+     * @param sslState
+     */
+    public RdpClient(String id, String serverHostName, String domain, String userName, String password, String pcb, ScreenDescription screen,
+            BufferedImageCanvas canvas, SSLState sslState) {
         super(id);
-        assembleRDPPipeline(userName, screen, canvas);
+        assembleRDPPipeline(serverHostName, domain, userName, password, pcb, screen, canvas, sslState);
     }
 
-//  /* DEBUG */
+    // /* DEBUG */
 //  @Override
 //  protected HashMap<String, streamer.Element> initElementMap(String id) {
 //    HashMap<String, streamer.Element> map = new HashMap<String, streamer.Element>();
@@ -45,72 +102,195 @@ public class RdpClient extends PipelineImpl {
 //    return map;
 //  }
 
-    private void assembleRDPPipeline(String userName, ScreenDescription screen, BufferedImageCanvas canvas) {
+    /**
+     * Assemble connection sequence and main pipeline.
+     *
+     * Connection sequence for RDP w/o NLA: cookie(TPKT) SSL x224(TPKT)
+     * main(FastPath).
+     *
+     * Connection sequence for RDP w NLA: cookie(TPKT) SSL credssp x224(TPKT)
+     * main(FastPath).
+     *
+     * Connection sequence for HyperV w NLA: pcb SSL credssp cookie(TPKT)
+     * x224(TPKT) main(FastPath).
+     */
+    protected void assembleRDPPipeline(String serverHostName, String domain, String userName, String password, String pcb, ScreenDescription screen,
+            BufferedImageCanvas canvas, SSLState sslState) {
+        // If preconnection blob with VM ID is specified, then we are connecting to
+        // HyperV server
+        boolean hyperv = (pcb != null && !pcb.isEmpty());
+        // HyperV server requires NLA (CredSSP/SPNEGO/NTLMSSP) to connect, because
+        // it cannot display login screen
+        boolean credssp = hyperv || (password != null && !password.isEmpty());
+
+        String workstation;
+        try {
+            workstation = InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException e) {
+            workstation = "workstation";
+        }
+
         //
         // Handshake chain
         //
 
         RdpState state = new RdpState();
-        int[] channelsToJoin = new int[] {RdpConstants.CHANNEL_RDPRDR, RdpConstants.CHANNEL_IO};
+        NtlmState ntlmState = new NtlmState();
+
+        int[] channelsToJoin = new int[] {RdpConstants.CHANNEL_IO,
+                // RdpConstants.CHANNEL_RDPRDR, // RDPRDR channel is not used in current
+                // version
+
+                // RdpConstants .CHANNEL_CLIPRDR // Clipboard channel is refused to join :-/
+        };
 
         // Add elements
 
-        add(
+        // If pre-connection blob is specified, then add element to send it as
+        // first packet
+        if (hyperv) {
+            add(new ClientPreConnectionBlob("pcb", pcb));
+        }
+
+        // If password is specified, then use CredSSP/NTLM (NTLMSSP)
+        int protocol = RdpConstants.RDP_NEG_REQ_PROTOCOL_SSL;
+        if (credssp) {
+            protocol = RdpConstants.RDP_NEG_REQ_PROTOCOL_HYBRID;
+
+            add(
+                    new ClientNtlmsspNegotiate("client_ntlmssp_nego", ntlmState),
+
+                    new ServerNtlmsspChallenge("server_ntlmssp_challenge", ntlmState),
+
+                    new ClientNtlmsspPubKeyAuth("client_ntlmssp_auth", ntlmState, sslState, serverHostName, domain, workstation, userName, password),
+
+                    new ServerNtlmsspPubKeyPlus1("server_ntlmssp_confirm", ntlmState),
+
+                    new ClientNtlmsspUserCredentials("client_ntlmssp_finish", ntlmState)
+
+                    );
+        }
+
+        add(new ClientX224ConnectionRequestPDU("client_connection_req", userName, protocol), new ServerX224ConnectionConfirmPDU("server_connection_conf"),
+                new UpgradeSocketToSSL("upgrade_to_ssl"),
+
+                new ClientMCSConnectInitial("client_initial_conference_create"), new ServerMCSConnectResponse("server_initial_conference_create"),
 
-            new ClientX224ConnectionRequestPDU("client_connection_req", userName), new ServerX224ConnectionConfirmPDU("server_connection_conf"),
+                new ClientMCSErectDomainRequest("client_erect_domain"),
 
-            new UpgradeSocketToSSL("upgrade_to_ssl"),
+                new ClientMCSAttachUserRequest("client_atach_user"), new ServerMCSAttachUserConfirmPDU("server_atach_user_confirm", state),
 
-            new ClientMCSConnectInitial("client_initial_conference_create"), new ServerMCSConnectResponse("server_initial_conference_create"),
+                new ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs("client_channel_join_rdprdr", channelsToJoin, state),
 
-            new ClientMCSErectDomainRequest("client_erect_domain"),
+                new ClientInfoPDU("client_info_req", userName),
 
-            new ClientMCSAttachUserRequest("client_atach_user"), new ServerMCSAttachUserConfirmPDU("server_atach_user_confirm", state),
+                new ServerLicenseErrorPDUValidClient("server_valid_client"),
 
-            new ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs("client_channel_join_rdprdr", channelsToJoin, state),
+                new ServerFastPath("server_fastpath"),
 
-            new ClientInfoPDU("client_info_req", userName),
+                // new ServerTpkt("server_tpkt"),
 
-            new ServerLicenseErrorPDUValidClient("server_valid_client"),
+                new ServerX224DataPdu("server_x224_data"),
 
-            new ServerFastPath("server_fastpath"),
+                // These TPKT and X224 wrappers are connected directly to OUT for
+                // handshake sequence
+                new ClientTpkt("client_tpkt_ot"),
 
-            new ServerTpkt("server_tpkt"),
+                new ClientX224DataPDU("client_x224_data_ot")
 
-            new ServerX224DataPdu("server_x224_data"),
+                );
 
-            // These TPKT and X224 wrappers are connected directly to OUT for handshake
-            // sequence
-            new ClientTpkt("client_tpkt_ot"),
+        // If HyperV VM ID is set, then insert element which will send VM ID as
+        // first packet of connection, before other packets
+        if (hyperv) {
 
-            new ClientX224DataPdu("client_x224_data_ot")
+            // HyperV: pcb SSL credssp cookie x224 main.
 
-        );
+            link("IN",
 
-        // Handshake sequence (via SlowPath)
-        link("IN",
+                    // Pre Connection Blob
+                    "pcb",
 
-            "server_fastpath >tpkt", "server_tpkt",
+                    // Main (will be used after connection seq) or tpkt (to X224)
+                    "server_fastpath >tpkt",
 
-            "client_connection_req", "server_connection_conf",
+                    // SSL
+                    "upgrade_to_ssl",
 
-            "upgrade_to_ssl",
+                    // CredSSP
+                    "client_ntlmssp_nego", "server_ntlmssp_challenge", "client_ntlmssp_auth", "server_ntlmssp_confirm", "client_ntlmssp_finish",
+
+                    // Cookie
+                    "client_connection_req", "server_connection_conf",
+
+                    // X224
+                    "client_initial_conference_create");
+
+            for (String element : new String[] {"pcb", "client_ntlmssp_nego", "server_ntlmssp_challenge", "client_ntlmssp_auth", "server_ntlmssp_confirm",
+            "client_ntlmssp_finish"}) {
+                link(element + " >otout", element + "< OUT");
+
+            }
+
+        } else {
+
+            // RDP: cookie SSL (credssp) x224 main.
+
+            link("IN",
+
+                    // Main or tpkt
+                    "server_fastpath >tpkt",
+
+                    // Cookie
+                    "client_connection_req", "server_connection_conf",
+
+                    // SSL
+                    "upgrade_to_ssl");
+
+            if (credssp) {
+                // SSL
+                link("upgrade_to_ssl",
+
+                        // CredSSP
+                        "client_ntlmssp_nego", "server_ntlmssp_challenge", "client_ntlmssp_auth", "server_ntlmssp_confirm", "client_ntlmssp_finish",
+
+                        // X224
+                        "client_initial_conference_create");
+
+                for (String element : new String[] {"client_ntlmssp_nego", "server_ntlmssp_challenge", "client_ntlmssp_auth", "server_ntlmssp_confirm",
+                "client_ntlmssp_finish"}) {
+                    link(element + " >otout", element + "< OUT");
+
+                }
+
+            } else {
+
+                link(
+                        // SSL
+                        "upgrade_to_ssl",
+
+                        // X224
+                        "client_initial_conference_create");
+            }
+        }
 
-            "client_initial_conference_create", "server_initial_conference_create",
+        link(
+                // X224
+                "client_initial_conference_create", "server_initial_conference_create",
 
-            "client_erect_domain",
+                "client_erect_domain",
 
-            "server_x224_data",
+                "server_x224_data",
 
-            "client_atach_user", "server_atach_user_confirm",
+                "client_atach_user", "server_atach_user_confirm",
 
-            "client_channel_join_rdprdr",
+                "client_channel_join_rdprdr",
 
-            "client_info_req",
+                "client_info_req",
 
-            "server_valid_client"
+                "server_valid_client"
 
-        );
+                );
 
         // Chain for direct handshake responses (without involving of queue)
         link("client_x224_data_ot", "client_tpkt_ot", "client_tpkt_ot< OUT");
@@ -122,8 +302,7 @@ public class RdpClient extends PipelineImpl {
         }
 
         // Connect one time outputs to client X224 input
-        String x224_peers[] =
-            new String[] {"client_initial_conference_create", "server_initial_conference_create", "client_erect_domain", "client_atach_user",
+        String x224_peers[] = new String[] {"client_initial_conference_create", "server_initial_conference_create", "client_erect_domain", "client_atach_user",
                 "server_atach_user_confirm", "client_channel_join_rdprdr", "client_info_req", "server_valid_client"};
         for (String element : x224_peers) {
             link(element + " >otout", element + "< client_x224_data_ot");
@@ -134,13 +313,13 @@ public class RdpClient extends PipelineImpl {
         //
 
         add(
-            // To transfer packets between input threads and output thread.
-            new Queue("queue"),
+                // To transfer packets between input threads and output thread.
+                new Queue("queue"),
 
-            // Slow path: MultiChannel Support
-            new ServerMCSPDU("server_mcs")
+                // Slow path: MultiChannel Support
+                new ServerMCSPDU("server_mcs")
 
-        );
+                );
 
         // Last element of handshake sequence will wake up queue and and socket
         // output pull loop, which will switch links, between socket output and
@@ -165,38 +344,38 @@ public class RdpClient extends PipelineImpl {
         // Add elements
         add(
 
-            new ServerChannel1003Router("server_channel_1003", state),
+                new ServerIOChannelRouter("server_io_channel", state),
 
-            new ServerDemandActivePDU("server_demand_active", screen, state),
+                new ServerDemandActivePDU("server_demand_active", screen, state),
 
-            new ClientConfirmActivePDU("client_confirm_active", screen, state),
+                new ClientConfirmActivePDU("client_confirm_active", screen, state),
 
-            new ServerBitmapUpdate("server_bitmap_update"),
+                new ServerBitmapUpdate("server_bitmap_update"),
 
-            new AwtCanvasAdapter("canvas_adapter", canvas, screen),
+                new AwtCanvasAdapter("canvas_adapter", canvas, screen),
 
-            new ServerPaletteUpdate("server_palette", screen),
+                new ServerPaletteUpdate("server_palette", screen),
 
-            keyEventSource, new AwtRdpKeyboardAdapter("keyboard_adapter"),
+                keyEventSource, new AwtRdpKeyboardAdapter("keyboard_adapter"),
 
-            mouseEventSource, new AwtRdpMouseAdapter("mouse_adapter"),
+                mouseEventSource, new AwtRdpMouseAdapter("mouse_adapter"),
 
-            // These FastPath, TPKT, and X224 wrappers are connected to queue
-            new ClientTpkt("client_tpkt_queue"),
+                // These FastPath, TPKT, and X224 wrappers are connected to queue
+                new ClientTpkt("client_tpkt_queue"),
 
-            new ClientX224DataPdu("client_x224_data_queue"),
+                new ClientX224DataPDU("client_x224_data_queue"),
 
-            new ClientFastPathPDU("client_fastpath_queue"));
+                new ClientFastPathPDU("client_fastpath_queue"));
 
         // Server packet handlers
-        link("server_mcs >channel_1003", "server_channel_1003");
+        link("server_mcs >channel_1003", "server_io_channel");
         link("server_fastpath >bitmap", "fastpath< server_bitmap_update", "server_bitmap_update< canvas_adapter");
-        link("server_channel_1003 >bitmap", "slowpath< server_bitmap_update");
+        link("server_io_channel >bitmap", "slowpath< server_bitmap_update");
 
         link("server_fastpath >palette", "fastpath< server_palette");
-        link("server_channel_1003 >palette", "slowpath< server_palette");
+        link("server_io_channel >palette", "slowpath< server_palette");
 
-        link("server_channel_1003 >demand_active", "slowpath< server_demand_active");
+        link("server_io_channel >demand_active", "slowpath< server_demand_active");
         // link("server_demand_active >confirm_active", "client_confirm_active",
         // "confirm_active< client_channel_1003");
         link("server_demand_active >confirm_active", "client_confirm_active", "confirm_active< client_x224_data_queue");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpConstants.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpConstants.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpConstants.java
deleted file mode 100644
index 3da1328..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpConstants.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import java.nio.charset.Charset;
-
-public interface RdpConstants {
-
-    /**
-     * Default charset to use when communicating with server using 8 bit strings.
-     */
-    public static final Charset CHARSET_8 = Charset.availableCharsets().get("US-ASCII");
-
-    /**
-     * Default charset to use when communicating with server using 16 bit strings.
-     */
-    public static final Charset CHARSET_16 = Charset.availableCharsets().get("UTF-16LE");
-
-    /**
-     * Negotiate SSL protocol to use to protect RDP connection.
-     * @see http://msdn.microsoft.com/en-us/library/cc240500.aspx
-     */
-    public static final int RDP_NEG_REQ_PROTOCOL_SSL = 1;
-
-    /**
-     * Negotiate CredSSP protocol to use to protect RDP connection.
-     * @see http://msdn.microsoft.com/en-us/library/cc240500.aspx
-     * When used, client must set @see RDP_NEG_REQ_PROTOCOL_SSL too.
-     */
-    public static final int RDP_NEG_REQ_PROTOCOL_HYBRID = 2;
-
-    /**
-     * RDP negotiation: flags (not used, always 0).
-     */
-    public static final int RDP_NEG_REQ_FLAGS = 0;
-
-    /**
-     * RDP Negotiation: request.
-     */
-    public static final int RDP_NEG_REQ_TYPE_NEG_REQ = 1;
-
-    /**
-     * RDP Negotiation: response.
-     */
-    public static final int RDP_NEG_REQ_TYPE_NEG_RSP = 2;
-
-    /**
-     * RDP Negotiation: failure.
-     */
-    public static final int RDP_NEG_REQ_TYPE_NEG_FAILURE = 3;
-
-    public static final int CHANNEL_IO = 1003;
-
-    public static final int CHANNEL_RDPRDR = 1004;
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpState.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpState.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpState.java
deleted file mode 100644
index 951f0be..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/RdpState.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class RdpState {
-
-    public long serverShareId;
-    public int serverUserChannelId;
-
-    public Set<Integer> channels = new HashSet<Integer>();
-
-    public void channelJoined(int actualChannel) {
-        channels.add(actualChannel);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerBitmapUpdate.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerBitmapUpdate.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerBitmapUpdate.java
deleted file mode 100644
index 5c30b69..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerBitmapUpdate.java
+++ /dev/null
@@ -1,200 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import streamer.BaseElement;
-import streamer.ByteBuffer;
-import streamer.Element;
-import streamer.FakeSink;
-import streamer.Link;
-import streamer.Pipeline;
-import streamer.PipelineImpl;
-import common.BitmapOrder;
-import common.BitmapRectangle;
-
-/**
- * @see http://msdn.microsoft.com/en-us/library/cc240624.aspx
- */
-public class ServerBitmapUpdate extends BaseElement {
-    public static final int UPDATETYPE_BITMAP = 0x0001;
-
-    /**
-     * Indicates that the bitmap data is compressed. The bitmapComprHdr field MUST
-     * be present if the NO_BITMAP_COMPRESSION_HDR (0x0400) flag is not set.
-     */
-    public static final int BITMAP_COMPRESSION = 0x0001;
-
-    /**
-     * Indicates that the bitmapComprHdr field is not present (removed for
-     * bandwidth efficiency to save 8 bytes).
-     */
-    private static final int NO_BITMAP_COMPRESSION_HDR = 0x0400;
-
-    public ServerBitmapUpdate(String id) {
-        super(id);
-    }
-
-    @Override
-    public void handleData(ByteBuffer buf, Link link) {
-
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        // * DEBUG */System.out.println(buf.toHexString(buf.length));
-
-        BitmapOrder order = new BitmapOrder();
-
-        // (2 bytes): A 16-bit, unsigned integer. The update type. This field MUST
-        // be set to UPDATETYPE_BITMAP (0x0001).
-        int updateType = buf.readSignedShortLE();
-        if (updateType != UPDATETYPE_BITMAP)
-            throw new RuntimeException("Unknown update type. Expected update type: UPDATETYPE_BITMAP (0x1). Actual update type: " + updateType + ", buf: " + buf + ".");
-
-        // (2 bytes): A 16-bit, unsigned integer. The number of screen rectangles
-        // present in the rectangles field.
-        int numberRectangles = buf.readSignedShortLE();
-
-        // (variable): Variable-length array of TS_BITMAP_DATA structures, each of
-        // which contains a rectangular clipping taken from the server-side screen
-        // frame buffer. The number of screen clippings in the array is specified by
-        // the numberRectangles field.
-        BitmapRectangle[] rectangles = new BitmapRectangle[numberRectangles];
-        for (int i = 0; i < numberRectangles; i++) {
-            rectangles[i] = readRectangle(buf);
-        }
-        order.rectangles = rectangles;
-
-        buf.assertThatBufferIsFullyRead();
-
-        ByteBuffer data = new ByteBuffer(0);
-        data.setOrder(order);
-        pushDataToAllOuts(data);
-
-        buf.unref();
-    }
-
-    public BitmapRectangle readRectangle(ByteBuffer buf) {
-
-        BitmapRectangle rectangle = new BitmapRectangle();
-
-        // (2 bytes): A 16-bit, unsigned integer. Left bound of the rectangle.
-        rectangle.x = buf.readSignedShortLE();
-
-        // (2 bytes): A 16-bit, unsigned integer. Top bound of the rectangle.
-        rectangle.y = buf.readSignedShortLE();
-
-        // (2 bytes): A 16-bit, unsigned integer. Inclusive right bound of the
-        // rectangle.
-        int destRight = buf.readSignedShortLE();
-        rectangle.width = destRight - rectangle.x + 1;
-
-        // (2 bytes): A 16-bit, unsigned integer. Inclusive bottom bound of the
-        // rectangle.
-        int destBottom = buf.readSignedShortLE();
-        rectangle.height = destBottom - rectangle.y + 1;
-
-        // (2 bytes): A 16-bit, unsigned integer. The width of the rectangle.
-        rectangle.bufferWidth = buf.readSignedShortLE();
-
-        // (2 bytes): A 16-bit, unsigned integer. The height of the rectangle.
-        rectangle.bufferHeight = buf.readSignedShortLE();
-
-        // (2 bytes): A 16-bit, unsigned integer. The color depth of the rectangle
-        // data in bits-per-pixel.
-        rectangle.colorDepth = buf.readSignedShortLE();
-
-        // (2 bytes): A 16-bit, unsigned integer. The flags describing the format of
-        // the bitmap data in the bitmapDataStream field.
-        int flags = buf.readSignedShortLE();
-
-        // BITMAP_COMPRESSION 0x0001
-        // Indicates that the bitmap data is compressed. The bitmapComprHdr field
-        // MUST be present if the NO_BITMAP_COMPRESSION_HDR (0x0400) flag is not
-        // set.
-        boolean compressed = ((flags & BITMAP_COMPRESSION) > 0);
-
-        // (2 bytes): A 16-bit, unsigned integer. The size in bytes of the data in
-        // the bitmapComprHdr and bitmapDataStream fields.
-        int bitmapLength = buf.readSignedShortLE();
-
-        // NO_BITMAP_COMPRESSION_HDR 0x0400
-        // Indicates that the bitmapComprHdr field is not present (removed for
-        // bandwidth efficiency to save 8 bytes).
-        if (compressed && (flags & NO_BITMAP_COMPRESSION_HDR) == 0) {
-            // (8 bytes): Optional Compressed Data Header structure specifying the
-            // bitmap data in the bitmapDataStream.
-            // This field MUST be present if the BITMAP_COMPRESSION (0x0001) flag is
-            // present in the Flags field, but the NO_BITMAP_COMPRESSION_HDR (0x0400)
-            // flag is not.
-
-            // Note: Even when compression header is enabled, server sends nothing.
-            // rectangle.compressedBitmapHeader = buf.readBytes(8);
-        }
-
-        // (variable): A variable-length array of bytes describing a bitmap image.
-        // Bitmap data is either compressed or uncompressed, depending on whether
-        // the BITMAP_COMPRESSION flag is present in the Flags field. Uncompressed
-        // bitmap data is formatted as a bottom-up, left-to-right series of pixels.
-        // Each pixel is a whole number of bytes. Each row contains a multiple of
-        // four bytes (including up to three bytes of padding, as necessary).
-        // Compressed bitmaps not in 32 bpp format are compressed using Interleaved
-        // RLE and encapsulated in an RLE Compressed Bitmap Stream structure,
-        // while compressed bitmaps at a color depth of 32 bpp are compressed
-        // using RDP 6.0 Bitmap Compression and stored inside
-        // an RDP 6.0 Bitmap Compressed Stream structure.
-        if (!compressed) {
-            rectangle.bitmapDataStream = buf.readBytes(bitmapLength);
-        } else {
-            ByteBuffer compressedImage = buf.readBytes(bitmapLength);
-            //* DEBUG */System.out.println("Compressed image: " + compressedImage + ", depth: " + rectangle.bitsPerPixel + ".");
-            rectangle.bitmapDataStream = RLEBitmapDecompression.rleDecompress(compressedImage, rectangle.bufferWidth, rectangle.bufferHeight, rectangle.colorDepth);
-            compressedImage.unref();
-        }
-
-        return rectangle;
-    }
-
-    /**
-     * Example.
-     */
-    public static void main(String args[]) {
-        ByteBuffer packet =
-            new ByteBuffer(new byte[] {0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x04, 0x0a,
-                0x00, 0x0c, (byte)0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
-
-        Element bitmap = new ServerBitmapUpdate("bitmap") {
-            {
-                verbose = true;
-            }
-        };
-        FakeSink fakeSink = new FakeSink("sink") {
-            {
-                verbose = true;
-            }
-        };
-        Pipeline pipeline = new PipelineImpl("test");
-
-        // BufferedImageCanvas canvas = new BufferedImageCanvas(1024, 768);
-        // Element adapter = new AwtRdpAdapter("test",canvas );
-        // pipeline.addAndLink(bitmap, adapter);
-        pipeline.addAndLink(bitmap, fakeSink);
-
-        bitmap.handleData(packet, null);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerChannel1003Router.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerChannel1003Router.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerChannel1003Router.java
deleted file mode 100644
index 1526edf..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerChannel1003Router.java
+++ /dev/null
@@ -1,533 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import streamer.BaseElement;
-import streamer.ByteBuffer;
-import streamer.Element;
-import streamer.Link;
-import streamer.MockSink;
-import streamer.MockSource;
-import streamer.Pipeline;
-import streamer.PipelineImpl;
-
-public class ServerChannel1003Router extends BaseElement {
-
-    /**
-     * Demand Active PDU.
-     */
-    public static final int PDUTYPE_DEMANDACTIVEPDU = 0x1;
-
-    /**
-     * Confirm Active PDU.
-     */
-    public static final int PDUTYPE_CONFIRMACTIVEPDU = 0x3;
-
-    /**
-     * Deactivate All PDU.
-     */
-    public static final int PDUTYPE_DEACTIVATEALLPDU = 0x6;
-
-    /**
-     * Data PDU (actual type is revealed by the pduType2 field in the Share Data
-     * Header).
-     */
-    public static final int PDUTYPE_DATAPDU = 0x7;
-
-    /**
-     * Enhanced Security Server Redirection PDU.
-     */
-    public static final int PDUTYPE_SERVER_REDIR_PKT = 0xA;
-
-    protected RdpState state;
-
-    public ServerChannel1003Router(String id, RdpState state) {
-        super(id);
-        this.state = state;
-    }
-
-    /**
-     * @see http://msdn.microsoft.com/en-us/library/cc240576.aspx
-     */
-    @Override
-    public void handleData(ByteBuffer buf, Link link) {
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        int length = buf.readUnsignedShortLE();
-        if (buf.length != length) {
-            // It is ServerErrorAlert-ValidClient
-            // Ignore it
-            //throw new RuntimeException("[" + this + "] ERROR: Incorrect PDU length: " + length + ", data: " + buf + ".");
-        }
-
-        int type = buf.readUnsignedShortLE() & 0xf;
-
-        // int sourceId = buf.readUnsignedShortLE();
-        buf.skipBytes(2);
-
-        switch (type) {
-            case PDUTYPE_DEMANDACTIVEPDU:
-                pushDataToPad("demand_active", buf);
-                break;
-            case PDUTYPE_CONFIRMACTIVEPDU:
-                throw new RuntimeException("Unexpected client CONFIRM ACTIVE PDU. Data: " + buf + ".");
-            case PDUTYPE_DEACTIVATEALLPDU:
-                // pushDataToPad("deactivate_all", buf);
-                /* ignore */buf.unref();
-                break;
-            case PDUTYPE_DATAPDU:
-                handleDataPdu(buf);
-                break;
-            case PDUTYPE_SERVER_REDIR_PKT:
-                // pushDataToPad("server_redir", buf);
-                /* ignore */buf.unref();
-                break;
-            default:
-                throw new RuntimeException("[" + this + "] ERROR: Unknown PDU type: " + type + ", data: " + buf + ".");
-        }
-
-    }
-
-    /**
-     * Graphics Update PDU.
-     */
-    public static final int PDUTYPE2_UPDATE = 0x02;
-
-    /**
-     * Control PDU.
-     */
-    public static final int PDUTYPE2_CONTROL = 0x14;
-
-    /**
-     * Pointer Update PDU.
-     */
-    public static final int PDUTYPE2_POINTER = 0x1B;
-
-    /**
-     * Input Event PDU.
-     */
-    public static final int PDUTYPE2_INPUT = 0x1C;
-
-    /**
-     * Synchronize PDU.
-     */
-    public static final int PDUTYPE2_SYNCHRONIZE = 0x1F;
-
-    /**
-     * Refresh Rect PDU.
-     */
-    public static final int PDUTYPE2_REFRESH_RECT = 0x21;
-
-    /**
-     * Play Sound PDU.
-     */
-    public static final int PDUTYPE2_PLAY_SOUND = 0x22;
-
-    /**
-     * Suppress Output PDU.
-     */
-    public static final int PDUTYPE2_SUPPRESS_OUTPUT = 0x23;
-
-    /**
-     * Shutdown Request PDU.
-     */
-    public static final int PDUTYPE2_SHUTDOWN_REQUEST = 0x24;
-
-    /**
-     * Shutdown Request Denied PDU.
-     */
-    public static final int PDUTYPE2_SHUTDOWN_DENIED = 0x25;
-
-    /**
-     * Save Session Info PDU.
-     */
-    public static final int PDUTYPE2_SAVE_SESSION_INFO = 0x26;
-
-    /**
-     * Font List PDU.
-     */
-    public static final int PDUTYPE2_FONTLIST = 0x27;
-
-    /**
-     * Font Map PDU.
-     */
-    public static final int PDUTYPE2_FONTMAP = 0x28;
-
-    /**
-     * Set Keyboard Indicators PDU.
-     */
-    public static final int PDUTYPE2_SET_KEYBOARD_INDICATORS = 0x29;
-
-    /**
-     * Persistent Key List PDU.
-     */
-    public static final int PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST = 0x2B;
-
-    /**
-     * Bitmap Cache Error PDU.
-     */
-    public static final int PDUTYPE2_BITMAPCACHE_ERROR_PDU = 0x2C;
-
-    /**
-     * Set Keyboard IME Status PDU.
-     */
-    public static final int PDUTYPE2_SET_KEYBOARD_IME_STATUS = 0x2D;
-
-    /**
-     * Offscreen Bitmap Cache Error PDU.
-     */
-    public static final int PDUTYPE2_OFFSCRCACHE_ERROR_PDU = 0x2E;
-
-    /**
-     * Set Error Info PDU.
-     */
-    public static final int PDUTYPE2_SET_ERROR_INFO_PDU = 0x2F;
-
-    /**
-     * DrawNineGrid Cache Error PDU.
-     */
-    public static final int PDUTYPE2_DRAWNINEGRID_ERROR_PDU = 0x30;
-
-    /**
-     * GDI+ Error PDU.
-     */
-    public static final int PDUTYPE2_DRAWGDIPLUS_ERROR_PDU = 0x31;
-
-    /**
-     * Auto-Reconnect Status PDU.
-     */
-    public static final int PDUTYPE2_ARC_STATUS_PDU = 0x32;
-
-    /**
-     * Status Info PDU.
-     */
-    public static final int PDUTYPE2_STATUS_INFO_PDU = 0x36;
-
-    /**
-     * Monitor Layout PDU.
-     */
-    public static final int PDUTYPE2_MONITOR_LAYOUT_PDU = 0x37;
-
-    /**
-     * Indicates an Orders Update.
-     */
-    public static final int UPDATETYPE_ORDERS = 0x0000;
-
-    /**
-     * Indicates a Bitmap Graphics Update.
-     */
-    public static final int UPDATETYPE_BITMAP = 0x0001;
-
-    /**
-     * Indicates a Palette Update.
-     */
-    public static final int UPDATETYPE_PALETTE = 0x0002;
-
-    /**
-     * Indicates a Synchronize Update.
-     */
-    public static final int UPDATETYPE_SYNCHRONIZE = 0x0003;
-
-    /**
-     * @see http://msdn.microsoft.com/en-us/library/cc240577.aspx
-     */
-    protected void handleDataPdu(ByteBuffer buf) {
-
-        // (4 bytes): A 32-bit, unsigned integer. Share identifier for the packet.
-        long shareId = buf.readUnsignedIntLE();
-        if (shareId != state.serverShareId)
-            throw new RuntimeException("Unexpected share ID: " + shareId + ".");
-//    buf.skipBytes(4);
-
-        // Padding.
-        buf.skipBytes(1);
-
-        // (1 byte): An 8-bit, unsigned integer. The stream identifier for the
-        // packet.
-        // int streamId = buf.readUnsignedByte();
-        buf.skipBytes(1);
-
-        // (2 bytes): A 16-bit, unsigned integer. The uncompressed length of the
-        // packet in bytes.
-        int uncompressedLength = buf.readUnsignedShortLE();
-
-        // (1 byte): An 8-bit, unsigned integer. The type of Data PDU.
-        int type2 = buf.readUnsignedByte();
-
-        // (1 byte): An 8-bit, unsigned integer. The compression type and flags
-        // specifying the data following the Share Data Header
-        int compressedType = buf.readUnsignedByte();
-        if (compressedType != 0)
-            throw new RuntimeException("Compression of protocol packets is not supported. Data: " + buf + ".");
-
-        // (2 bytes): A 16-bit, unsigned integer. The compressed length of the
-        // packet in bytes.
-        int compressedLength = buf.readUnsignedShortLE();
-        if (compressedLength != 0)
-            throw new RuntimeException("Compression of protocol packets is not supported. Data: " + buf + ".");
-
-        ByteBuffer data = buf.readBytes(uncompressedLength - 18);
-        buf.unref();
-
-        switch (type2) {
-
-            case PDUTYPE2_UPDATE: {
-
-                // (2 bytes): A 16-bit, unsigned integer. Type of the graphics update.
-                int updateType = data.readUnsignedShortLE();
-                ByteBuffer data2 = data.readBytes(data.length - data.cursor);
-                data.unref();
-
-                switch (updateType) {
-                    case UPDATETYPE_ORDERS:
-                        pushDataToPad("orders", data2);
-                        break;
-                    case UPDATETYPE_BITMAP:
-                        pushDataToPad("bitmap", data2);
-                        break;
-                    case UPDATETYPE_PALETTE:
-                        pushDataToPad("palette", data2);
-                        break;
-                    case UPDATETYPE_SYNCHRONIZE:
-                        // Ignore
-                        data2.unref();
-                        break;
-                }
-
-                break;
-            }
-            case PDUTYPE2_CONTROL:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_CONTROL ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_POINTER:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_POINTER ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_INPUT:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_INPUT ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SYNCHRONIZE:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SYNCHRONIZE ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_REFRESH_RECT:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_REFRESH_RECT ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_PLAY_SOUND:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_PLAY_SOUND ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SUPPRESS_OUTPUT:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SUPPRESS_OUTPUT ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SHUTDOWN_REQUEST:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SHUTDOWN_REQUEST ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SHUTDOWN_DENIED:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SHUTDOWN_DENIED ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SAVE_SESSION_INFO:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SAVE_SESSION_INFO ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_FONTLIST:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_FONTLIST ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_FONTMAP:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_FONTMAP ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SET_KEYBOARD_INDICATORS:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_KEYBOARD_INDICATORS ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_BITMAPCACHE_ERROR_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_BITMAPCACHE_ERROR_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SET_KEYBOARD_IME_STATUS:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_KEYBOARD_IME_STATUS ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_OFFSCRCACHE_ERROR_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_OFFSCRCACHE_ERROR_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_SET_ERROR_INFO_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_ERROR_INFO_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_DRAWNINEGRID_ERROR_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_DRAWNINEGRID_ERROR_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_DRAWGDIPLUS_ERROR_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_DRAWGDIPLUS_ERROR_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_ARC_STATUS_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_ARC_STATUS_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_STATUS_INFO_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_STATUS_INFO_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-            case PDUTYPE2_MONITOR_LAYOUT_PDU:
-                if (verbose)
-                    System.out.println("[" + this + "] INFO: Packet PDUTYPE2_MONITOR_LAYOUT_PDU ignored.");
-                // Ignore
-                data.unref();
-                break;
-
-            default:
-                throw new RuntimeException("Unknow data PDU type: " + type2 + ", data: " + buf + ".");
-        }
-    }
-
-    /**
-     * 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");
-
-        byte[] packet = new byte[] {
-            // TPKT
-            (byte)0x03, (byte)0x00, // TPKT Header: TPKT version = 3
-            (byte)0x00, (byte)0x1B, // TPKT length: 27 bytes
-
-            // X224
-            (byte)0x02, // X224 Length: 2 bytes
-            (byte)0xF0, // X224 Type: Data
-            (byte)0x80, // X224 EOT
-
-            // MCS
-            // Type: send data indication: 26 (0x1a, top 6 bits)
-            (byte)0x68, // ??
-
-            (byte)0x00, (byte)0x01, // User ID: 1002 (1001+1)
-            (byte)0x03, (byte)0xEB, // Channel ID: 1003
-            (byte)0x70, // Data priority: high, segmentation: begin|end
-            (byte)0x0D, // Payload length: 13 bytes
-
-            // Deactivate all PDU
-            (byte)0x0D, (byte)0x00, // Length: 13 bytes (LE)
-
-            // - PDUType: (0x16, LE)
-            // Type: (............0110) TS_PDUTYPE_DEACTIVATEALLPDU
-            // ProtocolVersion: (000000000001....) 1
-            (byte)0x16, (byte)0x00,
-
-            (byte)0xEA, (byte)0x03, // PDU source: 1002 (LE)
-            (byte)0xEA, (byte)0x03, (byte)0x01, (byte)0x00, // ShareID = 66538
-
-            (byte)0x01, (byte)0x00, // Length if source descriptor: 1 (LE)
-            (byte)0x00, // Source descriptor (should be set to 0): 0
-        };
-
-        MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
-        RdpState rdpState = new RdpState() {
-            {
-                serverShareId = 66538;
-            }
-        };
-        Element channel1003 = new ServerChannel1003Router("channel_1003", rdpState);
-        Element mcs = new ServerMCSPDU("mcs");
-        Element tpkt = new ServerTpkt("tpkt");
-        Element x224 = new ServerX224DataPdu("x224");
-        Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {
-            // Deactivate all PDU
-            (byte)0x0D, (byte)0x00, // Length: 13 bytes (LE)
-
-            // - PDUType: 22 (0x16, LE)
-            // Type: (............0110) TS_PDUTYPE_DEACTIVATEALLPDU
-            // ProtocolVersion: (000000000001....) 1
-            (byte)0x16, (byte)0x00,
-
-            (byte)0xEA, (byte)0x03, // PDU source: 1002 (LE)
-            (byte)0xEA, (byte)0x03, (byte)0x01, (byte)0x00, // ShareID = 66538
-
-            (byte)0x01, (byte)0x00, // Length if source descriptor: 1 (LE)
-            (byte)0x00, // Source descriptor (should be set to 0): 0
-        }));
-
-        Pipeline pipeline = new PipelineImpl("test");
-        pipeline.add(source, tpkt, x224, mcs, channel1003, sink);
-        pipeline.link("source", "tpkt", "x224", "mcs >channel_1003", "channel_1003 >deactivate_all", "sink");
-        pipeline.runMainLoop("source", STDOUT, false, false);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUCooperate.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUCooperate.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUCooperate.java
deleted file mode 100644
index 7bbe0c3..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUCooperate.java
+++ /dev/null
@@ -1,117 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import streamer.ByteBuffer;
-import streamer.Link;
-import streamer.OneTimeSwitch;
-
-public class ServerControlPDUCooperate extends OneTimeSwitch {
-
-    public ServerControlPDUCooperate(String id) {
-        super(id);
-    }
-
-    @Override
-    protected void handleOneTimeData(ByteBuffer buf, Link link) {
-        if (buf == null)
-            return;
-
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        // Ignore packet
-        buf.unref();
-        switchOff();
-    }
-
-}
-
-/* @formatter:off */
-/*
-03 00 00 28 02 F0 80 68 00 01 03 EB 70 1A 1A 00 17 00 EA 03 EA 03 01 00 9A 02 1A 00 14 00 00 00 04 00 00 00 00 00 00 00
-
-
-  Frame: Number = 38, Captured Frame Length = 97, MediaType = DecryptedPayloadHeader
-+ DecryptedPayloadHeader: FrameCount = 1, ErrorStatus = SUCCESS
-  TLSSSLData: Transport Layer Security (TLS) Payload Data
-+ TLS: TLS Rec Layer-1 SSL Application Data
-  ISOTS: TPKTCount = 1
-- TPKT: version: 3, Length: 40
-    version: 3 (0x3)
-    Reserved: 0 (0x0)
-    PacketLength: 40 (0x28)
-- X224: Data
-    Length: 2 (0x2)
-    Type: Data
-    EOT: 128 (0x80)
-- T125: Data Packet
-  - MCSHeader: Type=Send Data Indication, UserID=1002, ChannelID=1003
-   - Type: Send Data Indication
-    - RootIndex: 26
-       Value: (011010..) 0x1a
-   - UserID: 0x3ea
-    - UserID: 0x3ea
-     - ChannelId: 1002
-      - Align: No Padding
-         Padding2: (00......) 0x0
-        Value: 1 (0x1)
-   - Channel: 0x3eb
-    - ChannelId: 1003
-       Align: No Padding
-       Value: 1003 (0x3EB)
-   - DataPriority: high
-    - DataPriority: high
-     - RootIndex: 1
-        Value: (01......) 0x1
-   - Segmentation: Begin End
-      Begin: (1.......) Begin
-      End:   (.1......) End
-   - Length: 26
-    - Align: No Padding
-       Padding4: (0000....) 0x0
-      Length: 26
-    RDP: RDPBCGR
-- RDPBCGR: TsControlPDU
-  - SlowPathPacket: TsControlPDU
-   - SlowPath: Type = TS_PDUTYPE_DATAPDU
-    - TsShareControlHeader: Type = TS_PDUTYPE_DATAPDU
-       TotalLength: 26 (0x1A)
-     - PDUType: 23 (0x17)
-        Type:            (............0111) TS_PDUTYPE_DATAPDU
-        ProtocolVersion: (000000000001....) 1
-       PDUSource: 1002 (0x3EA)
-    - SlowPathIoPacket: 0x0
-     - ShareDataHeader: TS_PDUTYPE2_CONTROL
-        ShareID: 66538 (0x103EA)
-        Pad1: 154 (0x9A)
-        StreamID: TS_STREAM_MED
-        UncompressedLength: 26 (0x1A)
-        PDUType2: TS_PDUTYPE2_CONTROL
-      - CompressedType: Not Compressed
-         MPPC:       (....0000) MPPC 8K
-         Reserved:   (...0....)
-         Compressed: (..0.....) Not Compressed
-         Front:      (.0......) Not At Front
-         Flush:      (0.......) Not Flushed
-        CompressedLength: 0 (0x0)
-     - TsControlPDU: Action = Cooperate
-        Action: Cooperate
-        GrantID: 0 (0x0)
-        ControlID: 0 (0x0)
-
- */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUGrantedControl.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUGrantedControl.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUGrantedControl.java
deleted file mode 100644
index 62cbd6c..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerControlPDUGrantedControl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package rdpclient;
-
-import streamer.ByteBuffer;
-import streamer.Link;
-import streamer.OneTimeSwitch;
-
-public class ServerControlPDUGrantedControl extends OneTimeSwitch {
-
-    public ServerControlPDUGrantedControl(String id) {
-        super(id);
-    }
-
-    @Override
-    protected void handleOneTimeData(ByteBuffer buf, Link link) {
-        if (buf == null)
-            return;
-
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        // Ignore packet
-        buf.unref();
-        switchOff();
-    }
-
-}
-/* @formatter:off */
-/*
-03 00 00 28 02 F0 80 68 00 01 03 EB 70 1A 1A 00 17 00 EA 03 EA 03 01 00 50 02 1A 00 14 00 00 00 02 00 EC 03 EA 03 00 00
-
-  Frame: Number = 45, Captured Frame Length = 97, MediaType = DecryptedPayloadHeader
-+ DecryptedPayloadHeader: FrameCount = 1, ErrorStatus = SUCCESS
-  TLSSSLData: Transport Layer Security (TLS) Payload Data
-+ TLS: TLS Rec Layer-1 SSL Application Data
-  ISOTS: TPKTCount = 1
-- TPKT: version: 3, Length: 40
-    version: 3 (0x3)
-    Reserved: 0 (0x0)
-    PacketLength: 40 (0x28)
-- X224: Data
-    Length: 2 (0x2)
-    Type: Data
-    EOT: 128 (0x80)
-- T125: Data Packet
-  - MCSHeader: Type=Send Data Indication, UserID=1002, ChannelID=1003
-   - Type: Send Data Indication
-    - RootIndex: 26
-       Value: (011010..) 0x1a
-   - UserID: 0x3ea
-    - UserID: 0x3ea
-     - ChannelId: 1002
-      - Align: No Padding
-         Padding2: (00......) 0x0
-        Value: 1 (0x1)
-   - Channel: 0x3eb
-    - ChannelId: 1003
-       Align: No Padding
-       Value: 1003 (0x3EB)
-   - DataPriority: high
-    - DataPriority: high
-     - RootIndex: 1
-        Value: (01......) 0x1
-   - Segmentation: Begin End
-      Begin: (1.......) Begin
-      End:   (.1......) End
-   - Length: 26
-    - Align: No Padding
-       Padding4: (0000....) 0x0
-      Length: 26
-    RDP: RDPBCGR
-- RDPBCGR: TsControlPDU
-  - SlowPathPacket: TsControlPDU
-   - SlowPath: Type = TS_PDUTYPE_DATAPDU
-    - TsShareControlHeader: Type = TS_PDUTYPE_DATAPDU
-       TotalLength: 26 (0x1A)
-     - PDUType: 23 (0x17)
-        Type:            (............0111) TS_PDUTYPE_DATAPDU
-        ProtocolVersion: (000000000001....) 1
-       PDUSource: 1002 (0x3EA)
-    - SlowPathIoPacket: 0x0
-     - ShareDataHeader: TS_PDUTYPE2_CONTROL
-        ShareID: 66538 (0x103EA)
-        Pad1: 80 (0x50)
-        StreamID: TS_STREAM_MED
-        UncompressedLength: 26 (0x1A)
-        PDUType2: TS_PDUTYPE2_CONTROL
-      - CompressedType: Not Compressed
-         MPPC:       (....0000) MPPC 8K
-         Reserved:   (...0....)
-         Compressed: (..0.....) Not Compressed
-         Front:      (.0......) Not At Front
-         Flush:      (0.......) Not Flushed
-        CompressedLength: 0 (0x0)
-     - TsControlPDU: Action = Granted Control
-        Action: Granted Control
-        GrantID: 1004 (0x3EC)
-        ControlID: 1002 (0x3EA)
- */