Package edu.stanford.bmir.protege.web.server

Source Code of edu.stanford.bmir.protege.web.server.RecaptchaServiceImpl

package edu.stanford.bmir.protege.web.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import edu.stanford.bmir.protege.web.client.rpc.RecaptchaService;
import net.tanesha.recaptcha.ReCaptchaImpl;
import net.tanesha.recaptcha.ReCaptchaResponse;

/**
* Author: Matthew Horridge<br>
* Stanford University<br>
* Bio-Medical Informatics Research Group<br>
* Date: 04/06/2012
*/
public class RecaptchaServiceImpl extends WebProtegeRemoteServiceServlet implements RecaptchaService {

    private static final String PRIVATE_KEY = "6Le8WNISAAAAAAOO9H7DqIfADsDTnppfbXUN9r1r";

    private static final String CAPTCHA_URL = "http://www.google.com/recaptcha/api/verify";

    public boolean isSuccessful(String challenge, String response) {
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey(PRIVATE_KEY);

        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(CAPTCHA_URL, challenge, response);
        if(reCaptchaResponse.isValid()) {
            return true;
        }
        else {
            return false;
        }
    }
}
TOP

Related Classes of edu.stanford.bmir.protege.web.server.RecaptchaServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.