Jetty身份验证体系结构使用以下4个接口:
org.eclipse.jetty.server.UserIdentity
org.eclipse.jetty.security.LoginService
org.eclipse.jetty.security.IdentityService
java.security.Principal
Run Code Online (Sandbox Code Playgroud)
有人可以解释这4个接口如何在认证流程中互相交互.
浏览代码似乎不是很有帮助,因为有很多极端情况.我对主要流程感兴趣.
这个问题很难回答,因为它非常开放/模糊.
我先试试这个简单的答案.
首先,基础知识,JVM提供的内容:
java.security.Principal - 这是包含人员/公司/组(登录名)的Servlet规范对象.javax.security.auth.Subject - 它包含有关Principal的相关信息(请参阅javadoc链接以获取可显示的内容列表)现在Jetty的具体内容:
org.eclipse.jetty.server.UserIdentity - 这表示用户的标识.又称为Principal和Subject用户(如果principal为null,则用户未经过身份验证).这还包括一些帮助isUserInRole(String)样式逻辑的方法.org.eclipse.jetty.security.IdentityService- 这将UserIdentity与所属的范围/线程相关联.(这是一个先进的概念,一些安全实现需要挂钩以正确处理安全性.Detty只提供默认行为,仅仅创建并执行此类关联UserIdentity.因为它不需要Jetty附带的安全实现).org.eclipse.jetty.security.LoginService- 这是用于UserIdentity从a login()和logout()样式事件创建/验证/销毁运行时对象的安全性实现的API .最后,它如何联系在一起:
org.eclipse.jetty.security.Authenticator负责身份验证部分的HTTP部分,例如使用401 Unauthorized和响应403 Forbidden.它使用它LoginService来做它的事情.LoginService用途IdentityService关联的UserIdentity到线程处理请求.Principal直接暴露,via HttpServletRequest.getUserPrincipal(). Subject通过标准的Servlet API中不可用.UserIdentity通过部分地暴露HttpServletRequest.isUserInRole(String role)方法.LoginService不是通过Servlet API的直接访问,但可以使用HttpServletRequest.login(String user, String pass)和HttpServletRequest.logout()分别访问这些基本特征.<security-constraint>部分WEB-INF/web.xmljavax.annotation.security注释:
| 归档时间: |
|
| 查看次数: |
1174 次 |
| 最近记录: |