码迷,mamicode.com
首页 > 其他好文 > 详细

Jersey(1.19.1) - Security

时间:2016-04-17 00:44:57      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

Security information is available by obtaining the SecurityContext using @Context, which is essentially the equivalent functionality available on the HttpServletRequest.

SecurityContext can be used in conjunction with sub-resource locators to return different resources if the user principle is included in a certain role. For example, a sub-resource locator could return a different resource if a user is a preferred customer:

@Path("basket")
public ShoppingBasketResource get(@Context SecurityContext sc) {
    if (sc.isUserInRole("PreferredCustomer") {
        return new PreferredCustomerShoppingBaskestResource();
    } else {
        return new ShoppingBasketResource();
    }
}

 

Jersey(1.19.1) - Security

标签:

原文地址:http://www.cnblogs.com/huey/p/5399822.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!