diff --git a/grails-app/services/com/megatome/grails/RecaptchaService.groovy b/grails-app/services/com/megatome/grails/RecaptchaService.groovy index 6d89515..9a9c5a6 100644 --- a/grails-app/services/com/megatome/grails/RecaptchaService.groovy +++ b/grails-app/services/com/megatome/grails/RecaptchaService.groovy @@ -4,6 +4,7 @@ import com.megatome.grails.recaptcha.ReCaptcha import com.megatome.grails.recaptcha.net.AuthenticatorProxy import com.megatome.grails.util.ConfigHelper import grails.util.Environment +import org.grails.config.NavigableMap /** * Copyright 2010-2018 Megatome Technologies @@ -24,8 +25,8 @@ import grails.util.Environment class RecaptchaService { boolean transactional = false def grailsApplication - private def recaptchaConfig = null - private def recap = null + private NavigableMap recaptchaConfig = null + private ReCaptcha recap = null /** * Gets the ReCaptcha config. @@ -55,7 +56,7 @@ class RecaptchaService { return this.recaptchaConfig } - private def getRecaptchaInstance() { + private ReCaptcha getRecaptchaInstance() { if (!recap) { // Public key, private key, include noscript, include script, proxy config def config = getRecaptchaConfig() @@ -76,7 +77,7 @@ class RecaptchaService { recap } - private boolean safeGetConfigValue(def value, def defaultValue) { + private boolean safeGetConfigValue(String value, boolean defaultValue) { def config = getRecaptchaConfig() if (config.containsKey(value)) { return ConfigHelper.booleanValue(config[value]) @@ -94,7 +95,7 @@ class RecaptchaService { * * @return HTML code, suitable for embedding into a webpage. */ - def createCaptcha(props) { + String createCaptcha(props) { return getRecaptchaInstance().createRecaptchaHtml(props) } @@ -105,7 +106,7 @@ class RecaptchaService { * @param props Options for rendering; lang, and loadCallback are currently supported by recaptcha. * @return HTML code, suitable for embedding into a webpage. */ - def createCaptchaExplicit(props) { + String createCaptchaExplicit(props) { return getRecaptchaInstance().createRecaptchaExplicitHtml(props) } @@ -114,7 +115,7 @@ class RecaptchaService { * @param props Options for rendering; theme, type, tabindex, callback, expired-callback are currently supported * @return */ - def createRenderParameters(props) { + String createRenderParameters(props) { return getRecaptchaInstance().createRenderParameters(props) } @@ -126,7 +127,7 @@ class RecaptchaService { * * @return HTML code, suitable for embedding into a webpage. */ - def createScriptEntry(props) { + String createScriptEntry(props) { return getRecaptchaInstance().createScriptTag(props) } @@ -139,7 +140,7 @@ class RecaptchaService { * * @return True if the supplied answer is correct, false otherwise. Returns true if ReCaptcha support is disabled. */ - def verifyAnswer(session, remoteAddress, params) { + boolean verifyAnswer(session, remoteAddress, params) { if (!isEnabled()) { return true } @@ -152,7 +153,7 @@ class RecaptchaService { /** * Get a value indicating if the ReCaptcha plugin should be enabled. */ - def isEnabled() { + boolean isEnabled() { return safeGetConfigValue('enabled', true) } @@ -161,7 +162,7 @@ class RecaptchaService { * * @param session The current session */ - def validationFailed(session) { + boolean validationFailed(session) { return (session["recaptcha_error"] != null) } @@ -171,7 +172,7 @@ class RecaptchaService { * * @param session The current session. */ - def cleanUp(session) { + void cleanUp(session) { session["recaptcha_error"] = null } } diff --git a/src/main/groovy/com/megatome/grails/recaptcha/net/AuthenticatorProxy.groovy b/src/main/groovy/com/megatome/grails/recaptcha/net/AuthenticatorProxy.groovy index d020b82..e6b5411 100644 --- a/src/main/groovy/com/megatome/grails/recaptcha/net/AuthenticatorProxy.groovy +++ b/src/main/groovy/com/megatome/grails/recaptcha/net/AuthenticatorProxy.groovy @@ -23,7 +23,7 @@ class AuthenticatorProxy { int port = -1 String username = null String password = null - private def proxy = null + private Proxy proxy = null public AuthenticatorProxy(Map map) { map.each { k,v -> if (this.hasProperty(k)) { this."$k" = v} }