无论身份验证领域如何,获取用户名
我正在 Metro 和 Tomcat 堆栈上用 Java 开发 Web 服务,我的问题是用户身份验证。我了解 Tomcat 可以使用多个外部身份验证领域,例如 JDBCRealm 或 JNDIRealm,并且我希望最终用户为各自的领域配置 Tomcat 安装。
现在,我的 webservice-methods 中需要的是用户用于登录的用户名(或 id,唯一的东西),无论具体领域如何。我在哪里可以得到它?显然,到目前为止我搜索了错误的关键词 - 我想使用的概念有具体的名称吗?
提前致谢!
I'm developing a webservice in Java on a stack of Metro and Tomcat, and my problem is with the user authentication. I understand Tomcat can make use of several external authentication realms, such as JDBCRealm or JNDIRealm, and I want my endusers to configure their Tomcat installation for their respective realm.
Now, what I need in my webservice-methods is the user name (or id, something unique) the user has used to log in, regardless of the concrete realm. Where do I get it? Obviously I've searched for the wrong key words so far - is there a specific name for the concept I want to use?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
登录用户可通过
WebServiceContext#getUserPrincipal()
返回一个Principal
实例,其中转有一个getName()
方法。例如,
这是从
HttpServletRequest#getUserPrincipal()
顺便说一下。The logged-in user is available by
WebServiceContext#getUserPrincipal()
which returns aPrincipal
instance which in turn has agetName()
method.E.g.
This is under the covers obtained from
HttpServletRequest#getUserPrincipal()
by the way.