ws接口的安全问题
1 接口调用者身份验证问题
Rsa:私钥加密,公钥解密
Cxf:usernameToken
1 在请求中加入wsse的安全协议
2 在wsse中用安全令牌(用户名/密码)来验证用户的身份
3 cxf在发送和接受ws的soap请求时,在框架中加入回掉函数来处理安全令牌的校验
4 将安全令牌信息放入请求信息中,服务器上在调用方法时拦截并且校验请求这的身份信息
Cxf:安全令牌拦截器
服务器端:
1.在spring配置文件中注册服务身份安全拦截器WSS4JInInterceptor bean,通过构造注入在map中依次放入安全令牌,用户密码,以及回调函数
2.注册回调函数类MyPwdCallback,用来处理安全令牌检验。
3.发布的webservice接口类中调用拦截器
spring配置文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<context:property-placeholder location="classpath:dbconfig.properties" />
<!--1. 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driverClassName}" />
<property name="url" value="${url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.

本文探讨了SOAP风格Web服务的安全问题,重点关注接口调用者的身份验证。介绍了使用RSA私钥加密、CXF的usernameToken以及如何在CXF中实现安全令牌拦截器进行身份验证的方法。服务器端通过Spring配置文件注册WSS4JInInterceptor,并自定义回调函数处理安全令牌校验。客户端调用时,需要设置SOAP Header中的安全信息。测试表明,该方案能有效确保接口调用的安全性。
最低0.47元/天 解锁文章
3305

被折叠的 条评论
为什么被折叠?



