1 Reply Latest reply on Apr 1, 2014 1:32 PM by 2644841

    Any way to disable POST on Coherence REST?


      I'm using Coherence 3.7 with Grizzly to provide a rest interface (as per http://docs.oracle.com/middleware/1212/coherence/COHCG/rest_moddefault.htm#CICDBAAI).


      However, I only want to allow GETs through the REST interface - no POSTS or DELETES.


      I have gone through the docs but could not find a way to disable certain operations. Is there a way to do this?



        • 1. Re: Any way to disable POST on Coherence REST?

          So turns out if I had read the docs a bit more closely I could have figured this one out. For anyone else looking for something similar and not wanting to do down the whole JAAS route (as detailed here: 7 Securing Oracle Coherence REST), you basically implement your own custom filters as detailed here: http://docs.oracle.com/middleware/1212/coherence/COHCG/rest_moddefault.htm#CICIFJHG


          My request filter to allow only GETs looked a bit like this:


          import javax.ws.rs.HttpMethod;
          import com.sun.jersey.spi.container.ContainerRequest;
          import com.sun.jersey.spi.container.ContainerRequestFilter;
          public class AllowGetsOnlyRequestFilter implements ContainerRequestFilter {
              public ContainerRequest filter(ContainerRequest paramContainerRequest) {
                  if (!HttpMethod.GET.equals(paramContainerRequest.getMethod())) {
                      //only allow GETs
                      throw new  UnsupportedOperationException(String.format("%s not supported. Only %s operations are supported", paramContainerRequest.getMethod(), HttpMethod.GET));
                  return paramContainerRequest;


          Then wire it up on the registerContainerRequestFilters method of your class that extends DefaultResourceConfig


          getContainerRequestFilters().add(new AllowGetsOnlyRequestFilter ());