Captcha Implementation in commerce as per feasibility.
Character Verification on Registration\Forgot Password |
Captcha
Recaptcha is a free solution hosted and owned by Google.
Pros: Widely used in the industry, services based solution
really easy to impelemnt
Cons:The biggest minus on this is, if you have a strong
firewall policy where the outgoing IP/Ports for app servers are blocked. This
solution will not work as the IP addresses will change some times and hence it
might not be feasible to dynamically open up the firewalls for the new
addresses.
Pros: Really easy to implement and drop the jar files, no external webservices required. if you are using V6 and it also works with later versions of JDK hence this would work for V7. Kaptcha uses pixels and previous versions image libraries to refresh the image.
Cons: Does not support audio.
How to use in commerce?
1. Entry in web.xml for the servlet mapping, make this entry after dynacache and other OOB filters.
<servlet>
<servlet-name>Kaptcha</servlet-name>
<servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Kaptcha</servlet-name>
<url-pattern>/kaptcha</url-pattern>
</servlet-mapping>
2. The default implementation has .jpg but if you are using edge caching such as Akamai, removed tha .jpg.
3. Add the external jar file and making a corresponding entry in META_INF (I have a blog on this for reference http://www.ibmwcs.com/2011/06/adding-external-jar-file-to-wcs.html)
4. The API returns HTML collection, you can access in your javascript as follows:
var kaptchaVariable=document.getElementsByName("kaptcha").item(1).value;
5. If you need to refresh the Kaptcha implement a javascript on click and you can do HTML write attribute.
.writeAttribute('src','/webapp/wcs/stores/kaptcha?' + Math.floor(Math.random()*100) );
6. You can also implement an on the img and use the following method
$(AnchorelementPassed).down().writeAttribute('src', '/webapp/wcs/stores/kaptch?' + Math.floor(Math.random()*100) );
7. You can implement in a ajax call or a command but you can validate in validateParameters.
HttpServletRequest request =
((com.ibm.commerce.webcontroller.HttpControllerRequestObject) this
.getCommandContext()
.getRequest())
.getHttpRequest();
String kaptchaValueExpected = (String)request.getSession().
(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
Reference: http://www.google.com/recaptcha
http://code.google.com/p/kaptcha/
1. Entry in web.xml for the servlet mapping, make this entry after dynacache and other OOB filters.
<servlet>
<servlet-name>Kaptcha</servlet-name>
<servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Kaptcha</servlet-name>
<url-pattern>/kaptcha</url-pattern>
</servlet-mapping>
2. The default implementation has .jpg but if you are using edge caching such as Akamai, removed tha .jpg.
3. Add the external jar file and making a corresponding entry in META_INF (I have a blog on this for reference http://www.ibmwcs.com/2011/06/adding-external-jar-file-to-wcs.html)
4. The API returns HTML collection, you can access in your javascript as follows:
var kaptchaVariable=document.getElementsByName("kaptcha").item(1).value;
5. If you need to refresh the Kaptcha implement a javascript on click and you can do HTML write attribute.
.writeAttribute('src','/webapp/wcs/stores/kaptcha?' + Math.floor(Math.random()*100) );
6. You can also implement an on the img and use the following method
$(AnchorelementPassed).down().writeAttribute('src', '/webapp/wcs/stores/kaptch?' + Math.floor(Math.random()*100) );
7. You can implement in a ajax call or a command but you can validate in validateParameters.
HttpServletRequest request =
((com.ibm.commerce.webcontroller.HttpControllerRequestObject) this
.getCommandContext()
.getRequest())
.getHttpRequest();
String kaptchaValueExpected = (String)request.getSession().
(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
Reference: http://www.google.com/recaptcha
http://code.google.com/p/kaptcha/
Captcha can be implement in following ways:
ReplyDelete1. Recaptcha Provided by google, that will generate and validate captcha text by calling web service provided by google.
2. jCaptcha api, that will call the servlet method to generate the captcha image and validate text using Default class.
jCaptcha is not recommended api to generate and validate captcha, also its available only in its alpha version.
3. simpleCaptcha api, is recommended api to generate the captcha image and validate the text.
In respect of WCS we can implement Simple Captcha in two differnt ways.
1. Defining servlet in web.xml and calling that servlet from JSP. That will generate captcha image on application view.
2. Other way is directly calling the Object of Captcha class to generate the image. and then use variable in JSP tag to display image over applcation view page.
Second is the most recommended way over other, as if developer define servlet in web.xml and try to call the service from JSP, it will not work when working in distrubuted environement system, where web server and app servers are deployed and differnt locations. As servlet call from web server will not get transfered to app server, to genereate the captcha over jsp view page.
Reference: http://www.nataraz.in/creating-captcha-application/
ReplyDelete