Merge branch 'master' of ssh://git.code.sf.net/p/hl7api/fhircode
This commit is contained in:
commit
e63bb877ac
|
@ -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);
|
||||
}
|
|
@ -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())) {
|
||||
|
|
|
@ -21,4 +21,9 @@ public class DummyRestfulServer extends RestfulServer {
|
|||
return myResourceProviders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISecurityManager getSecurityManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue