Java Code Examples for net.tanesha.recaptcha.ReCaptcha#createRecaptchaHtml()

The following examples show how to use net.tanesha.recaptcha.ReCaptcha#createRecaptchaHtml() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReCaptchaService.java    From attic-rave with Apache License 2.0 6 votes vote down vote up
@Override
public String createHtml(HttpServletRequest request) {
    if (captchaEnabled) {
        if (StringUtils.isBlank(privateKey) || StringUtils.isBlank(publicKey)) {
            return invalidConfigurationMessage;
        }
        boolean secure = request.isSecure();

        ReCaptcha captcha;
        if (secure) {
            captcha = ReCaptchaFactory.newSecureReCaptcha(publicKey, privateKey, createNoScript);
        } else {
            captcha = ReCaptchaFactory.newReCaptcha(publicKey, privateKey, createNoScript);
        }

        return captcha.createRecaptchaHtml(null, null);
    }
    return "";
}
 
Example 2
Source File: AbstractContextResource.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public String getReCaptchaHtml() {
    if (!useReCaptcha()) {
        return "";
    }
    ReCaptcha c = ReCaptchaFactory.newSecureReCaptcha(
        properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false);
    return c.createRecaptchaHtml(null, null);
}
 
Example 3
Source File: UsersAction.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * Build the context for the create user mode.
 */
private String buildCreateContext(SessionState state, Context context)
{
	// put the service in the context
	context.put("service", userDirectoryService);

	String blurb = (String) state.getAttribute(CONFIG_CREATE_BLURB);
	if (!StringUtils.isEmpty(blurb))
	{
		context.put("createBlurb", blurb);
	}

	// is the type to be pre-set
	context.put("type", state.getAttribute("create-type"));

	boolean isValidatedWithAccountValidator = isValidatedWithAccountValidator(state);
	boolean isEidEditable = isEidEditable(state);

	// if the tool is configured to validate through email, we will use AccountValidator to set name fields, etc. So we indicate this in the context to hide fields that are redundant
	context.put("isValidatedWithAccountValidator", isValidatedWithAccountValidator);

	// If we're using account validator, an email needs to be sent
	// If the eid is not editable, the email will be used as the eid
	context.put("emailRequired", isValidatedWithAccountValidator || !isEidEditable);

	// password is required when using Gateway New Account tool
	// attribute "create-user" is true only for New Account tool
	context.put("pwRequired", state.getAttribute("create-user"));

	context.put("displayEid", isEidEditable);
	String value = (String) state.getAttribute("valueEid");
	if (value != null) context.put("valueEid", value);

	value = (String) state.getAttribute("valueFirstName");
	if (value != null) context.put("valueFirstName", value);

	value = (String) state.getAttribute("valueLastName");
	if (value != null) context.put("valueLastName", value);

	value = (String) state.getAttribute("valueEmail");
	if (value != null) context.put("valueEmail", value);
			
	if ((Boolean)state.getAttribute("user.recaptcha-enabled"))
	{
		ReCaptcha captcha = ReCaptchaFactory.newReCaptcha((String)state.getAttribute("user.recaptcha-public-key"), (String)state.getAttribute("user.recaptcha-private-key"), false);
        String captchaScript = captcha.createRecaptchaHtml((String)state.getAttribute("recaptcha-error"), null);
        state.removeAttribute("recaptcha-error");
        context.put("recaptchaScript", captchaScript);
	}

	return "_create";

}
 
Example 4
Source File: UsersAction.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * Build the context for the create user mode.
 */
private String buildCreateContext(SessionState state, Context context)
{
	// put the service in the context
	context.put("service", userDirectoryService);

	String blurb = (String) state.getAttribute(CONFIG_CREATE_BLURB);
	if (!StringUtils.isEmpty(blurb))
	{
		context.put("createBlurb", blurb);
	}

	// is the type to be pre-set
	context.put("type", state.getAttribute("create-type"));

	boolean isValidatedWithAccountValidator = isValidatedWithAccountValidator(state);
	boolean isEidEditable = isEidEditable(state);

	// if the tool is configured to validate through email, we will use AccountValidator to set name fields, etc. So we indicate this in the context to hide fields that are redundant
	context.put("isValidatedWithAccountValidator", isValidatedWithAccountValidator);

	// If we're using account validator, an email needs to be sent
	// If the eid is not editable, the email will be used as the eid
	context.put("emailRequired", isValidatedWithAccountValidator || !isEidEditable);

	// password is required when using Gateway New Account tool
	// attribute "create-user" is true only for New Account tool
	context.put("pwRequired", state.getAttribute("create-user"));

	context.put("displayEid", isEidEditable);
	String value = (String) state.getAttribute("valueEid");
	if (value != null) context.put("valueEid", value);

	value = (String) state.getAttribute("valueFirstName");
	if (value != null) context.put("valueFirstName", value);

	value = (String) state.getAttribute("valueLastName");
	if (value != null) context.put("valueLastName", value);

	value = (String) state.getAttribute("valueEmail");
	if (value != null) context.put("valueEmail", value);
			
	if ((Boolean)state.getAttribute("user.recaptcha-enabled"))
	{
		ReCaptcha captcha = ReCaptchaFactory.newReCaptcha((String)state.getAttribute("user.recaptcha-public-key"), (String)state.getAttribute("user.recaptcha-private-key"), false);
        String captchaScript = captcha.createRecaptchaHtml((String)state.getAttribute("recaptcha-error"), null);
        state.removeAttribute("recaptcha-error");
        context.put("recaptchaScript", captchaScript);
	}

	return "_create";

}
 
Example 5
Source File: RecaptchaAction.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
public String createFormHtml(){
    ReCaptcha rc=makeReCaptcha();
    return rc.createRecaptchaHtml(null, null);
}