首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Webservice用户密码过滤后持续获取Username

2012-09-09 
Webservice用户密码过滤后继续获取UsernameApache CXF + WSS4JSoap报文如下?xml version1.0 encoding

Webservice用户密码过滤后继续获取Username
Apache CXF + WSS4J

Soap报文如下

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  <soap:Header>    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">        <wsse:Username>tom</wsse:Username>        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123456</wsse:Password>      </wsse:UsernameToken>    </wsse:Security>  </soap:Header>  <soap:Body>    <ns1:ListPowerPointTemplates>    </ns1:ListPowerPointTemplates>  </soap:Body></soap:Envelope>


在Webservice里还是需要UserName来进行具体操作的,但是这个Username已经找不到了,经过网上搜索了,总算在一个角落里找到这么一段代码
@Resource   //这个标签很重要private WebServiceContext context;//your Webservice methodpublic String method(){    Principal principal = context.getUserPrincipal();    String userName = principal.getName();}


造福后来人

热点排行