开发者

In Restful web services how to get username or password programmatically (basic authentication)

开发者 https://www.devze.com 2023-02-11 06:20 出处:网络
I have restful web services in a Java EE application (ejb3) running on jboss. And do not know how to get username or password programmatically, like when service method is called I want to be able to

I have restful web services in a Java EE application (ejb3) running on jboss. And do not know how to get username or password programmatically, like when service method is called I want to be able to get this user principals as smilar to jaxws

webServiceContext.getUserPrincipal().getName() 

or

(httpServletRequest) <-- request.getUserPrincipal()

I would be glad to hear the solutio开发者_如何学Gons, thanks.


[SOLVED] I have found the solution, here it is;

Use

@Context
 protected SecurityContext sc;

Or

Public TestResponse test(@Context SecurityContext sc){
   ..
   sc.getUserPrincipal.getName() //will return username
}
0

精彩评论

暂无评论...
验证码 换一张
取 消