mirror of
https://github.com/moparisthebest/mailiverse
synced 2024-11-28 11:22:14 -05:00
makes the server check the recaptcha depending on whether there is a private key
This commit is contained in:
parent
ab9b7507ae
commit
fc9403fde6
@ -51,4 +51,6 @@ public class ConstantsServer
|
|||||||
public static final int MAXIMUM_MAIL_SIZE = 1024 * 1024 * 1;
|
public static final int MAXIMUM_MAIL_SIZE = 1024 * 1024 * 1;
|
||||||
|
|
||||||
public static final int AUTH_TIMEOUT = 45;
|
public static final int AUTH_TIMEOUT = 45;
|
||||||
|
|
||||||
|
public static final String RECAPTCHA_PRIVATE_KEY = "captcha_private_key";
|
||||||
}
|
}
|
||||||
|
@ -4,34 +4,33 @@
|
|||||||
*/
|
*/
|
||||||
package mail.streamserver;
|
package mail.streamserver;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mail.server.db.ExternalData;
|
import mail.server.db.ExternalData;
|
||||||
import mail.server.db.ExternalDataFactory;
|
import mail.server.db.ExternalDataFactory;
|
||||||
import mail.server.db.MailUserDb;
|
import mail.server.db.MailUserDb;
|
||||||
|
|
||||||
import org.apache.james.cli.probe.impl.JmxServerProbe;
|
|
||||||
|
|
||||||
import core.constants.ConstantsEnvironmentKeys;
|
import core.constants.ConstantsEnvironmentKeys;
|
||||||
|
import core.constants.ConstantsServer;
|
||||||
import core.exceptions.InternalException;
|
import core.exceptions.InternalException;
|
||||||
import core.exceptions.PublicMessageException;
|
import core.exceptions.PublicMessageException;
|
||||||
import core.server.captcha.Captcha;
|
import core.server.captcha.Captcha;
|
||||||
import core.server.mailextra.MailExtraDb;
|
import core.server.mailextra.MailExtraDb;
|
||||||
import core.srp.server.SRPServerUserSessionDb;
|
import core.srp.server.SRPServerUserSessionDb;
|
||||||
import core.util.Environment;
|
import core.util.Environment;
|
||||||
|
import core.util.ExternalResource;
|
||||||
import core.util.JSONSerializer;
|
import core.util.JSONSerializer;
|
||||||
import core.util.LogOut;
|
import core.util.LogOut;
|
||||||
import core.util.SimpleSerializer;
|
import core.util.SimpleSerializer;
|
||||||
import core.util.Strings;
|
import core.util.Strings;
|
||||||
import core.util.Triple;
|
import core.util.Triple;
|
||||||
|
|
||||||
|
|
||||||
public class MailServerSessionDb implements SRPServerUserSessionDb
|
public class MailServerSessionDb implements SRPServerUserSessionDb
|
||||||
{
|
{
|
||||||
static final boolean USE_CAPTCHA = true;
|
boolean USE_CAPTCHA =
|
||||||
|
!ExternalResource.
|
||||||
|
getTrimmedString(ConstantsServer.RECAPTCHA_PRIVATE_KEY).equals("NONE");
|
||||||
|
|
||||||
|
|
||||||
static LogOut log = new LogOut(MailServerSessionDb.class);
|
static LogOut log = new LogOut(MailServerSessionDb.class);
|
||||||
@ -39,7 +38,7 @@ public class MailServerSessionDb implements SRPServerUserSessionDb
|
|||||||
MailExtraDb payment;
|
MailExtraDb payment;
|
||||||
Captcha captcha;
|
Captcha captcha;
|
||||||
|
|
||||||
public MailServerSessionDb (MailUserDb db) throws SQLException, IOException
|
public MailServerSessionDb (MailUserDb db) throws Exception
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.captcha = new Captcha();
|
this.captcha = new Captcha();
|
||||||
|
@ -73,7 +73,7 @@ public class CaptchaResponse extends HttpServlet {
|
|||||||
{
|
{
|
||||||
String remoteAddr = request.getRemoteAddr();
|
String remoteAddr = request.getRemoteAddr();
|
||||||
ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
|
ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
|
||||||
reCaptcha.setPrivateKey(ExternalResource.getTrimmedString("captcha_private_key"));
|
reCaptcha.setPrivateKey(ExternalResource.getTrimmedString(ConstantsServer.RECAPTCHA_PRIVATE_KEY));
|
||||||
|
|
||||||
String challenge = request.getParameter("recaptcha_challenge_field");
|
String challenge = request.getParameter("recaptcha_challenge_field");
|
||||||
String uresponse = request.getParameter("recaptcha_response_field");
|
String uresponse = request.getParameter("recaptcha_response_field");
|
||||||
|
@ -1 +1 @@
|
|||||||
THIS IS THE PRIVATE KEY PROVIDED BY GOOGLE RECAPTCHA
|
NONE
|
||||||
|
Loading…
Reference in New Issue
Block a user