ajang di waktu senggang

Latest

Configuring remoQte Server Module #Step by Step

For you who don’t know what remoQte is, this is mobile application for Nokia touch device which is developed by me (Agung Pratama) and my college friend (Affath Firdausi) to compete on Nokia Tap That App competition. This application is free and you can download it here: http://store.ovi.com/content/158796.

In this post, I will explain how to configure and run the remoQte Server Module, step by step. Hope this will help you guys who has trouble how to run the remoQte server :D .

These are the file/program you must download first:

  1. remoQte server module (http://www.mediafire.com/?oe4l3ubt4qzmv00)
  2. Install Java (http://www.java.com/en/download/)

To check whether your computer has Java, you can do this:

  1. Open cmd, by press Windows + R, and type “cmd” (without quote) and hit OK.

  2. After that, the command prompt which is a black window will appear (but in my program, this is white window :p). Type “java –version” to chech what Java version is you use.

  3. If there is an error that saying your pc doesn’t have Java, but you are sure you have install Java, then you can do this (if you use Windows 7, but if you use another OS, then you can search in google “how to add Environment Variable on your OS”):
  • Open windows explorer, and search where the Java program was put. In my computer, the Java was put on “C:\Program Files (x86)\Java” folder.
  • On that directory, there is “jre6″ folder, and inside of “jre6″ folder there is “bin” folder. Please copy that path (“C:\Program Files (x86)\Java\jre6\bin\”).
  • Right Click on My Computer icon, and click on “Properties” like below:

  • After that click on “Advanced system settings”, choose “Environment Variables”, and then just click once on “PATH” if there is one (or if you don’t have, you can create one). Click on Edit button.

  • After that, there will be a box window. On variable value, add semicolon and the path into bin folder (which was you copy before). So in my case, I will add “;C:\Program Files (x86)\Java\jre6\bin\” (without quote) into variable value.

  • Press Ok, on all window you have opened.
  • Ok, in this step, your computer can now run Java (try to test on step 1 and 2 above to check the Java version you installed).

Now, I will explain how to run remoQte server module.

  1. Extract the remoQte server .rar file. There will be 2 files (remoQte Server.jar and README.txt).
  2. On the directory where you extract the module, create new file with .bat extension. Edit that file with notepad program.

  3. Type this following command “{REMOQTE DIRECTORY}\remoQte Server.jar”, where {REMOQTE DIRECTORY} is the directory where remoQte Server.jar located. In my case, {REMOQTE DIRECTORY} is C:\Users\agung\Downloads\Compressed\remoQte_server_0.5

    Please note that the DOUBLE QUOTE on remoQte Server.jar is needed. Don’t forget to save it (by pressing Ctrl-S) :P

  4. Now, to run the run.bat, open the cmd by pressing Windows + R, and type “cmd” (without quote) and hit OK.

  5. Now, drag the “run.bat” file into cmd window, the press Enter on the cmd window. It should now run the remoQte server :D

  6. Change the access password and port number if you want. But there is the default value on port number, so you don’t have to change it. Click the “Start Server” button, and you may connect your phone into pc/laptop’s wifi.

    Now, you can use the remoQte application. If you have trouble on configuring the server module, please leave comment here :D .

    Enjoy :D

Passing Parameter using HTTP Post on Blackberry

Well, passing parameter using HTTP Get method is very simple. You manually put your parameter on your url like: http://www.google.co.id/search?ie=UTF-8&q=remoQte. On that url, there are 2 parameters, ie and q where ie’s value is UTF-8 and q’s value is remoQte. But sometimes, you don’t want to explicitly put your parameter on the url (maybe the parameter value is some sensitive data, like username, password, credit-card, etc). So, there is another approach and this approach use POST method as passing parameter. Instead of passing parameter via url, POST method passing parameter via Body message on HTTP (or HTTPS, depends on the protocol used by the server) request.

I will explain how to pass the parameter using POST method on Blackberry.

This is how it looks like (my explanation is inline with the source code below):

URLEncodedPostData postData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
//passing q’s value and ie’s value
postData.append("q", "remoQte");
postData.append("ie", "UTF-8");

ConnectionFactory conFactory = new ConnectionFactory();
ConnectionDescriptor conDesc = null;
try{
	conDesc = conFactory.getConnection("http://www.google.co.id/search");
}catch(Exception e){
	System.out.println(e.toString()+":"+e.getMessage());
}
String response = ""; // this variable used for the server response
// if we can get the connection descriptor from ConnectionFactory
if(null != conDesc){
	try{
		HttpConnection connection = (HttpConnection)conDesc.getConnection();
		//set the header property
		connection.setRequestMethod(HttpConnection.POST);
		connection.setRequestProperty("Content-Length",	Integer.toString(postData.size())); //body content of post data
		connection.setRequestProperty("Connection", "close"); // close the connection after success sending request and receiving response from the server
		connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // we set the content of this request as application/x-www-form-urlencoded, because the post data is encoded as form-urlencoded(if you print the post data string, it will be like this -> q=remoQte&ie=UTF-8).

		//now it is time to write the post data into OutputStream
		OutputStream out = connection.getOutputStream();
		out.write(postData.getBytes("UTF-8"));
		out.flush();
		out.close();

		int responseCode = connection.getResponseCode(); //when this code is called, the post data request will be send to server, and after that we can read the response from the server if the response code is 200 (HTTP OK).
		if(responseCode == HttpConnection.HTTP_OK){
			//read the response from the server, if the response is ascii character, you can use this following code, otherwise, you must use array of byte instead of String
			InputStream in = connection.getInputStream();
			StringBuffer buf = new StringBuffer();
			int read = -1;
			while((read = in.read())!= -1)
				buf.append((char)read);
			response = buf.toString();
		}

		//don’t forget to close the connection
		connection.close();

	}catch(Exception e){
		System.out.println(e.toString()+":"+e.getMessage());
	}
}

Cara Instant Menerapkan Enkripsi SSL/TSL pada Halaman JSP GlassFish (Self Signed Certificate)

Tulisan ini saya bikin supaya kalau kelupaan cara konfigurasinya, tidak perlu repot-repot googling kesana kemari :D .

Apa itu SSL/TSL? Definisi formalnya tidak akan saya jelaskan di sini, karena Anda dapat googling sendiri dan begitu banyak resource di sana :D . Tapi secara singkat, enkripsi SSL/TSL banyak digunakan pada web aplikasi, yaitu contohnya ketika Anda melakukan login pada YahooMail. Enkripsi pada web aplikasi biasanya digunakan ketika ada data-data sensitive yang akan ditransfer dari client (browser) dan ke server, dan vice versa.Pada contoh YahooMail tadi, ketika Anda akan melakukan login, maka data sensitive tersebut berupa username dan password. Protocol yang digunakan dalam menggunakan enkripsi SSL/TSL ini adalah HTTPS. Coba Anda perhatikan link pada browser Anda, pasti berupa protocol https, bukan http seperti biasanya. Algoritma yang dipakai biasanya RSA/DSA 128 atau 256 bit.

Awalnya saya sempat googling bagaimana caranya menerapkan enkripsi SSL/TSL pada halaman JSP pada GlassFish Server. Sempat bikin frustasi juga, karena solusi-solusi yang saya dapatkan terlalu simple dan pada awalnya saya berpikiran tidak mungkin se-simple solusi tersebut. Menurut saya pasti ada perubahan pada source code dari aplikasi. Dan ternyata dugaan saya salah, hehe.

Oke caranya se-simple berikut:

  1. Jalankan GlassFish Server anda dan buat web aplikasi.
  2. Coba jalankan web aplikasi Anda (kalau saya menggunakan Netbeans, sehingga bisa langsung memakai tombol “Run”).


    Pada screenshot di atas, tampak bahwa port yang dipakai pada server GlassFish adalah 8080, dan itu masih menggunakan protocol http.

  3. Sekarang coba Anda ganti port dari 8080 ke 8181, dan ganti protocol http menjadi https di link browser Anda. Apa yang terjadi?


    Ya, ternyata pada default instalasi GlassFish server, port 8181 dapat digunakan ketika memerlukan security. Jadi dapat Anda lihat, protocol yang dipakai adalah https. Namun pada tahap ini web aplikasi Anda dapat diakses menggunakan kedua protocol tersebut (http dan https dengan kedua port yang berbeda). Tentu saja kita tidak ingin hal yang seperti ini. Oke saya lanjutkan cara bagaimana men-disable http-listener pada port 8080 (tanpa enkripsi SSL) dan hanya memakai port 8181 saja.

  4. Buka link “localhost:4848″ pada browser Anda untuk mengaktifkan GlassFish Administrator Console. Awalnya agak lama ketika loading, jadi tunggu saja :D
  5. Lalu pada panel kiri, ekspand “Network Config” -> “Network Listeners”


    Dapat dilihat terdapat 3 buah http-listener, yaitu admin-listener pada port 4848 (untuk admin console), http-listener-1 pada port 8080 (tanpa enkripsi SSL), dan http-listener-2 pada port 8181 (dan ini defaultnya sudah memakai enkripsi SSL TSL).

  6. Klik pada link http-listener-1, pada tab “General” akan terdapat pilihan “Status” yang awalnya ada terpilih Enabled. Nah, coba hilangkan centang Enabled ini dan tekan Save. Maka secara otomatis http-listener-1 ini menjadi tidak aktif, dan satu-satunya protocol yang dipakai adalah https pada port 8181.

    Note:

    1. Anda bisa mengubah port number dari 8181 menjadi port number yang lainnya dengan cara meng-klik pada link http-listener-2 dan disitu terdapat pilihan untuk mengubah port number.
    2. Certificate yang dipakai dalam mekanisme SSL/TSL ini pada defaultnya adalah self signed yang diberi alias “s1as” oleh GlassFish. Anda dapat mengubah segala macam konfigurasi untuk certificate, keystore, alias name dari keystore Anda pada tab “SSL” dari http-listener yang bersangkutan. Jangan lupa menaruh file keystore yang anda punya pada domain tersebut.
    3. Anda dapat mengoprek-oprek lebih lanjut bagaimana cara membuat keystore sendiri dan bagaimana cara konfigurasinya ke GlassFish pada link berikut: http://computersplace.net/microsoft-releated/windows-server-howto/create-certificate-keytool-glassfish.html

    Oke, sekian tutorial singkat dari saya. Kalau ada kesalahan mohon dikoreksi :D

Aplikasi remoQte Nokia (Free!)

Apa itu remoQte?

remoQte adalah aplikasi mobile, yang saat ini hanya tersedia pada platform Nokia, yang menjalankan desktop/laptop dengan menggantikan fungsi touchpad

Logo Aplikasi remoQte

dan keyboard. Contoh kegunaan dari aplikasi ini adalah  saat kamu sedang melakukan presentasi menggunakan laptop/desktop, namun kamu tetap harus bergerak aktif. Didukung dengan desain yang bagus dan rapi, serta performance yang terus ditingkatkan, aplikasi ini tidak rugi untuk dicoba.

Untuk menjalankan aplikasi ini, kamu akan mendownload 2 file, yaitu pada handset Nokia dan satu file lagi dijalankan pada laptop/desktop. Agar aplikasi ini dapat berjalan, handset Nokia-mu harus terkoneksi secara wireless dengan laptop-mu. Untuk melihat detail lebih lanjut, lebih baik silahkan lihat ke link berikut: http://store.ovi.com/content/158796#/content/158796/reviews.

Oiya, aplikasi ini dibuat oleh developer Indonesia lho dan gratis, hehe :D . Mari kita dukung :)

Berikut screenshot dari remoQte:

Halaman Configurasi

Touchpad Mode

Mode Keyboard

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Cara Memparsing XML Menggunakan Java

Untuk yang belum mengetahui apa itu xml, sebaiknya baca terlebih dahulu di sini.

Untuk membaca string/file xml di android, caranya sama seperti menggunakan Java yaitu menggunakan library yang ada di Java JDK. Misalkan kita mempunya file employee.xml seperti berikut :

employee.xml

Tag <world>, <company>, <employee>, <firstname>, dan <lastname> disebut element. Setiap element harus memiliki penutup seperti </nama_tag>. Di dalam xml, harus ada persis 1 root element, dari contoh di atas root element adalah <world>.

Pada gambar di atas, itu adalah isi dari file employee.xml. Saya akan menunjukkan bagaimana cara membaca informasi dari xml tersebut menggunakan Java.

Method parser di atas menerima parameter string berupa nama file input xml.

 NodeList companyList = doc.getElementsByTagName("company");
 

Pemanggilan doc.getElementsByTagName(“company”) akan mengembalikan semua object yang merupakan element <company>. Jadi companyList akan memegang reference mengenai informasi semua element dengan tag <company>.

 Element company = (Element) companyList.item(i);
 

Kode di atas akan mengembalikan node/element company ke-i.

Kemudian, dari company tersebut, kita akan mendapatkan semua list employee yang ada di company itu. Hal ini ditunjukkkan dengan :

 NodeList employeeList = company.getElementByTagName("employee");
 

Dari employeeList itu, kita akan mengakses element firstname dan lastname dari masing-masing employee.

 NodeList firstNameList = employee.getElementsByTagName("firstname");
 Node firstName = ((Element)firstNameList.item(0)).getChildNodes().item(0);
 System.out.println("First name : "+firstName.getNodeValue());

NodeList lastNameList = employee.getElementsByTagName("lastname");
 Node lastName = ((Element)lastNameList.item(0)).getChildNodes().item(0);
 System.out.println("Last name : "+lastName.getNodeValue());
 

Di sini, firstNameList(0) dan lastNameList(0) adalah element firstname dan lastname, karena masing-masing employee hanya ada 1 element fisrtname dan lastname. Namun setelah mendapatkan element dari fisrtname dan lastname, kita belum bisa mengakses text di dalam element tersebut. Text di dalam tag <firstname>Text</firstname> bukanlah element, sehingga hanya bisa diakses dengan cara getChildNode().item(0). Di sini terlihat bahwa sebuah element di xml, bisa direpresentasikan sebagai object bertipe Element maupun Node, tetapi text dari element adalah Node dan bukan Element (contoh: Text pada <First>Text</First> adalah Node, bukan Element, tetapi First bisa merupakan dua-duanya).

Untuk membuktikan apakah method parser telah berjalan dengan benar, saya telah membuat program yang akan memanggil method parser untuk mencoba memparsing informasi dari file xml tersebut:



 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import java.util.*;import java.io.*;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 public class Parser
 {
public static void main(String args[]) throws Exception
{

String fileInput = args[0];
parser(fileInput);
}

// Taruh implementasi method parser di sini

}


 

 

Kemudian compile file Parser.java dan jalankan dengan command:  java Parser employee.xml

Hasil screenshot :

Follow

Get every new post delivered to your Inbox.