Archive for January, 2010

Accept or Ignore Self Signed Certificates While reading ssl web page using Java

January 18, 2010

Turns out this is quite easy to do but hard to find the code for it. So here it is.

TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
	public java.security.cert.X509Certificate[] getAcceptedIssuers() {
		return null;
	}

	public void checkClientTrusted(X509Certificate[] certs,
			String authType) {
	}

	public void checkServerTrusted(X509Certificate[] certs,
			String authType) {
	}
} };

// Install the all-trusting trust manager
SSLContext sc;
try {
	sc = SSLContext.getInstance("SSL");
	sc.init(null, trustAllCerts, new java.security.SecureRandom());
	HttpsURLConnection
			.setDefaultSSLSocketFactory(sc.getSocketFactory());

	// Create all-trusting host name verifier
	HostnameVerifier allHostsValid = new HostnameVerifier() {
		public boolean verify(String hostname, SSLSession session) {
			return true;
		}
	};
	HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
} catch (Exception e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}

So basically what the above manager does is that it creates a socketFactory with a trust manager which allows all certificates and sets that as the default socket factory. The 2nd part is to validate a hostname which is not really important unless you are working on a server side IMO.

Open or trigger eclipse wizard without using an extension point in eclipse

January 18, 2010
Display display = Display.getDefault();
display.asyncExec(new Runnable(){
   public void run() {
      RegistryBrowserWizard wizard = new RegistryBrowserWizard();
      WizardDialog dialog = new WizardDialog(new Shell(), wizard);
      dialog.create();
      dialog.open();
   }
});

Helpful links to understand: FAQ How do I get a Display instance?

Boycott Sri Lanka – Top 10 Reasons to Boycott

January 5, 2010

There is a site on the net called http://www.boycottsrilanka.com which requests everyone to refrain from buying Sri Lankan products. I’m not sure what they are trying to achieve by doing so, but if they succeed in their objective the end result

People loosing market => Financial Issues for People => People loosing jobs => Family financial and economical issues => Anger towards the people who caused them these problems => Formation of retaliation or revenge on their minds => Short-sighted will take the revenge on innocent ppl (these innocent ppl most probably might be tamils since the boycott effort is encouraged by a set of short-sighted tamils abroad) => the innocent will become no longer innocent => accusations, bloodshed will happen => some political ppl will take advantage of the situation and say mistreatement for tamil/sinhala ppl => ppl who follow these stupid politicians will get enraged and cause more harm => minority will suffer the most because of this => for political gain political nut heads will CREATE more and more arguments and clashes. => people start getting gravely injured or killed by mistake => Friends/relatives and political gainers will take advantage of the deaths to take direct revenge by murdering => in the end alot of sri lankans will die => Disregarding that all were sri lankans and that there were sinhala and muslim ppl among who died, the propagandist will announce that tamils in sri lanka is subjected to genocide => and here we go again…

Believe me, this is the start of the eelam war of prabakaran also even though the first seed was not a boycott. But a very small thing can create so much destruction to people of a country who are trying to unite.

If you’ve decided to boycott by any chance, just take a moment and think. Would the Sri Lankan government or people give an 1/3 of the country for a race of people who are less than 1/5 of the populations just because our products are boycott? We invite to share the whole 100% of the country rather than 33.3%. Thats a better bargain I say. If someone says tamil can have better rights and better life style if they had a different country, then why not just go to south india where you have more space all are tamil. if they insist on a part of sri lanka, then look at pakistan and india. pakistan got what they wanted more than 50 years ago, but still both pakistan and indian ppl are dieing not only on borders but within their countries too. Solution is never division. its combination.

Anyway my whole reason for writing this blog is to comment on the Top 10 reasons the “boycott srilanka” are advertising.

1. Sri Lanka is one of the top “red alert” countries at risk for genocide (Genocide Prevention Project)

Are you boycotting Pakistan, Afghanistan, Iraq, Somalia…. also? They are in that list also you know. I cant find http://www.boycottpakistan.com/ on the net. If you are truly against genocide then you should carry your mission to all countries mentioned in your link. Just out of curiosity, did you start your effort only after seen the above link? or is it just a link which you found helpful to put in your site?
2. Sri Lanka was voted off United Nations Humans Rights Council in 2008 (Asian Human Rights Council)

I have nothing to say about this because I haven’t much knowledge on how UN HRC operates.
3. Sri Lanka has a history of expelling UN and human rights monitors from the country (BBC)

As far as I know no UN and human rights monitors were expelled. But UN and human rights monitors violators were expelled. They should have done what they came to do. But I’m sorry if some of them were falsely accused which I’m sure may have happened for some and I agree that it is unacceptable. But that doesn’t mean you can human rights violations are happening in every corner of the country or only to a specific race of people. In every country there is human rights violations. You just dont see them because you don’t bother to look them up. Just like you dont bother to look up the sinhalese and muslims who suffered on the hands of LTTE.
4. Sri Lanka is ranked as having the 2nd highest rate of disappearances in the world (United Nations)

An old report about 8 years ago. Even it it were true, this is no longer credible for today. So the 4th point is useless and barely applicable.
5. Sri Lanka is one of the most dangerous places for journalists (BBC)

I think all the facts in the article states that it is dangerous for journalists who are collaborating with the LTTE. So the 5th point is INCOMPLETE?
6. Tamils treated as second-class citizens in own country: they must carry identification cards (United Nations)

This sentence tells me that the person who created it has never set foot on sri lanka atleast during my lifetime. We singalese also cant go anywhere without an ID card. so its a common thing for every one. And as for second class accusation, in political arena only the prime minister and president positions have never been held by a tamil. Once even the Chief of Police was a tamil, not for forget our famouse beloved forign minister late Luxman Kadiragamar. My former training place CEO was a tamil. I have pretty good friends who are tamil when I was at school (and they still are). I dont know the claims are for a specific location of the country, so far I’m unable to see anything which proves the above accusation.
7. Culture of impunity: despite pervasive human rights violations, very few are ever held accountable (International Press Freedom Mission)

This is due to dirty politics in Sri Lanka. Cant argue with this. All Sinhala, Tamil, Muslims suffer equally because of this. But I’ve seen dirtier political actions in US/UK.
8. 130,000 + civilians denied access to freedom of movement in internment camps (Human Rights Watch)

no longer applicable.
9. 20,000+ civilian casualties just at the end of the war alone (Guardian UK)

the total for 30 year war is close to 80,000. this includes sinhalese, tamils and muslims. So what was your point again?
10. Continued restrictions on humanitarian aid in IDP camps (Washington Post)

no longer applicable.

I think these 10 reasons are applicable for US.

Trying to start learning Eclipse GEF? Here’s the best documentations I’ve found so far.

January 4, 2010

If you are looking for good GEF documentation then the chances are you already know how good GEF might be as a plugin. So straightway to the point. These steps are for java developers cause using java models you can get the full potential of GEF.

My advice,

1. Try to understand the basic architecture behind the Eclipse GEF

2. Start following a tutorial for creating an graphical editor using GEF step by step

3. Mess around with the tutorial example editor you just created.

4. Reverse engineer the example to create a simple editor of your choice

5. Start creating your editor using GEF

6. Use google and use the GEF news forum for problems which you will definitely have.

7. Take a break every 30-40 classes.

Some references

1. http://wiki.eclipse.org/GEF_Description

2. http://www.eclipsecon.org/2008/?page=sub/&id=102

3. common sense

4. best way to dig in to something

5. good luck

6. http://www.eclipse.org/forums/index.php?t=thread&frm_id=81&

7. you’ll understand what I mean when you get to this step 😉