added the ISecurityManager interface
This commit is contained in:
parent
ff28a821d4
commit
79670cf172
|
@ -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 static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private ISecurityManager securityManager;
|
||||||
|
|
||||||
private FhirContext myFhirContext;
|
private FhirContext myFhirContext;
|
||||||
|
|
||||||
private Map<Class<? extends IResource>, IResourceProvider> myTypeToProvider = new HashMap<Class<? extends IResource>, IResourceProvider>();
|
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 Collection<IResourceProvider> getResourceProviders();
|
||||||
|
|
||||||
|
public abstract ISecurityManager getSecurityManager();
|
||||||
|
|
||||||
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
try {
|
try {
|
||||||
String resourceName = null;
|
String resourceName = null;
|
||||||
|
@ -201,6 +205,11 @@ public abstract class RestfulServer extends HttpServlet {
|
||||||
try {
|
try {
|
||||||
ourLog.info("Initializing HAPI FHIR restful server");
|
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();
|
Collection<IResourceProvider> resourceProvider = getResourceProviders();
|
||||||
for (IResourceProvider nextProvider : resourceProvider) {
|
for (IResourceProvider nextProvider : resourceProvider) {
|
||||||
if (myTypeToProvider.containsKey(nextProvider.getResourceType())) {
|
if (myTypeToProvider.containsKey(nextProvider.getResourceType())) {
|
||||||
|
|
|
@ -21,4 +21,9 @@ public class DummyRestfulServer extends RestfulServer {
|
||||||
return myResourceProviders;
|
return myResourceProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ISecurityManager getSecurityManager() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue