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的更多相关文章

  1. Jersey(1.19.1) - Client API, Security with Http(s)URLConnection

    With Http(s)URLConnection The support for security, specifically HTTP authentication and/or cookie m ...

  2. Jersey(1.19.1) - Hello World, Get started with Jersey using the embedded Grizzly server

    Maven Dependencies The following Maven dependencies need to be added to the pom: <dependency> ...

  3. Jersey(1.19.1) - Hello World, Get started with a Web application

    1. Maven Dependency <properties> <jersey.version>1.19.1</jersey.version> </prop ...

  4. Jersey(1.19.1) - Deploying a RESTful Web Service

    JAX-RS provides a deployment agnostic abstract class Application for declaring root resource and pro ...

  5. Jersey(1.19.1) - JSON Support

    Jersey JSON support comes as a set of JAX-RS MessageBodyReader<T> and MessageBodyWriter<T&g ...

  6. Jersey(1.19.1) - Root Resource Classes

    Root resource classes are POJOs (Plain Old Java Objects) that are annotated with @Path have at least ...

  7. Jersey(1.19.1) - WebApplicationException and Mapping Exceptions to Responses

    Previous sections have shown how to return HTTP responses and it is possible to return HTTP errors u ...

  8. Jersey(1.19.1) - Life-cycle of Root Resource Classes

    By default the life-cycle of root resource classes is per-request, namely that a new instance of a r ...

  9. Jersey(1.19.1) - Client API, Uniform Interface Constraint

    The Jersey client API is a high-level Java based API for interoperating with RESTful Web services. I ...

随机推荐

  1. 如何设置(修改)jetty(maven插件maven-jetty-plugi)的端口

    在使用jetty的maven插件,有两种方式来改变jetty server的端口,第一种方式较为简单,即: 通过命令行指定端口:mvn -Djetty.port=9999 jetty:run 另一种方 ...

  2. 进程控制块PCB学习

    参考这篇文章:http://blog.csdn.net/shuizhilan/article/details/6642040 PCB(process control block),进程控制块,是我们学 ...

  3. Android之基于HTTP协议的下载

    Android之基于HTTP协议的下载 http://www.blogjava.net/zh-weir/archive/2010/05/02/319892.html http://www.qianfa ...

  4. Science上发表的超赞聚类算法(转)

    作者(Alex Rodriguez, Alessandro Laio)提出了一种很简洁优美的聚类算法, 可以识别各种形状的类簇, 并且其超参数很容易确定. 算法思想 该算法的假设是类簇的中心由一些局部 ...

  5. Mac下生成RSA密钥

    MAC OS自带了OpenSSL,直接在命令行里使用OPENSSL就可以. 打开命令行工具,然后输入 openssl打开openssl,接着只要三句命令就可以搞定. 第一句命令生成1024位私钥: O ...

  6. Codeforces Round #282 (Div. 1) A. Treasure 水题

    A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...

  7. BZOJ 4247 挂饰 背包DP

    4247: 挂饰 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id ...

  8. leetcode || 53、Maximum Subarray

    problem: Find the contiguous subarray within an array (containing at least one number) which has the ...

  9. JAXB完毕XML与Java对象的互转

    这段时间都老忙了,甚至连周末全部人员都在赶产品的进度,想想连续上12天班,人都有点晕了! 到这会儿最终有点时间.所以准备和大家分享一下JAXB,会不会有人认为有点陌生呢?没事,这里跟大伙儿简单的描写叙 ...

  10. Keeplived 配制图解

    http://blog.csdn.net/tantexian/article/details/50056229