Merge branch 'master' of ssh://git.code.sf.net/p/hl7api/fhircode

This commit is contained in:
jamesagnew 2014-03-07 17:31:38 -05:00
commit e63bb877ac
3 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,10 @@
package ca.uhn.fhir.rest.server;
import javax.servlet.http.HttpServletRequest;
/**
* Created by dsotnikov on 3/7/2014.
*/
public interface ISecurityManager {
public boolean authenticate(HttpServletRequest request);
}

View File

@ -37,6 +37,8 @@ public abstract class RestfulServer extends HttpServlet {
private static final long serialVersionUID = 1L;
private ISecurityManager securityManager;
private FhirContext myFhirContext;
private Map<Class<? extends IResource>, IResourceProvider> myTypeToProvider = new HashMap<Class<? extends IResource>, IResourceProvider>();
@ -101,6 +103,8 @@ public abstract class RestfulServer extends HttpServlet {
public abstract Collection<IResourceProvider> getResourceProviders();
public abstract ISecurityManager getSecurityManager();
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String resourceName = null;
@ -201,6 +205,11 @@ public abstract class RestfulServer extends HttpServlet {
try {
ourLog.info("Initializing HAPI FHIR restful server");
securityManager = getSecurityManager();
if (null == securityManager) {
ourLog.warn("No security manager has been provided, requests will not be authenticated!");
}
Collection<IResourceProvider> resourceProvider = getResourceProviders();
for (IResourceProvider nextProvider : resourceProvider) {
if (myTypeToProvider.containsKey(nextProvider.getResourceType())) {

View File

@ -21,4 +21,9 @@ public class DummyRestfulServer extends RestfulServer {
return myResourceProviders;
}
@Override
public ISecurityManager getSecurityManager() {
return null;
}
}