I always need to reset Netbeans JDK Home whenever I install new JDK version, this serves as my own note to remember:-
To reset, change 'netbeans_jdkhome' entry in {NETBEANS_INSTALL_FOLDER}/etc/netbeans.conf.
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Wednesday, November 3, 2010
Thursday, December 18, 2008
Email, How Reliable is it?
Email is one of the most important application in Internet today beside Web. However, it has become a channel where hackers target to steal confidential information such as login info from user. One of the most popular trick is to masquerade and send a fake email, saying the user account is going to expire and ask the user to login with a fake hyperlink, which link to a fake page with similar design to the real login page.
From technical point of view, how easy to send a fake email? The answer to this question is : 'It's very simple'.
You do not need to write a C program, BackTrack 3 or any hacker tool. You can easily do it with high level language such as Java. It depends on how your email provider securing their SMTP server, but in my case, most of the companies that I have worked with is having their SMTP that you can easily send a fake mail.
At very basic level, these few lines of Java code using Spring Framework can masquerade as 'Your Boss' and send out an email to your colleague saying that he is fired:-
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("mail.yourcompany.com");
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom("Boss<yourboss@yourcompany.com>");
helper.setTo("your_colleague@yourcompany.com");
helper.setSubject("You're Fired!");
helper.setText("I am very unhappy with your face, you're fired!!!");
You still will be able to find out which machine this email is sent from if you examine the email's properties. We joked with one of our colleague years ago with this. She was stunned and we quickly clarified with her before any bad thing happens next, it is sin. However, this shows that most people 'TRUST' email, and they believe it.
Do you believe your email?
From technical point of view, how easy to send a fake email? The answer to this question is : 'It's very simple'.
You do not need to write a C program, BackTrack 3 or any hacker tool. You can easily do it with high level language such as Java. It depends on how your email provider securing their SMTP server, but in my case, most of the companies that I have worked with is having their SMTP that you can easily send a fake mail.
At very basic level, these few lines of Java code using Spring Framework can masquerade as 'Your Boss' and send out an email to your colleague saying that he is fired:-
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("mail.yourcompany.com");
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom("Boss
helper.setTo("your_colleague@yourcompany.com");
helper.setSubject("You're Fired!");
helper.setText("I am very unhappy with your face, you're fired!!!");
You still will be able to find out which machine this email is sent from if you examine the email's properties. We joked with one of our colleague years ago with this. She was stunned and we quickly clarified with her before any bad thing happens next, it is sin. However, this shows that most people 'TRUST' email, and they believe it.
Do you believe your email?
Thursday, December 11, 2008
Strange Oracle Error : ORA-12505
I have been using Oracle 10g R2 for development for quite a while. However, when I was starting my application server from Eclipse today (not the first start, it should be near the 10th time after my machine boot in the morning), an exception is thrown saying:-
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl
This seems to be an TNS error, but I am very sure my last startup works and I never touched anything in Oracle since my last application server startup. I tried with tnsping orcl, it works and I have got no idea what's the cause. I tried restarting the TNS listener, oracle server itself as well as my Eclipse, nothing works
Finally, I decided to reboot my machine. And you know what, it works after reboot. Strange?
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl
This seems to be an TNS error, but I am very sure my last startup works and I never touched anything in Oracle since my last application server startup. I tried with tnsping orcl, it works and I have got no idea what's the cause. I tried restarting the TNS listener, oracle server itself as well as my Eclipse, nothing works
Finally, I decided to reboot my machine. And you know what, it works after reboot. Strange?
Wednesday, December 10, 2008
Apache Derby to Handle Case Insensitive Search
I have been using Apache Derby which can be bundled easily with the 'Lite' version of the product that I am developing in Flex/Java. The fact that by default Derby gives different result set for "where name='chua'" and "where name='CHUA'" has been an egg on my face. Using UPPER/LOWER with function index doesn't sounds good solution to me, neither to my boss. Derby folks are actually aware of the importance to support this, and several proposals have been made in the mailing list, but none have been implemented yet.
However, I am lucky enough to find a solution that I like with Collator here:-
http://blogs.sun.com/kah/entry/user_defined_collation_in_apache
The approach is to create a custom collator provider which returns collator with strength of SECONDARY, which gives case-insensitive comparison for EQUAL and LIKE.
Copied from the blog above:-
"
And the sample custom collator provider:-
"
Using territory based collation disables query optimization when doing LIKE query, I don't know the reason behind it. In the application that I am building, the user is allowed to use every single column to search and filter data. But, not every single column is indexed. ;-)
However, I am lucky enough to find a solution that I like with Collator here:-
http://blogs.sun.com/kah/entry/user_defined_collation_in_apache
The approach is to create a custom collator provider which returns collator with strength of SECONDARY, which gives case-insensitive comparison for EQUAL and LIKE.
Copied from the blog above:-
"
- Create a class that extends
java.text.spi.CollatorProviderand returns a collator that orders strings the way you want it to - Create a text file named META-INF/services/java.text.spi.CollatorProvider which contains one line with the name of your collator provider class
- Put the compiled class file and the text file in a jar file which you drop into your JRE's lib/ext directory or in one of the directories specified by the
java.ext.dirsproperty
And the sample custom collator provider:-
"
public class MyCollatorProvider extends CollatorProvider {
public Locale[] getAvailableLocales() {
return new Locale[] {
new Locale("en", "US", "caseinsensitive")
};
}
public Collator getInstance(Locale locale) {
Collator c = Collator.getInstance(Locale.US);
// Ignore tertiary differences (case differences)
c.setStrength(Collator.SECONDARY);
return c;
}
}
"
Make sure the custom collator provider jar is in java.ext.dirs for JRE that starts Derby. Create the database using connection string similar to following:-'jdbc:derby:NoCaseDB;territory=en_US_caseinsensitive;
collation=TERRITORY_BASED;create=true'
Using territory based collation disables query optimization when doing LIKE query, I don't know the reason behind it. In the application that I am building, the user is allowed to use every single column to search and filter data. But, not every single column is indexed. ;-)
Subscribe to:
Posts (Atom)
