CXF 拦截器将返回内容进行加密
时间: 2016-04-07来源:开源中国
前景提要
HDC调试需求开发(15万预算),能者速来!>>>
目前写了一个后台程序,对外提供接口是用cxf写 的webservice
安全方面的考虑要对返回数据进行加密
所以用了拦截器机制 继承AbstractPhaseInterceptor<Message>
super(Phase.PRE_STREAM); // 触发点在流关闭之前
主要代码 基本也是网上的
public void handleMessage(Message message) {
OutputStream os = message.getContent(OutputStream.class);
CachedStream cs = new CachedStream();
message.setContent(OutputStream.class, cs);
message.getInterceptorChain().doIntercept(message);
CachedOutputStream csnew = (CachedOutputStream) message.getContent(OutputStream.class);
InputStream in = csnew.getInputStream();
String result = getRetern(IOUtils.toString(in,"UTF-8"));
IOUtils.copy(new ByteArrayInputStream(result.getBytes("UTF-8")), os);

cs.close();
os.flush();
message.setContent(OutputStream.class, os);

}
返回的数据是用的json格式
当数据量小时没问题,但是一旦数据量过大就会报错 出现
Unexpected EOF in prolog

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行