2个web应用集成问题解决

需求描述如下:

 

2台机器部署了2个web应用,A应用需要访问B应用的URL。为了保证URL不会让任意用户随便粘贴就可以访问,需要在B应用上加上filter拦截请求,并进行权限校验。A应用的URL给用户看来是一个中间跳转页面的URL。在这个中间页面,添加hidden的value,在B应用的filter端进行value的校验。代码如下:

 

<%@ page language="java" contentType="text/html; 

charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
	<head>
		<title></title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

		<script type="text/javascript">
		function init(){
			document.getElementById('myForm').action="http://localhost:8080/ext2.2/Filter.jsp"
			document.getElementById('myForm').submit();
		}
		</script>
	</head>
	<body οnlοad="init()">
		<form method="post" id="myForm">
			<input type="hidden" name="key" id="key" value="MERKTLTTOR">
		</form>
	</body>
</html>

 

 

 

 

<%@ page language="java" contentType="text/html; 

charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
	<head>
		<title></title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

		<script type="text/javascript">
		function init (){
			<%
			String key=request.getParameter("key");
			if(!"MERKTLTTOR".equals(key)){
			%>
				alert('不允许访问');
			<%
			}
			%>
		}
		</script>
	</head>
<body οnlοad="init()">
		<form method="post" id="myForm">
			<input type="hidden" name="key" id="key" value="MERKTLTTOR">
		</form>
	</body>
</html>

 

 

 

这是filter页面,实际中可以是真正的过滤器filter。

中间页面采用post提交,用户在url中看不到提交的hidden。

 

中间页面的form的action可以用request.getParamter()获取

 

当然value可以采用一些加密算法进行加密。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值