中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

csrf漏洞怎么修復

九三
204
2021-02-07 14:34:35
欄目: 網絡安全

csrf漏洞怎么修復

使用Java對csrf漏洞進行修復,具體方法如下:

package referer;

import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class RefererServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setCharacterEncoding("UTF-8");

response.setContentType("text/html;charset=UTF-8");

String header = request.getHeader("Referer");

//String domainName = null;

String[] domain = { "localhost", "test.localhost", "admin.localhost" };

boolean key=false;

for (int i = 0; i < domain.length; i++) {

if (header != null && header.startsWith("http://" + domain[i]) && header.endsWith(domain[i])) {

key=true;

}

}

if(key==true) {

response.getWriter().write("成功讀到打到數據");

}else{

response.getWriter().write("非法請求");

}

}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

doGet(request, response);

}

}

0
大余县| 临沭县| 江油市| 广水市| 武清区| 高清| 城固县| 湾仔区| 普兰县| 宁南县| 连平县| 绥化市| 盐边县| 旅游| 蕉岭县| 容城县| 桐城市| 丁青县| 游戏| 金华市| 偃师市| 东兴市| 长武县| 黄大仙区| 太仆寺旗| 南通市| 永修县| 阆中市| 越西县| 彭州市| 开平市| 平舆县| 新昌县| 宜兰县| 大埔县| 商河县| 额济纳旗| 镇原县| 汝州市| 响水县| 丹寨县|