Category Archives: Java

Java – Creating an RSA key pair in Java

Keys can be used for Data Encryption and Digital Signing. They can be generated by OpenSSL which i have talked about in a previous article.

Actually, the Java JDK also provides API for creating key pair. Continue reading Java – Creating an RSA key pair in Java

Java Cryptography Extension – Remove JCE Key Size Restriction

As we talked about yesterday, the default JDK has a limitation on key size which is bounded by the JCE Jurisdiction Policy.

But actually, Java provides a JCE Patch such that you can remove the restriction on key size.
The patch is called Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files which can be download at Java SE Downloads.
Continue reading Java Cryptography Extension – Remove JCE Key Size Restriction

Java Cryptography Extension – Check Maximum Allowed Key Size

In Java, there is a limitation on key size by the JCE Jurisdiction Policy. If you manipulate a private key with bit size which is larger than the limitation, it will throw a InvalidKeyException complaining about Illegal key size.

The following piece of Java code will check maximum key size of all the algorithms and print the result to the console. Continue reading Java Cryptography Extension – Check Maximum Allowed Key Size

Java – Date validation using SimpleDateFormat

I need to write a program which reads a date string. The program then archives all the data on the server with the input date as an cut off date.

The following java program is based on the tutorial in </dream.in.code>. It reads a date string, validate it and print the number of date difference between today and the input date.
Continue reading Java – Date validation using SimpleDateFormat

Java – Get the content of inputStream from HttpServletRequest

Recently, i got a support case and it is about the inconsistency of the content length declared in the http header and the actual content length of the http request.

So i modified an existing program which will get the http request and manipulate it. I add some codes such that it will get the request inputStream and count it byte by byte before the request manipulation.
Continue reading Java – Get the content of inputStream from HttpServletRequest