我已经编写了一个servlet过滤器,我试图获取自定义header = samlRequest的值,从其他客户端/邮递员chrome插件获取samlRequest的值,但使用ajax调用我已经提供samlRequest键和它的值,但在java中,我正在获得唯一的关键samlRequest在“访问控制请求头”,如何获得samlRequest的价值。如何在java中获取标头值
$.ajax({
url: "http://indlin500.corp.test.com:31000/test/Portal/index.html",
type: "GET",
headers: { 'samlRequest': 'eJzVWVlz4roSfs6/oJhHJvECBkMRTsk2+2ow68stY8u2wBuWjQ2//srsyUlmJufOramTSjm41f '},
beforeSend: function(xhr){xhr.setRequestHeader('samlRequest', 'eJzVWVlz4roSfs6/oJhHJvECBkMRTsk2+2ow68stY8u2wBuWjQ2//srsyUlmJufOramTSjm41f ');},
success: function() { alert('Success!' + authHeader); }
});
FirewalledRequest [ [email protected] [OPTIONS /AmdocsOSS/Portal/index.html HTTP/1.1连接:保活 访问控制请求-方法:GET产地:http://10.19.121.17:7001 的User-Agent:Mozilla的/ 5.0(Windows NT的6.1; WOW64)为AppleWebKit/537.36 (KHTML,例如Gecko)Chrome浏览器/ Safari浏览器55.0.2883.87/537.36 访问控制请求报头:授权,samlrequest, x-partnerkey接受:/ DNT:1推荐人: http://10.19.121.17:7001/authentication-uxf-login-0.0.1-SNAPSHOT/customLoginPage.html接受编码:gzip,紧缩,SDCH接受语言:EN-US,恩,我已经提供了Q = 0.8 ]
使用Chrome其余客户端插件,我与价值的头越来越samlRequest 。
FirewalledRequest [ [email protected] [GET /AmdocsOSS/Portal/index.html HTTP/1.1连接:保活 缓存控制:无缓存samlRequest:eJzVWVlz4roSfs6/oJhHJvECBkMRTsk2 + 2ow68stY8u2wBuWjQ2 // srsyUlmJufOramTSjm41f的User-Agent:Mozilla的/ 5.0 (Windows NT的6.1; WOW64)为AppleWebKit/537.36(KHTML,例如Gecko) 铬/ 55.0.2883.87 Safari浏览器/ 537.36邮差令牌: ce7765d0-94b5-a1e1-d6ba -2abada3dfdd6 Accept:/ DNT:1 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-CN,en; q = 0.8
]
您需要将您的请求转换为“HttpServletRequest”,并且您将拥有getHeader方法。 https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html – neomega