简体   繁体   English

JAAS-如何在LoginModule之外检索主题?

[英]JAAS - How can the Subject be retrieved outside of the LoginModule?

I'm using Tomcat 8 and need to obtain the Subject outside of the LoginModule. 我正在使用Tomcat 8,并且需要在LoginModule之外获取Subject。 I've already tried: 我已经尝试过:

Subject subject = Subject.getSubject(AccessController.getContext());

But that just returns null every time. 但这每次都会返回null。 Anyone have any ideas? 有人有想法么?

我使用了一个可以包含Subject的自定义Principal ,并将JAAS登录模块设置为Principal ,然后使用request.getUserPrincipal()将其返回到Web应用程序内部,将其转换为我的自定义类,然后调用getSubject()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM