« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
| 公告 |
戒除浮躁,读好书,交益友 |
Blog信息 |
blog名称:邢红瑞的blog 日志总数:523 评论数量:1142 留言数量:0 访问次数:9691017 建立时间:2004年12月20日 |

| |
[j2ee]关于Hessian的安全机制的研究 原创空间, 文章收藏, 软件技术, 电脑与网络
邢红瑞 发表于 2008/5/19 14:18:02 |
hessian是caucho公司的实现的一种二进制的webservice,可以他只有最简单的http basic的认证方式,不适合各种场合的使用。阿里巴巴的架构师岑文初在文章里“犹抱琵琶半遮面”的说了一通,看出了不少端倪,一般使用http header里面加入安全认证信息。服务器端使用spring的如果修改HessianServiceExporter的方式,就是派生这个类HessianServiceExporter重写里面的handleRequest方法。 public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String dsa = request.getHeader("dsa"); if (log.isDebugEnabled()) { log.debug("dsa=" + dsa); }然后调用 super.handleRequest(request, response);
}更为优雅的使用spring的HandlerInterceptorAdapter,因为他也用了spring的mvc
public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {String dsa = request.getHeader("dsa"); if (log.isDebugEnabled()) { log.debug("dsa=" + dsa); }唯一不同的这里返回true,向后执行,false 中断处理}
客户端的情况复杂使用spring 继承HessianProxyFactory 实现 openConnection
public URLConnection openConnection(URL url) throws IOException { URLConnection conn = super.openConnection(url); conn.setRequestProperty("dsa", "1212512121211"); return conn;
}配置文件 <bean id="hello1Service" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <property name="serviceUrl"> <value> http://localhost/hello.service </value> </property> <property name="serviceInterface"> <value>com.xxx.hessian.BasicAPI</value> </property> <property name="proxyFactory"> <bean class="com.xxx.hessian.SHessianProxyFactory"/> </property> </bean>直接使用SHessianProxyFactory, public Map getAuthmap() { return authmap; }
public void setAuthmap(Map authmap) { this.authmap = authmap; }
private Map authmap=new HashMap();在 protected URLConnection openConnection(URL url) throws IOException最后加入
URLConnection conn = super.openConnection(url); Iterator<String> it=authmap.keySet().iterator(); while(it.hasNext()) { String key=it.next(); String value=(String) authmap.get(key); conn.setRequestProperty(key, value); } return conn;使用时static String url = "http://" + Constants.domainname + "/blog.service"; static HessianProxyFactory factory = new SHessianProxyFactory();factory.setAuthmap(apimap);然后调用。其实 可以将验证信息写入basic的认证的用户名和密码,服务器端可以使用acegi实现,最后感谢杜亚明的帮助。声明 实现思路没有用于 启明星辰公司的任何产品 包括utm。 |
|
回复:关于Hessian的安全机制的研究 原创空间, 文章收藏, 软件技术, 电脑与网络
初学者(游客)发表评论于2011/1/17 15:29:25 |
spring3 下怎么写,没有函数openConnection |
|
回复:关于Hessian的安全机制的研究 原创空间, 文章收藏, 软件技术, 电脑与网络
demohawk(游客)发表评论于2010/6/25 17:36:47 |
其实 可以将验证信息写入basic的认证的用户名和密码,服务器端可以使用acegi实现,最后感谢杜亚明的帮助。声明 实现思路没有用于
启明星辰公司的任何产品 包括utm。----能否详细解释一下,如果仅仅是basic认证用处不大,怎样和acegi结合,实现复杂的权限认证 |
|
回复:关于Hessian的安全机制的研究 原创空间, 文章收藏, 软件技术, 电脑与网络
qrduan(游客)发表评论于2009/2/18 13:26:45 |
请教一下,对hessian的二进制流加密,如何实现?hessian本身支持吗? |
|
» 1 »
|