Hi Kevin,
I am facing a similar issue. I did register the interceptor in a MyRestfulServer class within the initilize method.
But, what I face is pretty strange. The interceptor executes when the URL is localhost:8080/fhir/metadata but does not for localhost:8080/fhir/Patient or for
localhost:8080/fhir/Patient/mypatientId
In fact when I register the Interceptor I get a 404 response on the Patient resource GET requests but a 200 on the metadata. If I do not register the interceptor, I get a 200 response on both Patient and metadata
Here is my code (without the import statements):
package ca.uhn.fhir.jpa.starter;
@Interceptor
public class BasicSecurityInterceptor extends InterceptorAdapter {
@Hook(Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED)
public boolean incomingRequestPostProcessed(
RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse)
throws AuthenticationException {
System.out.println("Hello");
return true;
}
}
package ca.uhn.fhir.jpa.starter;
@WebServlet(
urlPatterns = {"/fhir/*"},
displayName = "FHIR Server")
public class MyRestfulServer extends RestfulServer {
@Override
protected void initialize() throws ServletException {
System.out.println("first line in initialize");
super.initialize();
// create FhirContext for the appropriate version
setFhirContext(FhirContext.forR4());
registerInterceptor(new BasicSecurityInterceptor());
System.out.println("last line in initialize");
}
}