The purpose of this problem is to test your knowledge of Filters: how to write and configure a Filter in a J2EE environment. You will also be tested on general problem–solving skills; specifically, your ability to incorporate into your project existing tools/third-party libraries with which you may not have previous familiarity.
You are to developer a basic Message Queuing system, which will receive text messages (perhaps via HTTP POST :) and simply add them to a Queue (stored in memory on the server). On HTTP GET request, your system should simply return the next message from the Queue, or inform the User that the Queue is empty (hint: one Servlet should be sufficient for this).
Your client page layout should be very simple and should contain only the components that are necessary to solve the problem (no extra formatting stuff please). Figure 1 shows a reasonable UI design for this problem.
After you have this basic setup working, you should address the issue of security: we want our messages to be encrypted prior to being saved on the message queue. Consequently, they also need to be decrypted on the way out of the queue, so that the client is not affected by the change in the way messages are stored.
To implement encryption/decryption functionality, you should use Jasypt (http://www.jasypt.org/) – a java library with basic encryption capabilities. The project’s main page contains all the necessary information on how to incorporate this library into your project; here is a simple code snipped showing how to perform text encryption/decryption using Jasypt:
String userPassword=”PassWord ”; String message = ”Some text which i s to be encrypted . . . ” ; //Encrypt BasicTextEncryptor textEncryptor = new BasicTextEncryptor ( ) ; textEncryptor . setPassword ( userPassword ) ; String myEncryptedText = textEncryptor . encrypt ( message ) ; System . out . println (” Encrypted text :\n”+myEncryptedText ) ; //Decrypt BasicTextEncryptor textDecryptor = new BasicTextEncryptor ( ) ; textDecryptor . setPassword ( userPassword ) ; String plainText = textDecryptor . decrypt ( myEncryptedText ) ; System . out . println (” Decrypted text :\n”+plainText ) ;
![]() |
Figure 1: A Reasonable User Interface Design |