All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.perimeterx.api.blockhandler.CaptchaBlockHandler Maven / Gradle / Ivy

There is a newer version: 6.13.0
Show newest version
package com.perimeterx.api.blockhandler;

import com.perimeterx.models.PXContext;
import com.perimeterx.models.exceptions.PXException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.IOException;

/**
 * Default captcha block handler which display captcha page on block
 * 

* Created by shikloshi on 07/07/2016. */ public class CaptchaBlockHandler implements BlockHandler { @Override public void handleBlocking(PXContext context, HttpServletResponseWrapper responseWrapper) throws PXException { String page = this.getCaptchaHtml(context); responseWrapper.setStatus(HttpServletResponse.SC_FORBIDDEN); responseWrapper.setContentType("text/html"); try { responseWrapper.getWriter().print(page); } catch (IOException e) { throw new PXException(e); } } private String getCaptchaHtml(PXContext context) { return "\n" + " \n" + " \n" + " \n" + " Access to This Page Has Been Blocked\n" + " \n" + " " + " \n" + " \n" + " \n" + "

\n" + " Access to This Page Has Been Blocked \n" + "
\n" + "
Access to '" + context.getFullUrl() + "' is blocked according to the site security policy.
Your browsing behaviour fingerprinting made us think you may be a bot.

This may happen as a result of the following: \n" + "
    \n" + "
  • JavaScript is disabled or not running properly.
  • \n" + "
  • Your browsing behaviour fingerprinting are not likely to be a regular user.
  • \n" + "
\n" + " To read more about the bot defender solution: https://www.perimeterx.com/bot-defender
If you think the blocking was done by mistake, contact the site administrator.
\n" + "
\n" + "
Block Reference: #' " + context.getUuid() + "' \n" + "
\n" + " \n" + ""; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy