Package com.oorian.recaptcha
Class ReCaptchaResponse
java.lang.Object
com.oorian.recaptcha.ReCaptchaResponse
Represents the response from the Google reCAPTCHA verification API.
Contains the verification result, score, action name, and other metadata returned by the API.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReCaptchaResponse(com.oorian.json.JsonObject json) Creates a ReCaptchaResponse from the parsed JSON returned by the Google API. -
Method Summary
Modifier and TypeMethodDescriptionReturns the action name that was passed when generating the token.Returns the timestamp of the challenge in ISO 8601 format.Returns the hostname of the site where the token was generated.doublegetScore()Returns the reCAPTCHA score.booleanReturns whether the reCAPTCHA verification was successful.
-
Constructor Details
-
ReCaptchaResponse
public ReCaptchaResponse(com.oorian.json.JsonObject json) Creates a ReCaptchaResponse from the parsed JSON returned by the Google API.- Parameters:
json- the parsed JSON response object
-
-
Method Details
-
isSuccess
public boolean isSuccess()Returns whether the reCAPTCHA verification was successful.- Returns:
trueif the token was valid
-
getScore
public double getScore()Returns the reCAPTCHA score.The score ranges from 0.0 to 1.0, where 1.0 indicates the highest confidence that the interaction is from a human. Google recommends a threshold of 0.5 as a starting point.
- Returns:
- the score (0.0 to 1.0)
-
getAction
Returns the action name that was passed when generating the token.- Returns:
- the action name, or
nullif not present
-
getChallengeTimestamp
Returns the timestamp of the challenge in ISO 8601 format.- Returns:
- the challenge timestamp
-
getHostname
Returns the hostname of the site where the token was generated.- Returns:
- the hostname
-