cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject [21/21] git commit: updated refs/heads/master to 48c4710
Date Thu, 02 Jan 2014 07:53:23 GMT
CLOUDSTACK-5344: Updated to allow rdp console to access hyper-v vm virtual framebuffer.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/48c47101
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/48c47101
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/48c47101

Branch: refs/heads/master
Commit: 48c47101aa9996c68851de878cb2229cf70dcf2b
Parents: 97ede25
Author: Donal Lafferty <dlafferty@gmail.com>
Authored: Wed Nov 27 14:38:51 2013 +0000
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Thu Jan 2 13:06:10 2014 +0530

----------------------------------------------------------------------
 .../console-proxy-rdp/rdpconsole/README.txt     |   54 +-
 services/console-proxy-rdp/rdpconsole/pom.xml   |    9 +-
 .../console-proxy-rdp/rdpconsole/rdp-config.bat |    2 +-
 .../src/main/java/common/AwtBellAdapter.java    |   77 --
 .../src/main/java/common/AwtCanvasAdapter.java  |  166 ---
 .../main/java/common/AwtClipboardAdapter.java   |   56 -
 .../src/main/java/common/AwtKeyEventSource.java |    0
 .../main/java/common/AwtMouseEventSource.java   |    0
 .../src/main/java/common/BitmapOrder.java       |    3 +-
 .../src/main/java/common/BitmapRectangle.java   |    6 +-
 .../main/java/common/BufferedImageCanvas.java   |    2 +-
 .../common/BufferedImageCopyRectAdapter.java    |   32 +-
 .../java/common/BufferedImagePixelsAdapter.java |   46 +-
 .../rdpconsole/src/main/java/common/Client.java |  283 ++++-
 .../src/main/java/common/CopyRectOrder.java     |    0
 .../src/main/java/common/KeyOrder.java          |    0
 .../src/main/java/common/MouseOrder.java        |    0
 .../src/main/java/common/OrderType.java         |    0
 .../src/main/java/common/ScreenDescription.java |   56 +-
 .../main/java/common/SizeChangeListener.java    |    0
 .../java/common/adapter/AwtBellAdapter.java     |   77 ++
 .../java/common/adapter/AwtCanvasAdapter.java   |  171 +++
 .../common/adapter/AwtClipboardAdapter.java     |   57 +
 .../src/main/java/common/asn1/Any.java          |   78 ++
 .../main/java/common/asn1/Asn1Constants.java    |   83 ++
 .../src/main/java/common/asn1/Asn1Integer.java  |  116 ++
 .../src/main/java/common/asn1/BerType.java      |   40 +
 .../src/main/java/common/asn1/BitString.java    |   67 ++
 .../src/main/java/common/asn1/ObjectID.java     |   67 ++
 .../src/main/java/common/asn1/OctetString.java  |   80 ++
 .../src/main/java/common/asn1/Sequence.java     |  143 +++
 .../src/main/java/common/asn1/SequenceOf.java   |   82 ++
 .../src/main/java/common/asn1/Tag.java          |  462 +++++++
 .../main/java/common/opt/IncrementalOption.java |   28 +
 .../src/main/java/common/opt/IntOption.java     |   41 +
 .../opt/NoArgumentForOptionException.java       |   26 +
 .../src/main/java/common/opt/Option.java        |  102 ++
 .../src/main/java/common/opt/OptionParser.java  |  147 +++
 .../common/opt/OptionRequiredException.java     |   26 +
 .../main/java/common/opt/StringArrayOption.java |   38 +
 .../common/opt/StringEnumerationOption.java     |   72 ++
 .../src/main/java/common/opt/StringOption.java  |   41 +
 .../java/common/opt/UnknownOptionException.java |   27 +
 .../java/rdpclient/AwtRdpKeyboardAdapter.java   |  350 ------
 .../main/java/rdpclient/AwtRdpMouseAdapter.java |  179 ---
 .../java/rdpclient/ClientConfirmActivePDU.java  | 1129 -----------------
 .../main/java/rdpclient/ClientFastPathPDU.java  |   55 -
 .../src/main/java/rdpclient/ClientInfoPDU.java  |  455 -------
 .../rdpclient/ClientMCSAttachUserRequest.java   |  103 --
 ...lJoinRequestServerMCSChannelConfirmPDUs.java |  222 ----
 .../java/rdpclient/ClientMCSConnectInitial.java |  669 -----------
 .../rdpclient/ClientMCSErectDomainRequest.java  |  189 ---
 .../java/rdpclient/ClientPacketSniffer.java     |   49 -
 .../java/rdpclient/ClientSynchronizePDU.java    |  248 ----
 .../src/main/java/rdpclient/ClientTpkt.java     |   54 -
 .../ClientX224ConnectionRequestPDU.java         |  156 ---
 .../main/java/rdpclient/ClientX224DataPdu.java  |   52 -
 .../src/main/java/rdpclient/HandshakeEnd.java   |   27 -
 .../src/main/java/rdpclient/MockServer.java     |  198 ---
 .../src/main/java/rdpclient/PacketSniffer.java  |   75 --
 .../java/rdpclient/RLEBitmapDecompression.java  |  985 ---------------
 .../src/main/java/rdpclient/RdpClient.java      |  297 ++++-
 .../src/main/java/rdpclient/RdpConstants.java   |   70 --
 .../src/main/java/rdpclient/RdpState.java       |   33 -
 .../main/java/rdpclient/ServerBitmapUpdate.java |  200 ----
 .../java/rdpclient/ServerChannel1003Router.java |  533 ---------
 .../rdpclient/ServerControlPDUCooperate.java    |  117 --
 .../ServerControlPDUGrantedControl.java         |  114 --
 .../java/rdpclient/ServerDemandActivePDU.java   |  660 ----------
 .../src/main/java/rdpclient/ServerFastPath.java |  258 ----
 .../ServerLicenseErrorPDUValidClient.java       |  121 --
 .../ServerMCSAttachUserConfirmPDU.java          |  134 ---
 .../ServerMCSChannelJoinConfirmPDU.java         |   89 --
 .../rdpclient/ServerMCSConnectResponse.java     |  283 -----
 .../src/main/java/rdpclient/ServerMCSPDU.java   |  149 ---
 .../java/rdpclient/ServerPacketSniffer.java     |   50 -
 .../java/rdpclient/ServerPaletteUpdate.java     |   77 --
 .../java/rdpclient/ServerSynchronizePDU.java    |  115 --
 .../src/main/java/rdpclient/ServerTpkt.java     |   70 --
 .../ServerX224ConnectionConfirmPDU.java         |  237 ----
 .../main/java/rdpclient/ServerX224DataPdu.java  |   64 -
 .../rdpclient/TrustAllX509TrustManager.java     |   40 -
 .../main/java/rdpclient/UpgradeSocketToSSL.java |   44 -
 .../adapter/AwtRdpKeyboardAdapter.java          |  350 ++++++
 .../rdpclient/adapter/AwtRdpMouseAdapter.java   |  179 +++
 .../rdpclient/clip/ClipboardDataFormat.java     |  143 +++
 .../java/rdpclient/clip/ClipboardState.java     |   70 ++
 .../clip/ServerClipRdrChannelRouter.java        |  193 +++
 .../clip/ServerClipboardCapabilitiesPDU.java    |  180 +++
 .../clip/ServerFormatDataResponsePDU.java       |   97 ++
 .../rdpclient/clip/ServerFormatListPDU.java     |  237 ++++
 .../rdpclient/clip/ServerMonitorReadyPDU.java   |   85 ++
 .../rdpclient/debug/ClientPacketSniffer.java    |   51 +
 .../java/rdpclient/debug/PacketSniffer.java     |   75 ++
 .../rdpclient/debug/ServerPacketSniffer.java    |   49 +
 .../hyperv/ClientPreConnectionBlob.java         |  121 ++
 .../ntlmssp/ClientNtlmsspNegotiate.java         |  177 +++
 .../ntlmssp/ClientNtlmsspPubKeyAuth.java        |  680 +++++++++++
 .../ntlmssp/ClientNtlmsspUserCredentials.java   |  128 ++
 .../java/rdpclient/ntlmssp/CryptoAlgos.java     |  361 ++++++
 .../main/java/rdpclient/ntlmssp/NegoFlags.java  |  492 ++++++++
 .../java/rdpclient/ntlmssp/NtlmCompute.java     |   24 +
 .../java/rdpclient/ntlmssp/NtlmConstants.java   |  157 +++
 .../main/java/rdpclient/ntlmssp/NtlmState.java  |  887 ++++++++++++++
 .../main/java/rdpclient/ntlmssp/SecBuffer.java  |   21 +
 .../ntlmssp/ServerNtlmsspChallenge.java         |  293 +++++
 .../ntlmssp/ServerNtlmsspPubKeyPlus1.java       |  125 ++
 .../ntlmssp/asn1/AlgorithmIdentifier.java       |   40 +
 .../java/rdpclient/ntlmssp/asn1/NegoData.java   |   64 +
 .../java/rdpclient/ntlmssp/asn1/NegoItem.java   |   73 ++
 .../ntlmssp/asn1/SubjectPublicKeyInfo.java      |   35 +
 .../rdpclient/ntlmssp/asn1/TSCredentials.java   |   62 +
 .../rdpclient/ntlmssp/asn1/TSCspDataDetail.java |   98 ++
 .../rdpclient/ntlmssp/asn1/TSPasswordCreds.java |   76 ++
 .../java/rdpclient/ntlmssp/asn1/TSRequest.java  |  201 ++++
 .../ntlmssp/asn1/TSSmartCardCreds.java          |   90 ++
 .../java/rdpclient/ntlmssp/package-info.java    |   71 ++
 .../rdpclient/rdp/ClientConfirmActivePDU.java   | 1131 ++++++++++++++++++
 .../java/rdpclient/rdp/ClientFastPathPDU.java   |   55 +
 .../main/java/rdpclient/rdp/ClientInfoPDU.java  |  456 +++++++
 .../rdp/ClientMCSAttachUserRequest.java         |  103 ++
 ...lJoinRequestServerMCSChannelConfirmPDUs.java |  223 ++++
 .../rdpclient/rdp/ClientMCSConnectInitial.java  |  696 +++++++++++
 .../rdp/ClientMCSErectDomainRequest.java        |  189 +++
 .../rdpclient/rdp/ClientSynchronizePDU.java     |  248 ++++
 .../src/main/java/rdpclient/rdp/ClientTpkt.java |   54 +
 .../rdp/ClientX224ConnectionRequestPDU.java     |  162 +++
 .../java/rdpclient/rdp/ClientX224DataPDU.java   |   52 +
 .../rdpclient/rdp/RLEBitmapDecompression.java   | 1014 ++++++++++++++++
 .../main/java/rdpclient/rdp/RdpConstants.java   |   91 ++
 .../src/main/java/rdpclient/rdp/RdpState.java   |   33 +
 .../java/rdpclient/rdp/ServerBitmapUpdate.java  |  199 +++
 .../rdp/ServerControlPDUCooperate.java          |  117 ++
 .../rdp/ServerControlPDUGrantedControl.java     |  114 ++
 .../rdpclient/rdp/ServerDemandActivePDU.java    |  660 ++++++++++
 .../main/java/rdpclient/rdp/ServerFastPath.java |  315 +++++
 .../rdpclient/rdp/ServerIOChannelRouter.java    |  534 +++++++++
 .../rdp/ServerLicenseErrorPDUValidClient.java   |  121 ++
 .../rdp/ServerMCSAttachUserConfirmPDU.java      |  116 ++
 .../rdp/ServerMCSChannelJoinConfirmPDU.java     |   89 ++
 .../rdpclient/rdp/ServerMCSConnectResponse.java |  283 +++++
 .../main/java/rdpclient/rdp/ServerMCSPDU.java   |  149 +++
 .../java/rdpclient/rdp/ServerPaletteUpdate.java |   77 ++
 .../rdpclient/rdp/ServerSynchronizePDU.java     |  115 ++
 .../src/main/java/rdpclient/rdp/ServerTpkt.java |   70 ++
 .../rdp/ServerX224ConnectionConfirmPDU.java     |  234 ++++
 .../java/rdpclient/rdp/ServerX224DataPdu.java   |   64 +
 .../main/java/streamer/AssertingByteBuffer.java |  107 --
 .../src/main/java/streamer/BaseElement.java     |   98 +-
 .../src/main/java/streamer/BufferPool.java      |    0
 .../src/main/java/streamer/ByteBuffer.java      |  466 ++++++--
 .../src/main/java/streamer/DataSink.java        |    0
 .../src/main/java/streamer/DataSource.java      |    0
 .../src/main/java/streamer/Direction.java       |    0
 .../src/main/java/streamer/Element.java         |    2 +-
 .../src/main/java/streamer/Event.java           |    3 +-
 .../src/main/java/streamer/FakeSink.java        |   69 --
 .../src/main/java/streamer/FakeSource.java      |  125 --
 .../main/java/streamer/InputStreamSource.java   |   36 +-
 .../rdpconsole/src/main/java/streamer/Link.java |    0
 .../src/main/java/streamer/MockSink.java        |  113 --
 .../src/main/java/streamer/MockSource.java      |   89 --
 .../src/main/java/streamer/OneTimeSwitch.java   |    3 +
 .../src/main/java/streamer/Order.java           |    0
 .../main/java/streamer/OutputStreamSink.java    |   42 +-
 .../src/main/java/streamer/Pipeline.java        |    2 +
 .../src/main/java/streamer/PipelineImpl.java    |   77 +-
 .../src/main/java/streamer/Queue.java           |   28 +-
 .../src/main/java/streamer/SocketWrapper.java   |  216 +---
 .../main/java/streamer/SocketWrapperImpl.java   |  249 ++++
 .../src/main/java/streamer/SyncLink.java        |  123 +-
 .../main/java/streamer/apr/AprSocketSink.java   |  129 ++
 .../main/java/streamer/apr/AprSocketSource.java |  171 +++
 .../java/streamer/apr/AprSocketWrapperImpl.java |  281 +++++
 .../java/streamer/bco/BcoSocketWrapperImpl.java |  119 ++
 .../streamer/debug/AssertingByteBuffer.java     |  109 ++
 .../src/main/java/streamer/debug/Dumper.java    |   28 +
 .../src/main/java/streamer/debug/FakeSink.java  |   77 ++
 .../main/java/streamer/debug/FakeSource.java    |  138 +++
 .../main/java/streamer/debug/MockServer.java    |  203 ++++
 .../src/main/java/streamer/debug/MockSink.java  |  154 +++
 .../main/java/streamer/debug/MockSource.java    |   95 ++
 .../src/main/java/streamer/ssl/SSLState.java    |   26 +
 .../streamer/ssl/TrustAllX509TrustManager.java  |   52 +
 .../java/streamer/ssl/UpgradeSocketToSSL.java   |   44 +
 .../vncclient/AwtKeyboardEventToVncAdapter.java |  368 ------
 .../vncclient/AwtMouseEventToVncAdapter.java    |   71 --
 .../main/java/vncclient/EncodingsMessage.java   |   63 -
 .../vncclient/FrameBufferUpdateRequest.java     |  126 --
 .../vncclient/RGB888LE32PixelFormatRequest.java |   89 --
 .../src/main/java/vncclient/RfbConstants.java   |   85 --
 .../java/vncclient/Vnc33Authentication.java     |  292 -----
 .../src/main/java/vncclient/Vnc33Hello.java     |  116 --
 .../src/main/java/vncclient/VncClient.java      |   58 +-
 .../src/main/java/vncclient/VncInitializer.java |  245 ----
 .../main/java/vncclient/VncMessageHandler.java  |  420 -------
 .../adapter/AwtVncKeyboardAdapter.java          |  369 ++++++
 .../vncclient/adapter/AwtVncMouseAdapter.java   |   71 ++
 .../java/vncclient/vnc/EncodingsMessage.java    |   63 +
 .../vncclient/vnc/FrameBufferUpdateRequest.java |  126 ++
 .../vnc/RGB888LE32PixelFormatRequest.java       |   89 ++
 .../main/java/vncclient/vnc/RfbConstants.java   |   85 ++
 .../java/vncclient/vnc/Vnc33Authentication.java |  292 +++++
 .../src/main/java/vncclient/vnc/Vnc33Hello.java |  116 ++
 .../main/java/vncclient/vnc/VncInitializer.java |  245 ++++
 .../java/vncclient/vnc/VncMessageHandler.java   |  420 +++++++
 .../src/main/resources/jaas_ntlm_config.txt     |   21 +
 .../rdpconsole/src/test/doc/README.txt          |    2 +
 .../rdpconsole/src/test/doc/dev-rdp-config.bat  |   13 +
 .../src/test/doc/freerdp-debug-log.txt          |  772 ++++++++++++
 .../rdpconsole/src/test/doc/rdp.pfx             |  Bin 0 -> 2572 bytes
 .../src/test/java/rdpclient/MockServerTest.java |    9 +-
 212 files changed, 21655 insertions(+), 12007 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/README.txt
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/README.txt b/services/console-proxy-rdp/rdpconsole/README.txt
old mode 100644
new mode 100755
index 15029d4..546746c
--- a/services/console-proxy-rdp/rdpconsole/README.txt
+++ b/services/console-proxy-rdp/rdpconsole/README.txt
@@ -14,28 +14,38 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-This project contains code for basic VNC and RDP clients.
-
-VNC client can be invoked using following command:
-
-  mvn exec:java -Dexec.mainClass="common.Client" -Dexec.args="vnc 192.168.0.101 5901 password"
-
-where
-  * vnc - name of protcol;
-  * 192.168.0.101 - IP of VNC server;
-  * 5901 - port of VNC server screen (5900+display number);
-  * password - VNC server password.
-
-
-RDP client can be invoked using following command:
-
-  mvn exec:java -Dexec.mainClass="common.Client" -Dexec.args="rdp 192.168.0.101 3389 Administrator"
-
-where
-  * rdp - name of protcol;
-  * 192.168.0.101 - IP of RDP server;
-  * 3389 - port of RDP server;
-  * Administrator - user name for loging dialog.
+This project contains code for basic VNC, RDP, and HyperV (RDP) clients.
+
+Usage: 
+  java common.Client vnc|rdp|hyperv OPTIONS
+
+Common options:
+  --help|-h	Show this help text.
+  --debug-link|-DL	Print debugging messages when packets are trasnferred via links.
+  --debug-element|-DE	Print debugging messages when packets are received or sended by elements.
+  --debug-pipeline|-DP	Print debugging messages in pipelines.
+  --host|-n|--host-name VALUE	Name or IP address of host to connect to. Required.
+  --width|-W VALUE	Width of canvas. Default value is "1024".
+  --height|-H VALUE	Height of canvas. Default value is "768".
+
+VNC options:
+  --port|-p VALUE	Port of VNC display server to connect to. Calculate as 5900 + display number, e.g. 5900 for display #0, 5901 for display #1, and so on. Default value is "5901".
+  --password|-P VALUE	Password to use. Required.
+
+RDP options:
+  --ssl-implementation|-j jre|apr|bco	Select SSL engine to use: JRE standard implementation, Apache Portable Runtime native library, BonuncyCastle.org implementation. Default value is "apr".
+  --port|-p VALUE	Port of RDP server to connect to. Default value is "3389".
+  --domain|-D VALUE	NTLM domain to login into. Default value is "Workgroup".
+  --user|-U VALUE	User name to use. Default value is "Administrator".
+  --password|-P VALUE	Password to use. If omitted, then login screen will be shown.
+
+HyperV options:
+  --ssl-implementation|-j jre|apr|bco	Select SSL engine to use: JRE standard implementation, Apache Portable Runtime native library, BonuncyCastle.org implementation. Default value is "apr".
+  --port|-p VALUE	Port of HyperV server to connect to. Default value is "2179".
+  --instance|-i VALUE	HyperV instance ID to use. Required.
+  --domain|-D VALUE	NTLM domain to login into. Default value is "Workgroup".
+  --user|-U VALUE	User name to use. Default value is "Administrator".
+  --password|-P VALUE	Password to use. Required.
 
 
 Limitations of VNC client:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/pom.xml
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/pom.xml b/services/console-proxy-rdp/rdpconsole/pom.xml
old mode 100644
new mode 100755
index d25329a..5737a85
--- a/services/console-proxy-rdp/rdpconsole/pom.xml
+++ b/services/console-proxy-rdp/rdpconsole/pom.xml
@@ -61,11 +61,18 @@
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
+    <!-- Apache Portable Runtime implementation of SSL protocol, which is compatible with broken MS RDP SSL suport.
+    NOTE: tomcat-native package with /usr/lib/libtcnative-1.so library is necessary for APR to work. -->
     <dependency>
       <groupId>org.apache.tomcat.embed</groupId>
       <artifactId>tomcat-embed-core</artifactId>
       <version>7.0.30</version>
-      <scope>test</scope>
+    </dependency>
+    <!-- Another implementation of SSL protocol. Does not work with broken MS RDP SSL too. -->
+    <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcprov-jdk16</artifactId>
+      <version>1.46</version>
     </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/rdp-config.bat
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/rdp-config.bat b/services/console-proxy-rdp/rdpconsole/rdp-config.bat
old mode 100644
new mode 100755
index e951014..f19b00d
--- a/services/console-proxy-rdp/rdpconsole/rdp-config.bat
+++ b/services/console-proxy-rdp/rdpconsole/rdp-config.bat
@@ -16,7 +16,7 @@ rem specific language governing permissions and limitations
 rem under the License.
 
 rem 
-rem Configure and start RDP service.
+rem Configure and start RDP service. Run this script on RDP server.
 rem 
  
 rem Turn off firewall

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtBellAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtBellAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtBellAdapter.java
deleted file mode 100644
index 5970abb..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtBellAdapter.java
+++ /dev/null
@@ -1,77 +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 common;
-
-import java.awt.Toolkit;
-
-import streamer.BaseElement;
-import streamer.ByteBuffer;
-import streamer.Element;
-import streamer.FakeSource;
-import streamer.Link;
-import streamer.Pipeline;
-import streamer.PipelineImpl;
-
-public class AwtBellAdapter extends BaseElement {
-
-    public AwtBellAdapter(String id) {
-        super(id);
-        declarePads();
-    }
-
-    private void declarePads() {
-        inputPads.put(STDIN, null);
-    }
-
-    @Override
-    public void handleData(ByteBuffer buf, Link link) {
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        if (buf == null)
-            return;
-
-        Toolkit.getDefaultToolkit().beep();
-    }
-
-    @Override
-    public String toString() {
-        return "Bell(" + id + ")";
-    }
-
-    /**
-     * Example.
-     */
-    public static void main(String args[]) {
-        System.setProperty("streamer.Element.debug", "true");
-
-        Element source = new FakeSource("source") {
-            {
-                this.incommingBufLength = 0;
-                this.delay = 1000;
-                this.numBuffers = 3;
-            }
-        };
-
-        Element sink = new AwtBellAdapter("sink");
-
-        Pipeline pipeline = new PipelineImpl("test");
-        pipeline.addAndLink(source, 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/common/AwtCanvasAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtCanvasAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtCanvasAdapter.java
deleted file mode 100644
index 8adee49..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtCanvasAdapter.java
+++ /dev/null
@@ -1,166 +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 common;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.WritableRaster;
-
-import rdpclient.ServerBitmapUpdate;
-import streamer.BaseElement;
-import streamer.ByteBuffer;
-import streamer.Element;
-import streamer.Link;
-import streamer.Order;
-import streamer.Pipeline;
-import streamer.PipelineImpl;
-
-public class AwtCanvasAdapter extends BaseElement {
-
-    protected ScreenDescription screen;
-
-    public AwtCanvasAdapter(String id, BufferedImageCanvas canvas, ScreenDescription screen) {
-        super(id);
-        this.canvas = canvas;
-        this.screen = screen;
-    }
-
-    protected BufferedImageCanvas canvas;
-
-    @Override
-    public String toString() {
-        return "AwtRdpAdapter(" + id + ")";
-    }
-
-    @Override
-    public void handleData(ByteBuffer buf, Link link) {
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        Order order = buf.getOrder();
-        switch ((OrderType)order.type) {
-
-            case BITMAP_UPDATE:
-                handleBitmap((BitmapOrder)order, buf);
-                break;
-
-            case COPY_RECT:
-                handleCopyRect((CopyRectOrder)order, buf);
-                break;
-
-            default:
-                throw new RuntimeException("Order is not implemented: " + buf + ".");
-                // break;
-        }
-
-        buf.unref();
-    }
-
-    private void handleCopyRect(CopyRectOrder order, ByteBuffer buf) {
-        // TODO Auto-generated method stub
-        // Copy image
-        canvas.getOfflineGraphics().copyArea(order.srcX, order.srcY, order.width, order.height, order.x - order.srcX, order.y - order.srcY);
-
-        // Request update of repainted area
-        canvas.repaint(order.x, order.y, order.width, order.height);
-
-    }
-
-    private void handleBitmap(BitmapOrder order, ByteBuffer buf) {
-        // Draw rectangle on offline buffer
-        BufferedImage image = canvas.getOfflineImage();
-        Graphics2D g = (Graphics2D)image.getGraphics();
-
-        for (BitmapRectangle rectangle : order.rectangles) {
-            // *DEBUG*/System.out.println("["+this+"] DEBUG: Rectangle: " +
-            // rectangle.toString());
-
-            int x = rectangle.x;
-            int y = rectangle.y;
-            int width = rectangle.width;
-            int height = rectangle.height;
-            int bufferWidth = rectangle.bufferWidth;
-            int bufferHeight = rectangle.bufferHeight;
-
-            BufferedImage rectImage;
-            switch (rectangle.colorDepth) {
-                case 8: {
-                    rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_BYTE_INDEXED, screen.colorMap);
-                    WritableRaster raster = rectImage.getRaster();
-                    raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toByteArray());
-                    break;
-                }
-                case 15: {
-                    rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_USHORT_555_RGB);
-                    WritableRaster raster = rectImage.getRaster();
-                    raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toShortArray());
-                    break;
-                }
-                case 16: {
-                    rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_USHORT_565_RGB);
-                    WritableRaster raster = rectImage.getRaster();
-                    raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toShortArray());
-                    break;
-                }
-                case 24:
-                case 32: {
-                    rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_INT_RGB);
-                    WritableRaster raster = rectImage.getRaster();
-                    raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toIntLEArray());
-                    break;
-                }
-                default:
-                    throw new RuntimeException("Unsupported color depth: " + rectangle.colorDepth + ".");
-            }
-
-            g.setClip(x, y, width, height);
-            g.drawImage(rectImage, x, y, null);
-
-            // Request update of repainted area
-            canvas.repaint(x, y, width, height);
-        }
-
-    }
-
-    /**
-     * 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");
-        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});
-
-        Pipeline pipeline = new PipelineImpl("test");
-
-        Element bitmap = new ServerBitmapUpdate("bitmap");
-
-        BufferedImageCanvas canvas = new BufferedImageCanvas(1024, 768);
-        Element adapter = new AwtCanvasAdapter("test", canvas, null) {
-            {
-                verbose = true;
-            }
-        };
-        pipeline.addAndLink(bitmap, adapter);
-
-        bitmap.handleData(packet, null);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtClipboardAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtClipboardAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtClipboardAdapter.java
deleted file mode 100644
index 75dc1b9..0000000
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtClipboardAdapter.java
+++ /dev/null
@@ -1,56 +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 common;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.StringSelection;
-
-import streamer.BaseElement;
-import streamer.ByteBuffer;
-import streamer.Link;
-import vncclient.VncMessageHandler;
-
-public class AwtClipboardAdapter extends BaseElement {
-
-    public AwtClipboardAdapter(String id) {
-        super(id);
-        declarePads();
-    }
-
-    private void declarePads() {
-        inputPads.put(STDIN, null);
-    }
-
-    @Override
-    public void handleData(ByteBuffer buf, Link link) {
-        if (verbose)
-            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
-
-        if (buf == null)
-            return;
-
-        String content = (String)buf.getMetadata(VncMessageHandler.CLIPBOARD_CONTENT);
-        StringSelection contents = new StringSelection(content);
-        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null);
-    }
-
-    @Override
-    public String toString() {
-        return "Clipboard(" + id + ")";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtKeyEventSource.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtKeyEventSource.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtKeyEventSource.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtMouseEventSource.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtMouseEventSource.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/AwtMouseEventSource.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapOrder.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapOrder.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapOrder.java
old mode 100644
new mode 100755
index 3a25c8f..8d64331
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapOrder.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapOrder.java
@@ -40,7 +40,8 @@ public class BitmapOrder extends Order {
     @Override
     public String toString() {
         final int maxLen = 10;
-        return String.format("BitmapUpdateOrder [rectangles=%s]", rectangles != null ? Arrays.asList(rectangles).subList(0, Math.min(rectangles.length, maxLen)) : null);
+        return String.format("BitmapUpdateOrder [rectangles=%s]", rectangles != null ? Arrays.asList(rectangles).subList(0, Math.min(rectangles.length, maxLen))
+                : null);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapRectangle.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapRectangle.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapRectangle.java
old mode 100644
new mode 100755
index 08dcbf6..1685114
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapRectangle.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BitmapRectangle.java
@@ -65,8 +65,10 @@ public class BitmapRectangle {
 
     @Override
     public String toString() {
-        return String.format("BitmapUpdateRectangle [x=%s, y=%s, width=%s, height=%s, bitsPerPixel=%s, bitmapDataStream=%s]", x, y, width, height, colorDepth,
-            bitmapDataStream);
+        return String
+                .format(
+                        "BitmapUpdateRectangle [x=%s, y=%s, width=%s, height=%s, bitsPerPixel=%s, bitmapDataStream=%s]",
+                        x, y, width, height, colorDepth, bitmapDataStream);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCanvas.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCanvas.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCanvas.java
old mode 100644
new mode 100755
index 2418de3..43abb27
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCanvas.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCanvas.java
@@ -49,7 +49,7 @@ public class BufferedImageCanvas extends Canvas {
     }
 
     public void setCanvasSize(int width, int height) {
-        this.offlineImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        offlineImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
         graphics = offlineImage.createGraphics();
 
         setSize(offlineImage.getWidth(), offlineImage.getHeight());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCopyRectAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCopyRectAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCopyRectAdapter.java
old mode 100644
new mode 100755
index 28bf640..804cab7
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCopyRectAdapter.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImageCopyRectAdapter.java
@@ -81,23 +81,23 @@ public class BufferedImageCopyRectAdapter extends BaseElement {
         Element renderer = new BufferedImageCopyRectAdapter("renderer", canvas);
 
         int[] pixelsBeforeCopy = new int[] {
-            // 0
-            1, 2, 3, 4,
-            // 1
-            5, 6, 7, 8,
-            // 2
-            9, 10, 11, 12,
-            // 3
-            13, 14, 15, 16};
+                // 0
+                1, 2, 3, 4,
+                // 1
+                5, 6, 7, 8,
+                // 2
+                9, 10, 11, 12,
+                // 3
+                13, 14, 15, 16};
         int[] pixelsAfterCopy = new int[] {
-            // 0
-            11, 12, 3, 4,
-            // 1
-            15, 16, 7, 8,
-            // 2
-            9, 10, 11, 12,
-            // 3
-            13, 14, 15, 16};
+                // 0
+                11, 12, 3, 4,
+                // 1
+                15, 16, 7, 8,
+                // 2
+                9, 10, 11, 12,
+                // 3
+                13, 14, 15, 16};
 
         // Initalize image
         int[] data = ((DataBufferInt)canvas.getOfflineImage().getRaster().getDataBuffer()).getData();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImagePixelsAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImagePixelsAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImagePixelsAdapter.java
old mode 100644
new mode 100755
index e93df3e..396bdd4
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImagePixelsAdapter.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/BufferedImagePixelsAdapter.java
@@ -82,32 +82,32 @@ public class BufferedImagePixelsAdapter extends BaseElement {
 
         switch (dataBuf.getDataType()) {
 
-            case DataBuffer.TYPE_INT: {
+        case DataBuffer.TYPE_INT: {
 
-                // Convert array of bytes to array of int's
-                int[] intArray = buf.toIntLEArray();
+            // Convert array of bytes to array of int's
+            int[] intArray = buf.toIntLEArray();
 
-                // We chose RGB888 model, so Raster will use DataBufferInt type
-                DataBufferInt dataBuffer = (DataBufferInt)dataBuf;
+            // We chose RGB888 model, so Raster will use DataBufferInt type
+            DataBufferInt dataBuffer = (DataBufferInt)dataBuf;
 
-                int imageWidth = image.getWidth();
-                int imageHeight = image.getHeight();
+            int imageWidth = image.getWidth();
+            int imageHeight = image.getHeight();
 
-                // Paint rectangle directly on buffer, line by line
-                int[] imageBuffer = dataBuffer.getData();
+            // Paint rectangle directly on buffer, line by line
+            int[] imageBuffer = dataBuffer.getData();
 
-                for (int srcLine = 0, dstLine = y; srcLine < rectHeight && dstLine < imageHeight; srcLine++, dstLine++) {
-                    try {
-                        System.arraycopy(intArray, srcLine * rectWidth, imageBuffer, x + dstLine * imageWidth, rectWidth);
-                    } catch (IndexOutOfBoundsException e) {
-                    }
+            for (int srcLine = 0, dstLine = y; srcLine < rectHeight && dstLine < imageHeight; srcLine++, dstLine++) {
+                try {
+                    System.arraycopy(intArray, srcLine * rectWidth, imageBuffer, x + dstLine * imageWidth, rectWidth);
+                } catch (IndexOutOfBoundsException e) {
                 }
-                break;
             }
+            break;
+        }
 
-            default:
-                throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: " +
-                    dataBuf.getClass().getSimpleName());
+        default:
+            throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: "
+                    + dataBuf.getClass().getSimpleName());
         }
 
         // Request update of repainted area
@@ -123,13 +123,11 @@ public class BufferedImagePixelsAdapter extends BaseElement {
 
         Element renderer = new BufferedImagePixelsAdapter("renderer", canvas);
 
-        byte[] pixels =
-            new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
-                12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+        byte[] pixels = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5,
+                6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
 
-        int[] pixelsLE =
-            new int[] {0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d, 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d, 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d,
-                0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d};
+        int[] pixelsLE = new int[] {0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d, 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d, 0x04030201, 0x08070605,
+                0x0c0b0a09, 0x100f0e0d, 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d};
 
         ByteBuffer buf = new ByteBuffer(pixels);
         buf.putMetadata(TARGET_X, 0);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
old mode 100644
new mode 100755
index b6dc4a2..688693b
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
@@ -22,46 +22,216 @@ import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
 import java.net.InetSocketAddress;
+import java.util.Arrays;
 
 import rdpclient.RdpClient;
 import streamer.Element;
 import streamer.Pipeline;
 import streamer.PipelineImpl;
 import streamer.SocketWrapper;
+import streamer.SocketWrapperImpl;
+import streamer.apr.AprSocketWrapperImpl;
+import streamer.bco.BcoSocketWrapperImpl;
+import streamer.ssl.SSLState;
 import vncclient.VncClient;
+import common.opt.IntOption;
+import common.opt.Option;
+import common.opt.OptionParser;
+import common.opt.StringEnumerationOption;
+import common.opt.StringOption;
 
 public class Client {
 
+    enum Protocol {
+        NONE, VNC, RDP, HYPERV
+    }
+
+    // Common options
+    private Option help = new Option() {
+        {
+            name = "--help";
+            alias = "-h";
+            description = "Show this help text.";
+        }
+    };
+    private Option debugLink = new Option() {
+        {
+            name = "--debug-link";
+            alias = "-DL";
+            description = "Print debugging messages when packets are trasnferred via links.";
+        }
+    };
+    private Option debugElement = new Option() {
+        {
+            name = "--debug-element";
+            alias = "-DE";
+            description = "Print debugging messages when packets are received or sended by elements.";
+        }
+    };
+    private Option debugPipeline = new Option() {
+        {
+            name = "--debug-pipeline";
+            alias = "-DP";
+            description = "Print debugging messages in pipelines.";
+        }
+    };
+
+    private StringOption hostName = new StringOption() {
+        {
+            name = "--host";
+            alias = "-n";
+            aliases = new String[] {"--host-name"};
+            required = true;
+            description = "Name or IP address of host to connect to.";
+        }
+    };
+    private IntOption canvasWidth = new IntOption() {
+        {
+            name = "--width";
+            alias = "-W";
+            value = 1024;
+            description = "Width of canvas.";
+        }
+    };
+
+    private IntOption canvasHeight = new IntOption() {
+        {
+            name = "--height";
+            alias = "-H";
+            value = 768;
+            description = "Height of canvas.";
+        }
+    };
+
+    // Protocol specific options
+
+    private IntOption vncPort = new IntOption() {
+        {
+            name = "--port";
+            alias = "-p";
+            value = 5901;
+            description = "Port of VNC display server to connect to. Calculate as 5900 + display number, e.g. 5900 for display #0, 5901 for display #1, and so on.";
+        }
+    };
+
+    private IntOption rdpPort = new IntOption() {
+        {
+            name = "--port";
+            alias = "-p";
+            value = 3389;
+            description = "Port of RDP server to connect to.";
+        }
+    };
+
+    private IntOption hyperVPort = new IntOption() {
+        {
+            name = "--port";
+            alias = "-p";
+            value = 2179;
+            description = "Port of HyperV server to connect to.";
+        }
+    };
+
+    private StringOption password = new StringOption() {
+        {
+            name = "--password";
+            alias = "-P";
+            required = true;
+            description = "Password to use.";
+        }
+    };
+
+    private StringOption rdpPassword = new StringOption() {
+        {
+            name = "--password";
+            alias = "-P";
+            required = false;
+            description = "Password to use. If omitted, then login screen will be shown.";
+        }
+    };
+
+    private StringOption userName = new StringOption() {
+        {
+            name = "--user";
+            alias = "-U";
+            value = "Administrator";
+            description = "User name to use.";
+        }
+    };
+
+    private StringOption domain = new StringOption() {
+        {
+            name = "--domain";
+            alias = "-D";
+            value = "Workgroup";
+            description = "NTLM domain to login into.";
+        }
+    };
+
+    private StringOption hyperVInstanceId = new StringOption() {
+        {
+            name = "--instance";
+            alias = "-i";
+            required = true;
+            description = "HyperV instance ID to use.";
+        }
+    };
+    private StringEnumerationOption sslImplementation = new StringEnumerationOption() {
+        {
+            name = "--ssl-implementation";
+            alias = "-j";
+            value = "apr";
+            choices = new String[] {"jre", "apr", "bco"};
+            description = "Select SSL engine to use: JRE standard implementation, Apache Portable Runtime native library, BonuncyCastle.org implementation.";
+        }
+    };
+
+    private final Option[] commonOptions = new Option[] {help, debugLink, debugElement, debugPipeline, hostName, canvasWidth, canvasHeight};
+    private final Option[] vncOptions = new Option[] {vncPort, password};
+    private final Option[] rdpOptions = new Option[] {sslImplementation, rdpPort, domain, userName, rdpPassword};
+    private final Option[] hyperVOptions = new Option[] {sslImplementation, hyperVPort, hyperVInstanceId, domain, userName, password};
+
     private static Frame frame;
     private static SocketWrapper socket;
     private static ScrollPane scroller;
     private static ScreenDescription screen;
     private static BufferedImageCanvas canvas;
 
-    public static void main(String args[]) {
-        // System.setProperty("streamer.Link.debug", "true");
-        // System.setProperty("streamer.Element.debug", "true");
-        // System.setProperty("streamer.Pipeline.debug", "true");
+    private void help() {
+        System.out.println("Usage: \n  java common.Client vnc|rdp|hyperv OPTIONS\n");
+        System.out.println(Option.toHelp("Common options", commonOptions));
+        System.out.println(Option.toHelp("VNC options", vncOptions));
+        System.out.println(Option.toHelp("RDP options", rdpOptions));
+        System.out.println(Option.toHelp("HyperV options", hyperVOptions));
+    }
+
+    public void runClient(String[] args) {
 
         try {
-            if (args.length < 4) {
-                System.out.println("Usage: \n  java common.Client vnc IP PORT PASSWORD\n  java common.Client rdp IP PORT username\n");
-                System.exit(0);
-            }
 
-            String connectionType = args[0];
-            String hostname = args[1];
-            int port = Integer.parseInt(args[2]);
-            String userNameOrPassword = args[3];
+            Protocol protocol = parseOptions(args);
+            if (protocol == Protocol.NONE)
+                return;
 
-            // Create address from arguments
-            InetSocketAddress address = new InetSocketAddress(hostname, port);
+            System.setProperty("streamer.Link.debug", "" + debugLink.used);
+            System.setProperty("streamer.Element.debug", "" + debugElement.used);
+            System.setProperty("streamer.Pipeline.debug", "" + debugPipeline.used);
+
+            SSLState sslState = new SSLState();
 
             // Create socket wrapper
-            socket = new SocketWrapper("socket");
+            if ("jre".equals(sslImplementation.value)) {
+                socket = new SocketWrapperImpl("socket", sslState);
+            } else if ("apr".equals(sslImplementation.value)) {
+                socket = new AprSocketWrapperImpl("socket", sslState);
+            } else if ("bco".equals(sslImplementation.value)) {
+                socket = new BcoSocketWrapperImpl("socket", sslState);
+            } else {
+                throw new RuntimeException("Unexpected option value: \"" + sslImplementation.value + "\". " + sslImplementation.help());
+            }
 
             screen = new ScreenDescription();
-            canvas = new BufferedImageCanvas(1024, 768);
+            canvas = new BufferedImageCanvas(canvasWidth.value, canvasHeight.value);
             screen.addSizeChangeListener(new SizeChangeListener() {
                 @Override
                 public void sizeChanged(int width, int height) {
@@ -74,13 +244,24 @@ public class Client {
             });
 
             // Assemble pipeline
+            InetSocketAddress address;
             Element main;
-            if ("vnc".equals(connectionType)) {
-                main = new VncClient("client", userNameOrPassword, screen, canvas);
-            } else if ("rdp".equals(connectionType)) {
-                main = new RdpClient("client", userNameOrPassword, screen, canvas);
-            } else {
-                throw new RuntimeException("Unknown connection type. Expected value: \"vnc\" or \"rdp\", actual value: \"" + connectionType + "\".");
+            switch (protocol) {
+            case VNC:
+                address = new InetSocketAddress(hostName.value, vncPort.value);
+                main = new VncClient("client", password.value, screen, canvas);
+                break;
+            case RDP:
+                address = new InetSocketAddress(hostName.value, rdpPort.value);
+                main = new RdpClient("client", hostName.value, domain.value, userName.value, rdpPassword.value, null, screen, canvas, sslState);
+                break;
+            case HYPERV:
+                address = new InetSocketAddress(hostName.value, hyperVPort.value);
+                main = new RdpClient("client", hostName.value, domain.value, userName.value, password.value, hyperVInstanceId.value, screen, canvas, sslState);
+                break;
+            default:
+                address = null;
+                main = null;
             }
 
             Pipeline pipeline = new PipelineImpl("Client");
@@ -89,7 +270,7 @@ public class Client {
 
             pipeline.validate();
 
-            frame = createVncClientMainWindow(canvas, "VNC", new WindowAdapter() {
+            frame = createVncClientMainWindow(canvas, protocol.toString() + " " + hostName.value, new WindowAdapter() {
                 @Override
                 public void windowClosing(WindowEvent evt) {
                     shutdown();
@@ -108,6 +289,41 @@ public class Client {
         }
     }
 
+    private Protocol parseOptions(String[] args) {
+        String protocolName = (args.length > 0) ? args[0] : "";
+        Protocol protocol = Protocol.NONE;
+
+        Option[] options;
+        if (protocolName.equals("vnc")) {
+            protocol = Protocol.VNC;
+            options = join(commonOptions, vncOptions);
+        } else if (protocolName.equals("rdp")) {
+            protocol = Protocol.RDP;
+            options = join(commonOptions, rdpOptions);
+        } else if (protocolName.equals("hyperv")) {
+            protocol = Protocol.HYPERV;
+            options = join(commonOptions, hyperVOptions);
+        } else {
+            help();
+            return Protocol.NONE;
+        }
+
+        // Parse all options for given protocol
+        String[] arguments = OptionParser.parseOptions(args, 1, options);
+
+        if (arguments.length > 0) {
+            System.err.println("[Client] ERROR: Arguments are not allowed here. Check command syntax. Extra arguments: \"" + Arrays.toString(arguments) + "\".");
+            help();
+            return Protocol.NONE;
+        }
+
+        if (help.used) {
+            help();
+            return Protocol.NONE;
+        }
+        return protocol;
+    }
+
     protected static void shutdown() {
         if (frame != null) {
             frame.setVisible(false);
@@ -135,4 +351,25 @@ public class Client {
         return frame;
     }
 
+    /**
+     * Join two arrays with options and return new array.
+     */
+    private Option[] join(Option[] a1, Option[] a2) {
+        // Extend first array
+        Option[] result = Arrays.copyOf(a1, a1.length + a2.length);
+
+        // Append second array to first
+        for (int i = 0, p = a1.length; i < a2.length; i++, p++)
+            result[p] = a2[i];
+
+        return result;
+    }
+
+    public static void main(String args[]) {
+        // *DEBUG*/System.setProperty("javax.net.debug", "ssl");
+        // * DEBUG */System.setProperty("javax.net.debug", "ssl:record:packet");
+
+        new Client().runClient(args);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/CopyRectOrder.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/CopyRectOrder.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/CopyRectOrder.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/KeyOrder.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/KeyOrder.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/KeyOrder.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/MouseOrder.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/MouseOrder.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/MouseOrder.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/OrderType.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/OrderType.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/OrderType.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/ScreenDescription.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/ScreenDescription.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/ScreenDescription.java
old mode 100644
new mode 100755
index a9155e8..1c33a63
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/ScreenDescription.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/ScreenDescription.java
@@ -56,12 +56,12 @@ public class ScreenDescription {
      * Store information about server pixel format.
      */
     public void setPixelFormat(int bitsPerPixel, int depth, boolean bigEndianFlag, boolean trueColorFlag, int redMax, int greenMax, int blueMax, int redShift,
-        int greenShift, int blueShift) {
+            int greenShift, int blueShift) {
 
-        this.bytesPerPixel = (bitsPerPixel + 7) / 8;
+        bytesPerPixel = (bitsPerPixel + 7) / 8;
 
         this.bitsPerPixel = bitsPerPixel;
-        this.colorDepth = depth;
+        colorDepth = depth;
         this.bigEndianFlag = bigEndianFlag;
         this.trueColorFlag = trueColorFlag;
 
@@ -79,23 +79,23 @@ public class ScreenDescription {
     public void setPixelFormatRGBTrueColor(int bitsPerPixel) {
 
         switch (bitsPerPixel) {
-            case 8:
-                setPixelFormat(8, 8, false, false, -1, -1, -1, -1, -1, -1);
-                break;
-            case 15:
-                setPixelFormat(16, 15, false, true, 31, 31, 31, 0, 5, 10);
-                break;
-            case 16:
-                setPixelFormat(16, 16, false, true, 31, 63, 31, 0, 5, 11);
-                break;
-            case 24:
-                setPixelFormat(24, 24, false, true, 255, 255, 255, 0, 8, 16);
-                break;
-            case 32:
-                setPixelFormat(32, 24, false, true, 255, 255, 255, 0, 8, 16);
-                break;
-            default:
-                throw new RuntimeException("Unknown color depth.");
+        case 8:
+            setPixelFormat(8, 8, false, false, -1, -1, -1, -1, -1, -1);
+            break;
+        case 15:
+            setPixelFormat(16, 15, false, true, 31, 31, 31, 0, 5, 10);
+            break;
+        case 16:
+            setPixelFormat(16, 16, false, true, 31, 63, 31, 0, 5, 11);
+            break;
+        case 24:
+            setPixelFormat(24, 24, false, true, 255, 255, 255, 0, 8, 16);
+            break;
+        case 32:
+            setPixelFormat(32, 24, false, true, 255, 255, 255, 0, 8, 16);
+            break;
+        default:
+            throw new RuntimeException("Unknown color depth.");
         }
 
     }
@@ -107,8 +107,8 @@ public class ScreenDescription {
         if (height <= 0 || width <= 0)
             throw new RuntimeException("Incorrect framebuffer size: " + width + "x" + height + ".");
 
-        this.framebufferWidth = width;
-        this.framebufferHeight = height;
+        framebufferWidth = width;
+        framebufferHeight = height;
 
         callSizeChangeListeners(width, height);
     }
@@ -145,16 +145,16 @@ public class ScreenDescription {
     }
 
     public boolean isRGB888_32_LE() {
-        return (colorDepth == 24 && bitsPerPixel == 32 && redShift == 0 && greenShift == 8 && blueShift == 16 && redMax == 255 && greenMax == 255 && blueMax == 255 &&
-            !bigEndianFlag && trueColorFlag);
+        return (colorDepth == 24 && bitsPerPixel == 32 && redShift == 0 && greenShift == 8 && blueShift == 16 && redMax == 255 && greenMax == 255 && blueMax == 255
+                && !bigEndianFlag && trueColorFlag);
     }
 
     @Override
     public String toString() {
-        return "ScreenDescription [framebufferWidth=" + framebufferWidth + ", framebufferHeight=" + framebufferHeight + ", desktopName=" + desktopName +
-            ", bytesPerPixel=" + bytesPerPixel + ", depth=" + colorDepth + ", bitsPerPixel=" + bitsPerPixel + ", redShift=" + redShift + ", greenShift=" + greenShift +
-            ", blueShift=" + blueShift + ", redMax=" + redMax + ", greenMax=" + greenMax + ", blueMax=" + blueMax + ", bigEndianFlag=" + bigEndianFlag +
-            ", trueColorFlag=" + trueColorFlag + "]";
+        return "ScreenDescription [framebufferWidth=" + framebufferWidth + ", framebufferHeight=" + framebufferHeight + ", desktopName=" + desktopName
+                + ", bytesPerPixel=" + bytesPerPixel + ", depth=" + colorDepth + ", bitsPerPixel=" + bitsPerPixel + ", redShift=" + redShift + ", greenShift=" + greenShift
+                + ", blueShift=" + blueShift + ", redMax=" + redMax + ", greenMax=" + greenMax + ", blueMax=" + blueMax + ", bigEndianFlag=" + bigEndianFlag
+                + ", trueColorFlag=" + trueColorFlag + "]";
     }
 
     public void addSizeChangeListener(SizeChangeListener sizeChangeListener) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/SizeChangeListener.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/SizeChangeListener.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/SizeChangeListener.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtBellAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtBellAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtBellAdapter.java
new file mode 100755
index 0000000..c25b07f
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtBellAdapter.java
@@ -0,0 +1,77 @@
+// 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 common.adapter;
+
+import java.awt.Toolkit;
+
+import streamer.BaseElement;
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.FakeSource;
+
+public class AwtBellAdapter extends BaseElement {
+
+    public AwtBellAdapter(String id) {
+        super(id);
+        declarePads();
+    }
+
+    private void declarePads() {
+        inputPads.put(STDIN, null);
+    }
+
+    @Override
+    public void handleData(ByteBuffer buf, Link link) {
+        if (verbose)
+            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
+
+        if (buf == null)
+            return;
+
+        Toolkit.getDefaultToolkit().beep();
+    }
+
+    @Override
+    public String toString() {
+        return "Bell(" + id + ")";
+    }
+
+    /**
+     * Example.
+     */
+    public static void main(String args[]) {
+        System.setProperty("streamer.Element.debug", "true");
+
+        Element source = new FakeSource("source") {
+            {
+                incommingBufLength = 0;
+                delay = 1000;
+                numBuffers = 3;
+            }
+        };
+
+        Element sink = new AwtBellAdapter("sink");
+
+        Pipeline pipeline = new PipelineImpl("test");
+        pipeline.addAndLink(source, 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/common/adapter/AwtCanvasAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java
new file mode 100755
index 0000000..55ca8fd
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtCanvasAdapter.java
@@ -0,0 +1,171 @@
+// 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 common.adapter;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
+
+import rdpclient.rdp.ServerBitmapUpdate;
+import streamer.BaseElement;
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.Order;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import common.BitmapOrder;
+import common.BitmapRectangle;
+import common.BufferedImageCanvas;
+import common.CopyRectOrder;
+import common.OrderType;
+import common.ScreenDescription;
+
+public class AwtCanvasAdapter extends BaseElement {
+
+    protected ScreenDescription screen;
+
+    public AwtCanvasAdapter(String id, BufferedImageCanvas canvas, ScreenDescription screen) {
+        super(id);
+        this.canvas = canvas;
+        this.screen = screen;
+    }
+
+    protected BufferedImageCanvas canvas;
+
+    @Override
+    public String toString() {
+        return "AwtRdpAdapter(" + id + ")";
+    }
+
+    @Override
+    public void handleData(ByteBuffer buf, Link link) {
+        if (verbose)
+            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
+
+        Order order = buf.getOrder();
+        switch ((OrderType)order.type) {
+
+        case BITMAP_UPDATE:
+            handleBitmap((BitmapOrder)order, buf);
+            break;
+
+        case COPY_RECT:
+            handleCopyRect((CopyRectOrder)order, buf);
+            break;
+
+        default:
+            throw new RuntimeException("Order is not implemented: " + buf + ".");
+            // break;
+        }
+
+        buf.unref();
+    }
+
+    private void handleCopyRect(CopyRectOrder order, ByteBuffer buf) {
+        // TODO Auto-generated method stub
+        // Copy image
+        canvas.getOfflineGraphics().copyArea(order.srcX, order.srcY, order.width, order.height, order.x - order.srcX, order.y - order.srcY);
+
+        // Request update of repainted area
+        canvas.repaint(order.x, order.y, order.width, order.height);
+
+    }
+
+    private void handleBitmap(BitmapOrder order, ByteBuffer buf) {
+        // Draw rectangle on offline buffer
+        BufferedImage image = canvas.getOfflineImage();
+        Graphics2D g = (Graphics2D)image.getGraphics();
+
+        for (BitmapRectangle rectangle : order.rectangles) {
+            // *DEBUG*/System.out.println("["+this+"] DEBUG: Rectangle: " +
+            // rectangle.toString());
+
+            int x = rectangle.x;
+            int y = rectangle.y;
+            int width = rectangle.width;
+            int height = rectangle.height;
+            int bufferWidth = rectangle.bufferWidth;
+            int bufferHeight = rectangle.bufferHeight;
+
+            BufferedImage rectImage;
+            switch (rectangle.colorDepth) {
+            case 8: {
+                rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_BYTE_INDEXED, screen.colorMap);
+                WritableRaster raster = rectImage.getRaster();
+                raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toByteArray());
+                break;
+            }
+            case 15: {
+                rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_USHORT_555_RGB);
+                WritableRaster raster = rectImage.getRaster();
+                raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toShortArray());
+                break;
+            }
+            case 16: {
+                rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_USHORT_565_RGB);
+                WritableRaster raster = rectImage.getRaster();
+                raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toShortArray());
+                break;
+            }
+            case 24:
+            case 32: {
+                rectImage = new BufferedImage(bufferWidth, height, BufferedImage.TYPE_INT_RGB);
+                WritableRaster raster = rectImage.getRaster();
+                raster.setDataElements(0, 0, bufferWidth, bufferHeight, rectangle.bitmapDataStream.toIntLEArray());
+                break;
+            }
+            default:
+                throw new RuntimeException("Unsupported color depth: " + rectangle.colorDepth + ".");
+            }
+
+            g.setClip(x, y, width, height);
+            g.drawImage(rectImage, x, y, null);
+
+            // Request update of repainted area
+            canvas.repaint(x, y, width, height);
+        }
+
+    }
+
+    /**
+     * 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");
+        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});
+
+        Pipeline pipeline = new PipelineImpl("test");
+
+        Element bitmap = new ServerBitmapUpdate("bitmap");
+
+        BufferedImageCanvas canvas = new BufferedImageCanvas(1024, 768);
+        Element adapter = new AwtCanvasAdapter("test", canvas, null) {
+            {
+                verbose = true;
+            }
+        };
+        pipeline.addAndLink(bitmap, adapter);
+
+        bitmap.handleData(packet, null);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtClipboardAdapter.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtClipboardAdapter.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtClipboardAdapter.java
new file mode 100755
index 0000000..cc7f330
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/adapter/AwtClipboardAdapter.java
@@ -0,0 +1,57 @@
+// 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 common.adapter;
+
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+
+import streamer.BaseElement;
+import streamer.ByteBuffer;
+import streamer.Link;
+
+public class AwtClipboardAdapter extends BaseElement {
+
+    public static final String CLIPBOARD_CONTENT = "content";
+
+    public AwtClipboardAdapter(String id) {
+        super(id);
+        declarePads();
+    }
+
+    private void declarePads() {
+        inputPads.put(STDIN, null);
+    }
+
+    @Override
+    public void handleData(ByteBuffer buf, Link link) {
+        if (verbose)
+            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
+
+        if (buf == null)
+            return;
+
+        String content = (String)buf.getMetadata(CLIPBOARD_CONTENT);
+        StringSelection contents = new StringSelection(content);
+        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null);
+    }
+
+    @Override
+    public String toString() {
+        return "ClipboardAdapter(" + id + ")";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Any.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Any.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Any.java
new file mode 100755
index 0000000..2ef7c69
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Any.java
@@ -0,0 +1,78 @@
+// 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 common.asn1;
+
+import streamer.ByteBuffer;
+
+/**
+ * Any type. Don't forget to set type.
+ */
+public class Any extends Tag {
+
+    /**
+     * Raw bytes of any value.
+     */
+    public ByteBuffer value;
+
+    public Any(String name) {
+        super(name);
+    }
+
+    @Override
+    public boolean isValueSet() {
+        return value != null;
+    }
+
+    @Override
+    public long calculateLengthOfValuePayload() {
+        return value.length;
+    }
+
+    @Override
+    public void writeTagValuePayload(ByteBuffer buf) {
+        buf.writeBytes(value);
+    }
+
+    @Override
+    public void readTagValue(ByteBuffer buf, BerType typeAndFlags) {
+        long length = buf.readBerLength();
+
+        value = buf.readBytes((int)length);
+    }
+
+    @Override
+    public Tag deepCopy(String suffix) {
+        return new Any(name + suffix).copyFrom(this);
+    }
+
+    @Override
+    public Tag copyFrom(Tag tag) {
+        super.copyFrom(tag);
+        tagType = tag.tagType;
+        value = new ByteBuffer(((Any)tag).value.toByteArray());
+        return this;
+    }
+
+    @Override
+    public boolean isTypeValid(BerType typeAndFlags, boolean explicit) {
+        if (explicit)
+            return typeAndFlags.tagClass == tagClass && typeAndFlags.constructed && typeAndFlags.typeOrTagNumber == tagNumber;
+        else
+            return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Constants.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Constants.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Constants.java
new file mode 100755
index 0000000..6dacd60
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Constants.java
@@ -0,0 +1,83 @@
+// 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 common.asn1;
+
+public interface Asn1Constants {
+
+    /**
+     * Universal class type.
+     */
+    public static final int UNIVERSAL_CLASS = 0x00;
+
+    /**
+     * Application class type.
+     */
+    public static final int APPLICATION_CLASS = 0x40;
+
+    public static final int CONTEXT_CLASS = 0x80;
+
+    public static final int PRIVATE_CLASS = 0xC0;
+
+    /**
+     * Constructed type.
+     */
+    public static final int CONSTRUCTED = 0x20;
+
+    /**
+     * Mask to extract class.
+     */
+    public static final int CLASS_MASK = 0xC0;
+
+    /**
+     * Mask to extract type.
+     */
+    public static final int TYPE_MASK = 0x1F;
+
+    public static final int EOF = 0x00;
+    public static final int BOOLEAN = 0x01;
+    /**
+     * Integer primitive.
+     */
+    public static final int INTEGER = 0x02;
+    public static final int BIT_STRING = 0x03;
+    /**
+     * Octet string primitive.
+     */
+    public static final int OCTET_STRING = 0x04;
+    public static final int NULL = 0x05;
+    public static final int OBJECT_ID = 0x06;
+    public static final int REAL = 0x09;
+    public static final int ENUMERATED = 0x0A;
+    /**
+     * Sequence primitive.
+     */
+    public static final int SEQUENCE = 0x10;
+    public static final int SET = 0x11;
+    public static final int NUMERIC_STRING = 0x12;
+    public static final int PRINTABLE_STRING = 0x13;
+    public static final int TELETEX_STRING = 0x14;
+    public static final int VIDEOTEXT_STRING = 0x15;
+    public static final int IA5_STRING = 0x16;
+    public static final int UTCTIME = 0x17;
+    public static final int GENERAL_TIME = 0x18;
+    public static final int GRAPHIC_STRING = 0x19;
+    public static final int VISIBLE_STRING = 0x1A;
+    public static final int GENERAL_STRING = 0x1B;
+
+    public static final int EXTENDED_TYPE = 0x1F;
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Integer.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Integer.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Integer.java
new file mode 100755
index 0000000..678e04e
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/Asn1Integer.java
@@ -0,0 +1,116 @@
+// 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 common.asn1;
+
+import streamer.ByteBuffer;
+
+/**
+ * Variable length integer.
+ */
+public class Asn1Integer extends Tag {
+
+    public Long value = null;
+
+    public Asn1Integer(String name) {
+        super(name);
+        tagType = INTEGER;
+    }
+
+    @Override
+    public void readTagValue(ByteBuffer buf, BerType typeAndFlags) {
+        // Type is already read by parent parser
+
+        long length = buf.readBerLength();
+        if (length > 8)
+            throw new RuntimeException("[" + this + "] ERROR: Integer value is too long: " + length + " bytes. Cannot handle integers more than 8 bytes long. Data: "
+                    + buf + ".");
+
+        value = buf.readSignedVarInt((int)length);
+    }
+
+    @Override
+    public Tag deepCopy(String suffix) {
+        return new Asn1Integer(name + suffix).copyFrom(this);
+    }
+
+    @Override
+    public Tag copyFrom(Tag tag) {
+        super.copyFrom(tag);
+        value = ((Asn1Integer)tag).value;
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + "= " + value;
+    }
+
+    @Override
+    public long calculateLengthOfValuePayload() {
+        if (value <= 0xff)
+            return 1;
+        if (value <= 0xffFF)
+            return 2;
+        if (value <= 0xffFFff)
+            return 3;
+        if (value <= 0xffFFffFFL)
+            return 4;
+        if (value <= 0xffFFffFFffL)
+            return 5;
+        if (value <= 0xffFFffFFffFFL)
+            return 6;
+        if (value <= 0xffFFffFFffFFffL)
+            return 7;
+
+        return 8;
+    }
+
+    @Override
+    public void writeTagValuePayload(ByteBuffer buf) {
+        long value = this.value.longValue();
+
+        if (value < 0xff) {
+            buf.writeByte((int)value);
+        } else if (value <= 0xffFF) {
+            buf.writeShort((int)value);
+        } else if (value <= 0xffFFff) {
+            buf.writeByte((int)(value >> 16));
+            buf.writeShort((int)value);
+        } else if (value <= 0xffFFffFFL) {
+            buf.writeInt((int)value);
+        } else if (value <= 0xffFFffFFffL) {
+            buf.writeByte((int)(value >> 32));
+            buf.writeInt((int)value);
+        } else if (value <= 0xffFFffFFffFFL) {
+            buf.writeShort((int)(value >> 32));
+            buf.writeInt((int)value);
+        } else if (value <= 0xffFFffFFffFFffL) {
+            buf.writeByte((int)(value >> (32 + 16)));
+            buf.writeShort((int)(value >> 32));
+            buf.writeInt((int)value);
+        } else {
+            buf.writeInt((int)(value >> 32));
+            buf.writeInt((int)value);
+        }
+    }
+
+    @Override
+    public boolean isValueSet() {
+        return value != null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BerType.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BerType.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BerType.java
new file mode 100755
index 0000000..8e53f24
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BerType.java
@@ -0,0 +1,40 @@
+// 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 common.asn1;
+
+public class BerType {
+
+    public int tagClass;
+    public boolean constructed;
+    public int typeOrTagNumber;
+
+    public BerType() {
+    }
+
+    public BerType(int tagClass, boolean constructed, int typeOrTagNumber) {
+        this.tagClass = tagClass;
+        this.constructed = constructed;
+        this.typeOrTagNumber = typeOrTagNumber;
+    }
+
+    @Override
+    public String toString() {
+        return "BerType [tagClass=" + Tag.tagClassToString(tagClass) + ", constructed=" + constructed + ", type or tag number="
+                + Tag.tagTypeOrNumberToString(tagClass, typeOrTagNumber) + "]";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BitString.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BitString.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BitString.java
new file mode 100755
index 0000000..3323c72
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/asn1/BitString.java
@@ -0,0 +1,67 @@
+// 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 common.asn1;
+
+import streamer.ByteBuffer;
+
+public class BitString extends Tag {
+
+    /**
+     * Bit string value.
+     */
+    public ByteBuffer value;
+
+    public BitString(String name) {
+        super(name);
+        tagType = BIT_STRING;
+    }
+
+    @Override
+    public boolean isValueSet() {
+        return value != null;
+    }
+
+    @Override
+    public long calculateLengthOfValuePayload() {
+        return value.length;
+    }
+
+    @Override
+    public void writeTagValuePayload(ByteBuffer buf) {
+        buf.writeBytes(value);
+    }
+
+    @Override
+    public void readTagValue(ByteBuffer buf, BerType typeAndFlags) {
+        long length = buf.readBerLength();
+
+        value = buf.readBytes((int)length);
+    }
+
+    @Override
+    public Tag deepCopy(String suffix) {
+        return new BitString(name + suffix).copyFrom(this);
+    }
+
+    @Override
+    public Tag copyFrom(Tag tag) {
+        super.copyFrom(tag);
+        value = new ByteBuffer(((BitString)tag).value.toByteArray());
+        return this;
+    }
+
+}


Mime
View raw message