本文整理汇总了Java中net.tanesha.recaptcha.ReCaptcha.createRecaptchaHtml方法的典型用法代码示例。如果您正苦于以下问题:Java ReCaptcha.createRecaptchaHtml方法的具体用法?Java ReCaptcha.createRecaptchaHtml怎么用?Java ReCaptcha.createRecaptchaHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.tanesha.recaptcha.ReCaptcha
的用法示例。
在下文中一共展示了ReCaptcha.createRecaptchaHtml方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHtml
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
@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 "";
}
示例2: doGet
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String cacheKey = "page-contact";
String output = null;
Cache cache = CacheSingleton.getInstance().getCache();
if (cache.containsKey(cacheKey)) {
output = (String) cache.get(cacheKey);
} else {
ConfigManager configManager = ConfigManager.getInstance();
ReCaptcha captcha = ReCaptchaFactory
.newReCaptcha(
configManager
.getValue(ConfigManager.RECAPTCHA_PUBLIC_KEY),
configManager
.getValue(ConfigManager.RECAPTCHA_PRIVATE_KEY),
false);
String captchaScript = captcha.createRecaptchaHtml(
req.getParameter("error"), null);
VelocityContext context = prepareContext(req);
context.put(
"pageTitle",
"Contact form and information"
+ configManager
.getValue(ConfigManager.WEBSITE_TITLE_SUFFIX));
context.put("htmlCaptcha", captchaScript);
output = generateTemplate("contact.vm", context);
cache.put(cacheKey, output);
}
writeResponse(output, resp);
}
示例3: createCaptchaHtml
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
public String createCaptchaHtml() {
if (config.hasCaptchaKeys()) {
ReCaptcha reCaptcha = ReCaptchaFactory.newSecureReCaptcha(config.reCaptchaPublicKey(), config.reCaptchaPrivateKey(), false);
return reCaptcha.createRecaptchaHtml(null, null);
}
return "";
}
示例4: getReCaptchaHtml
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
public String getReCaptchaHtml() {
if (!useReCaptcha()) {
return "";
}
ReCaptcha c = ReCaptchaFactory.newSecureReCaptcha(
properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false);
return c.createRecaptchaHtml(null, null);
}
示例5: buildCreateContext
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
/**
* 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";
}
示例6: createFormHtml
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
public String createFormHtml(){
ReCaptcha rc=makeReCaptcha();
return rc.createRecaptchaHtml(null, null);
}
示例7: getText
import net.tanesha.recaptcha.ReCaptcha; //导入方法依赖的package包/类
@Override protected String getText(final Arguments arguments, final Element element, final String attributeName) {
final String recaptchaPublicKey = "6LceYuESAAAAAG-s2C1bzURTlpt6niMTMmnHTKuT";
final String recaptchaPrivateKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
final ReCaptcha captcha = ReCaptchaFactory.newReCaptcha(recaptchaPublicKey, recaptchaPrivateKey, false);
return captcha.createRecaptchaHtml(null, null);
}