在RESTfulWeb服务中,如何以编程方式获取用户名或密码(基本身份验证)

在RESTfulWeb服务中,如何以编程方式获取用户名或密码(基本身份验证),rest,ejb-3.0,restful-authentication,basic-authentication,Rest,Ejb 3.0,Restful Authentication,Basic Authentication,我在jboss上运行的JavaEE应用程序(ejb3)中有RESTfulWeb服务。并且不知道如何以编程方式获取用户名或密码,比如在调用服务方法时,我希望能够以类似于jaxws的方式获取此用户主体 webServiceContext.getUserPrincipal().getName() 或 (httpServletRequest)[已解决] 我找到了解决办法,就在这里 使用 或 你也通过注入上下文获得密码吗?事实上这是很久以前的事了,但我记得,是的,我能够同时获得用户名和密码!可能是sc

我在jboss上运行的JavaEE应用程序(ejb3)中有RESTfulWeb服务。并且不知道如何以编程方式获取用户名或密码,比如在调用服务方法时,我希望能够以类似于jaxws的方式获取此用户主体

webServiceContext.getUserPrincipal().getName() 

(httpServletRequest)[已解决]
我找到了解决办法,就在这里

使用


你也通过注入上下文获得密码吗?事实上这是很久以前的事了,但我记得,是的,我能够同时获得用户名和密码!可能是sc.getUserPrincipal.getPassword()?
(httpServletRequest) <-- request.getUserPrincipal()
@Context
 protected SecurityContext sc;
Public TestResponse test(@Context SecurityContext sc){
   ..
   sc.getUserPrincipal.getName() //will return username
}