Roberto Sánchez
2014-01-17 c8eb07e8dc020346aaee0d859040ccabb79349bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package net.curisit.securis.services;
import java.io.IOException;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import org.jboss.resteasy.core.ResourceMethodInvoker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Provider
public class SecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter {
   private static final Logger log = LoggerFactory.getLogger(SecurityInterceptor.class);
   @Context
   private HttpServletRequest servletRequest;
   @Override
   public void filter(ContainerRequestContext containerRequestContext) throws IOException {
       log.info("filter using REST interceptor, method: {}", containerRequestContext.getMethod());
       log.info("filter using REST interceptor, ResourceMethodInvoker: {}", containerRequestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker"));
       ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) containerRequestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
       Method method = methodInvoker.getMethod();
       if (!method.isAnnotationPresent(Securable.class))
           return;
   }
   // @Override
   // public ServerResponse preProcess(HttpRequest httpRequest, ResourceMethod resourceMethod) throws Failure, WebApplicationException {
   //
   // Securable securable = resourceMethod.getMethod().getAnnotation(Securable.class);
   // String headerValue = servletRequest.getHeader(securable.header());
   //
   // if (headerValue == null) {
   // return (ServerResponse) Response.status(Status.BAD_REQUEST).entity("Invalid Session").build();
   // } else {
   // // Validatation logic goes here
   // }
   //
   // return null;
   // }
}