Tuesday, September 15, 2020

Guacamole RDP - How to Redirect Printing and Map Drive

RDP printing is not really REDIRECT, but you can print to a special PDF printer auto setup by RDP session, then it will deliver to you by download.


You can never map your drives directly to an RDP session.  But you can map a special Guacamole drive for Upload and Download purpose.  



The following is an example for above setup  (some special setting needed for your connection profile)



Here we have enable printing and set the redirect printer name as “GPRINT”  and we enable the drive with name “GDRIVE”.  

Try to print something and you will get the PDF file.



The drive path set as “/home/${GUAC_USERNAME}”  and automatically create drive.  


How to upload a file from local to your RDP session.

Drag a local file to the RDP session window, it will be uploaded to this GDRIVE folder.



How to download file from RDP session to local

Drag a remote file into the special folder “Download”, you can get the file in your browser download area.


Wednesday, May 13, 2020

How to Setup REST Web Service for a MySQL Database

I want to access/update a MySQL database from Oracle.  Found the most reasonable way is using REST API. 





How to implement ZOOM API on PL/SQL with JWT Token

How to implement ZOOM API on PL/SQL


<<< UPDATE NEWS - ZOOM API DOES NOT SUPPORT JWT ANY MORE SINCE MID 2023

IGNORE THIS DOCUMENT >>>>


We adopt JWT Token instead of OAUTH2 for it is more suitable for pl/sql implementation.


Step 1. Create an email for the zoom account application (e.g. zoom@hovon.com)

Step 2.  Sign up a Zoom Marketplace Account at https://marketplace.zoom.us/ with zoom email

Step 3.  Sign in the zoom account and create an JWT app. (we will use this to generate JWT token for Zoom API access)

 

 

 

 

On App Credentials page, you can find two important information for next few steps

(API Key and API Secret).  You can copy the JWT Token here for testing.

 

Go to https://jwt.io/ and paste the JWT token on Encoded Area (Left hand side)

 

You will then check the decoded result on right hand side

If everything is good, you will find the iss: is your API Key, iat: is the token issue date and exp: is the token expiration date.


Now your jwt configuration is ready.  (Your app is allowed to invoke any Zoom APIs)

 

Step 4.  Setup Necessary environment for JWT token generation in PL/SQL

For Oracle 12 and after you can install JWT_NINJA as stated on https://github.com/morten-egan/jwt_ninja


For Oracle 10/11, you can install my fork of JWT_NINJA

https://github.com/kevincch/jwt_ninja


Step 5. Testing JWT Token Generation

Generate a jwt token valid for 90 minutes with following SQL

select jwt_ninja.jwt_generate(

        p_signature_key        => '<Zoom API Secret>'

       ,p_reg_claim_issuer        => '<Zoom API Key>'

       ,p_reg_claim_issuedat    => sysdate

                -(to_number(substr(TZ_OFFSET(SESSIONTIMEZONE),1,3))/24) -- convert to GMT

       ,p_reg_claim_expiration  => sysdate  

                                        -(to_number(substr(TZ_OFFSET(SESSIONTIMEZONE),1,3))/24) -- convert to GMT

                                        +(1/24/60*90)   -- plus 90 minutes

) as token from dual;


Go to https://jwt.io/ and paste the JWT token on Encoded Area (Left hand side)

 

You will then check the decoded result on right hand side’

If everything is good, you will find the iss: is your API Key, iat: is the token issue date and exp: is the token expiration date.


Step 6 Testing the Zoom API with JWT Token with curl command


$ curl --request GET  \

         --url 'https://api.zoom.us/v2/users/me'  \

         --header 'content-type: application/json' \

         --header 'authorization: Bearer <JWT Token Here>'


You will get similar result as following


NOW YOU JWT SHOULD WORK WELL, you can then build you own code for Zoom API implementation








Thursday, February 20, 2020

Guacamole Setup on CentOS 7

Here is a step by step guide how to install and configure Apache Guacamole on CentOS7

Step 1. Of course, you need to install a new system. During the installation, remember to set few things to avoid manual change later.

- set time zone
- set network configuration
- set storage
- select minimal server packages
- begin installation
- set root password


Step 2. After installation reboot, it's a good practice to keep your system up-to-date.


# yum update -y


Reboot


Step 3. Install some dependency packages.  The following list all packages to be installed. 

# yum install -y cairo-devel
# yum install -y libjpeg-turbo-devel
# yum install -y libpng-devel
# yum install -y libtool
# yum install -y uuid-devel


# yum install epel-release
# rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
# yum install -y ffmpeg-devel
# yum install -y freerdp-devel
# yum install -y pango-devel
# yum install -y libssh2-devel
# yum install -y libtelnet-devel
# yum install -y libvncserver-devel
# yum install -y libwebsockets-devel
# yum install -y pulseaudio-libs-devel
# yum install -y openssl-devel
# yum install -y libvorbis-devel
# yum install -y libwebp-devel

Step 4. Download Apache Guacamole Server source and get it install

you might need this tool.
# yum install -y wget


Download Source (2 ways)

download from website http://guacamole.apache.org or from github

download from website

after getting the url from browser download manager, you can download with wget ( for me, i have the url)


# wget http://apache.communilink.net/guacamole/1.1.0/source/guacamole-server-1.1.0.tar.gz
# tar -xzf guacamole-server-1.1.0.tar.gz
# cd guacamole-server-1.1.0/

download from github

# git clone git://github.com/apache/guacamole-server.git
# cd guacamole-server/
# autoreconf -fi
# ./configure --with-init-dir=/etc/init.d


You should get similar result


# make
# make install
# ldconfig

Now the Guacamole Server is ready.

Step 5. Download Apache Guacamole Client WAR

Download client from website


after getting the url from browser download manager, you can download with wget ( for me, i have the url)
# wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/guacamole/1.1.0/binary/guacamole-1.1.0.war

Step 6. Install Tomcat


# yum install -y tomcat
# yum install -y tomcat-admin-webapps
# yum install -y tomcat-webapps


# vi /usr/share/tomcat/conf/tomcat-users.xml
Uncomment these lines and change the password for admin

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user name="admin" password="**********" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
</tomcat-users>





# systemctl enable tomcat
# systemctl restart tomcat

Step 7. Open port 8080 on firewall

# firewall-cmd --add-port=8080/tcp --permanent
# firewall-cmd --reload


now your tomcat should be available
http://:8080/
mine is http://10.10.10.13:8080/


and the manager app should also work at http://10.10.10.13:8080/manager/html
After input the admin user name and  password,


# cp guacamole-1.1.0.war /usr/share/tomcat/webapps/guacamole.war


Then refresh the http://10.10.10.13:8080/manager/html
You will see the app deployed


# mkdir /etc/guacamole
# vi /etc/guacamole/guacamole.properties
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port:     4822


# vi /etc/guacamole/user-mapping.xml
(this is for testing purpose, change the red parts as needed)

<user-mapping>

   <authorize
            username="testuser"
            password="testpass123">

        <connection name="VNC TEST”>
            <protocol>vnc</protocol>
            <param name="hostname">172.16.10.10</param>
            <param name="port">5900</param>
            <param name="password">******</param>
        </connection>

        <connection name="SSH TEST">
            <protocol>ssh</protocol>
            <param name="hostname">10.10.10.25</param>
            <param name="port">22</param>
        </connection>

        <connection name="RDP TEST">
            <protocol>rdp</protocol>
            <param name="hostname">172.16.10.19</param>
            <param name="port">3389</param>
        </connection>

    </authorize>

</user-mapping>


# systemctl enable guacd
# systemctl restart tomcat guacd


Step 8.  Testing - without Database

http://10.10.10.13:8080/guacamole


Try to click any of connections for testing 
During session connected, you can use CTRL+ALT+SHIFT to call the GUACAMOLE menu for disconnections (under top right corner choose testuser->disconnect)