com.perimeterx.api.blockhandler.DefaultBlockHandler Maven / Gradle / Ivy
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 blocking implementation - Sends 403
*
* Created by shikloshi on 03/07/2016.
*/
public class DefaultBlockHandler implements BlockHandler {
public void handleBlocking(PXContext context, HttpServletResponseWrapper responseWrapper) throws PXException {
responseWrapper.setStatus(HttpServletResponse.SC_FORBIDDEN);
responseWrapper.setContentType("text/html");
try {
responseWrapper.getWriter().print(getHtml(context));
} catch (IOException e) {
throw new PXException(e);
}
}
private String getHtml(PXContext context) {
return "\n" +
"
\n" +
" \n" +
" \n" +
" Access to This Page Has Been Blocked \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" +
"
Block Reference: #' " + context.getUuid() + "' \n" +
" \n" +
" \n" +
"";
}
}