Google reCAPTCHA 2 Component for Vaadin
Provides a simple Google reCAPTCHA v2 component for Vaadin. See https://developers.google.com/recaptcha/ for more information.
Usage
-
Generate your reCAPTCHA keys on http://www.google.com/recaptcha/intro/index.html
-
Include the artifact in your POM:
<dependency> <groupId>com.anton-johansson<groupId> <artifactId>vaadin-recaptcha</artifactId> <version>2.0.0</version> </dependency>
-
Include the reCAPTCHA JavaScript in your UI:
@JavaScript("https://www.google.com/recaptcha/api.js") public class CustomUI extends UI { ... }
-
Add the
Recaptcha
-component to your UI:String siteKey = "..."; String secretKey = "..."; Recaptcha captcha = new Recaptcha(siteKey, secretKey); layout.addComponent(captcha);
-
Optionally set extra properties on your component:
captcha.setType(RecaptchaType.AUDIO); captcha.setTheme(RecaptchaTheme.DARK); captcha.setSize(RecaptchaSize.COMPACT);
-
Validate the user input:
if (!captcha.isVerified()) { ... }
License
Apache License © Anton Johansson