Skip to end of metadata
Go to start of metadata
Table of Contents

This document describes integrating reCaptcha with CAS. reCaptcha is a free CAPTCHA service that helps to digitize books, newspapers and old time radio shows. This tutorial uses the recaptch4j library to access the reCaptcha service. The version of CAS used in this tutorial is 3.4.11. This tutorial was based on another by Axel Mendoza Pupo that covered JCAPTCHA integration.


The following changes need to be made to WEB-INF/login-webflow.xml:

Replace view-state "viewLoginForm" with:
Replace action-state "realSubmit" with:
Add action-states:
Add decision-state:

Implement CaptchaErrorCountAction


Implement CaptchaValidateAction

Spring Configuration

Add the following file to WEB-INF/spring-configuration:


Note the reCaptchaPublicKey is exposed in the context here as a bean for reference in the view.

Add reCaptcha keys to properties file

Add the recaptcha.private.key and recaptcha.public.key properties to src/main/resources/

Add reCaptcha to casLoginView.jsp


Note the reCaptchaPublicKey bean is referenced here.

Add reCaptcha4j dependency in pom.xml

  • No labels