Monday 8 September 2014

Implementing Captcha on PeopleSoft login page using JCaptcha - Part-1

In my previous post I discussed the steps to take for deploying the sample JCaptcha code within a PeopleSoft webserver and test it. In this post, I will be going through the steps to take in order to implement Captcha on the PeopleSoft login page using JCaptcha.  As this will be a long solution I'm breaking it into two parts.

Before I proceed, if you had followed the steps to deploy the sample war file and test that, you will have to undo all of the steps and bring your PeopleSoft instance to its original state.

A normal page is rendered by PeopleSoft servlet as shown below -

In essence, my captcha implementation solution approach intercepts the login request and validates the captcha challenge response before forwarding the request to PeopleSoft psp servlet as illustrated in diagram below 

At a high level, the implementation steps include - 
  1. Copying the necessary JCaptcha jar file libraries and classes
  2. Modify the PORTAL.war deployment descriptor file (web.xml)
  3. Customizing the signin.html, text.properties and error.properties
  4. Place the refresh image in the webserver image folder
  5. Create a JSP file for the captcha validation
Step1:
From the JCaptcha 2.0 war file, extract the 6 jar files highlighted in the screenshot below and place them in the lib directory of the PeopleSoft Webserver - 
In your case the lib directory will be at this location - 
 <%PS_HOME%>\webserv\<domain>\applications\peoplesoft\PORTAL.war\WEB-INF\lib  
We need only the servlet class file (SimpleImageCaptchaServlet.class) from the 7th jar file of the war file. This is the class that renders the Captcha image.
Copy/Extract the class file to this location -

 <%PS_HOME%>\webserv\<domain>\applications\peoplesoft\PORTAL.war\WEB-INF\classes\com\octo\captcha\module\servlet\image  
 in my case  
 C:\psoft\pt85302\webserv\hcm92dmo\applications\peoplesoft\PORTAL.war\WEB-INF\classes\com\octo\captcha\module\servlet\image  
Note: You will have to create these folders (octo\captcha\module\servlet\image) as it won't exist.

Step2:
Now navigate to the WEB-INF folder and open the deployment descriptor file - web.xml and add the code below -

    <servlet>  
        <servlet-name>jcaptcha</servlet-name>  
        <servlet-class>com.octo.captcha.module.servlet.image.SimpleImageCaptchaServlet</servlet-class>  
    </servlet>  
   <servlet-mapping>  
       <servlet-name>jcaptcha</servlet-name>  
       <url-pattern>/chitra_durga.jpg/*</url-pattern>  
   </servlet-mapping>  
You may change the servlet mapping as per your wish.

Verification: If you have successfully executed these steps you can restart the webserver and do a quick test by accessing the servlet that renders the captcha image as shown below.

The rest of the solution will be covered in Part-2. For comments, feedback or questions drop a note.

Regards,
Rao

No comments:

Post a Comment