且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用WSS4J拦截器在Web服务方法中获取经过身份验证的用户

更新时间:2022-06-24 08:04:29

我发现这是与这样一个重要主题有关的唯一问题,所以我想分享我为CXF 3.1发现的内容.x。

I found this to be the only question relating to such an important subject, so I would like to share what I found for CXF 3.1.x.

基本思路与@ alfredo-a相同。以下是代码:

The basic idea is the same as @alfredo-a illustrated. Here is the code:

Message message=PhaseInterceptorChain.getCurrentMessage();
SecurityContext context=message.get(SecurityContext.class);
String userName=context.getUserPrincipal().getName();

我希望这对某人有帮助。

I hope this is helpful to someone.

干杯!