@Provider @ServerInterceptor public class PreProcessInterceptorForIsisSession implements PreProcessInterceptor { @Override public ServerResponse preProcess(HttpRequest httpRequest, ResourceMethodInvoker resourceMethodInvoker) throws Failure, WebApplicationException { return null; } }
@ServerInterceptor @ClientInterceptor @DecoderPrecedence public class LZFDecodingInterceptor implements MessageBodyReaderInterceptor {
/** * Client interceptor to set HTTP headers to advertise that REST client can accept LZF encoding */ @Provider @ClientInterceptor @HeaderDecoratorPrecedence public class AcceptLZFClientInterceptor { /** * Set headers to advertise ability to accept LZF compression <p/> * Check if client response has HTTP header "Accept-Encoding" set: <p/> * <ul> <li>- If none, set header to "lzf", if has a header, add lzf to the list</li></ul> * @param ctx Client execution context * @return Response with headers appended * @throws Exception */ public ClientResponse execute(ClientExecutionContext ctx) throws Exception { String encoding = ctx.getRequest().getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING); if (encoding == null) { ctx.getRequest().header(HttpHeaders.ACCEPT_ENCODING, "lzf"); } else { if (!encoding.contains("lzf")) { encoding += ", lzf"; ctx.getRequest().header(HttpHeaders.ACCEPT_ENCODING, encoding); } } return ctx.proceed(); } }
@ServerInterceptor @ClientInterceptor @EncoderPrecedence public class LZFEncodingInterceptor implements MessageBodyWriterInterceptor
@Provider @ServerInterceptor @Precedence("SECURITY") public class Challenger implements PreProcessInterceptor {
@ClientInterceptor @Provider public class RESTClientExecutionInterceptor implements ClientExecutionInterceptor {
public int calculateOrder(Class<?> clazz) { Precedence precedence = (Precedence)clazz.getAnnotation(Precedence.class); if (precedence != null) { String value = precedence.value(); Integer o = precedenceOrder.get(value); if (o == null) throw new RuntimeException(Messages.MESSAGES.unknownInterceptorPrecedence(value)); return o; } else { for (Annotation annotation : clazz.getAnnotations()) { precedence = annotation.annotationType().getAnnotation(Precedence.class); if (precedence != null) { String value = precedence.value(); Integer o = precedenceOrder.get(value); if (o == null) throw new RuntimeException(Messages.MESSAGES.unknownInterceptorPrecedence(value)); return o; } } } return Priorities.USER; }
@Provider @ServerInterceptor public class PreProcessInterceptorForIsisSession implements PreProcessInterceptor { @Override public ServerResponse preProcess(final HttpRequest request, final ResourceMethod method) throws Failure, WebApplicationException { // TODO Auto-generated method stub return null; } }
@ServerInterceptor @Precedence("SECURITY") public class LoginPreProcessorInterceptor implements PreProcessInterceptor {
@ClientInterceptor @HeaderDecoratorPrecedence public class AcceptEncodingGZIPInterceptor implements ClientExecutionInterceptor
@ClientInterceptor @Provider public class RESTClientExecutionInterceptor implements ClientExecutionInterceptor {
public int calculateOrder(Class<?> clazz) { Precedence precedence = (Precedence)clazz.getAnnotation(Precedence.class); if (precedence != null) { String value = precedence.value(); Integer o = precedenceOrder.get(value); if (o == null) throw new RuntimeException(Messages.MESSAGES.unknownInterceptorPrecedence(value)); return o; } else { for (Annotation annotation : clazz.getAnnotations()) { precedence = annotation.annotationType().getAnnotation(Precedence.class); if (precedence != null) { String value = precedence.value(); Integer o = precedenceOrder.get(value); if (o == null) throw new RuntimeException(Messages.MESSAGES.unknownInterceptorPrecedence(value)); return o; } } } return Priorities.USER; }
@Provider @ServerInterceptor public class PreProcessInterceptorForIsisSession implements PreProcessInterceptor { @Override public ServerResponse preProcess(final HttpRequest request, final ResourceMethod method) throws Failure, WebApplicationException { // TODO Auto-generated method stub return null; } }
@ClientInterceptor @HeaderDecoratorPrecedence @Deprecated public class AcceptEncodingGZIPInterceptor implements ClientExecutionInterceptor
@Provider @ServerInterceptor public class RestSecurityInterceptor implements PreProcessInterceptor { private static final Logger log = Logger.getLogger(RestSecurityInterceptor.class.getName()); @Override public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws UnauthorizedException { // pass public methods if (method.getResourceClass().equals(PublicServiceRest.class)) { return null; } // user not logged-in? if (AuthService.getCurrentAccount() == null) { ServerResponse response = new ServerResponse(); response.setStatus(HttpResponseCodes.SC_UNAUTHORIZED); MultivaluedMap<String, Object> headers = new Headers<Object>(); headers.add("Content-Type", "text/plain"); response.setMetadata(headers); response.setEntity("{\"code\":401, \"message\":\"HTTP error 401: Unauthorized to access " + request.getPreprocessedPath() + "\"" + ""); return response; } return null; } }
@Provider @ServerInterceptor public class Current implements PostProcessInterceptor {
@ServerInterceptor public class WarpResteasyInterceptor implements PreProcessInterceptor, PostProcessInterceptor, MessageBodyReaderInterceptor, MessageBodyWriterInterceptor {
@ServerInterceptor @Produces(org.overlord.sramp.atom.MediaType.APPLICATION_SRAMP_ATOM_EXCEPTION) @Consumes(org.overlord.sramp.atom.MediaType.APPLICATION_SRAMP_ATOM_EXCEPTION)