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="$