Search in sources :

Example 6 with CaptchaPreValidationResponse

use of org.wso2.carbon.identity.captcha.connector.CaptchaPreValidationResponse in project identity-governance by wso2-extensions.

the class UsernameRecoveryReCaptchaConnector method preValidate.

@Override
public CaptchaPreValidationResponse preValidate(ServletRequest servletRequest, ServletResponse servletResponse) throws CaptchaException {
    CaptchaPreValidationResponse preValidationResponse = new CaptchaPreValidationResponse();
    String path = ((HttpServletRequest) servletRequest).getRequestURI();
    HttpServletResponse httpServletResponse = ((HttpServletResponse) servletResponse);
    if (CaptchaUtil.isPathAvailable(path, RECOVER_USERNAME_URL)) {
        httpServletResponse.setHeader("reCaptcha", "conditional");
        preValidationResponse.setCaptchaValidationRequired(true);
    }
    return preValidationResponse;
}
Also used : CaptchaPreValidationResponse(org.wso2.carbon.identity.captcha.connector.CaptchaPreValidationResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

CaptchaPreValidationResponse (org.wso2.carbon.identity.captcha.connector.CaptchaPreValidationResponse)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Property (org.wso2.carbon.identity.application.common.model.Property)2 CaptchaClientException (org.wso2.carbon.identity.captcha.exception.CaptchaClientException)2 CaptchaException (org.wso2.carbon.identity.captcha.exception.CaptchaException)2 CaptchaHttpServletRequestWrapper (org.wso2.carbon.identity.captcha.util.CaptchaHttpServletRequestWrapper)2 IdentityGovernanceException (org.wso2.carbon.identity.governance.IdentityGovernanceException)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)1 User (org.wso2.carbon.identity.application.common.model.User)1 CaptchaConnector (org.wso2.carbon.identity.captcha.connector.CaptchaConnector)1 CaptchaPostValidationResponse (org.wso2.carbon.identity.captcha.connector.CaptchaPostValidationResponse)1 CaptchaServerException (org.wso2.carbon.identity.captcha.exception.CaptchaServerException)1 CaptchaHttpServletResponseWrapper (org.wso2.carbon.identity.captcha.util.CaptchaHttpServletResponseWrapper)1