changeset 618:5ab377df6d8b find-move-scp

filtering on aet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Oct 2013 11:50:17 +0200
parents a24b0161b171
children 70d0f27e5bd3
files OrthancServer/DicomProtocol/IFindRequestHandler.h OrthancServer/Internals/FindScp.cpp OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancFindRequestHandler.h OrthancServer/main.cpp
diffstat 5 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/IFindRequestHandler.h	Fri Oct 25 11:28:02 2013 +0200
+++ b/OrthancServer/DicomProtocol/IFindRequestHandler.h	Fri Oct 25 11:50:17 2013 +0200
@@ -47,7 +47,7 @@
     {
     }
 
-    virtual void Handle(const DicomMap& input,
-                        DicomFindAnswers& answers) = 0;
+    virtual void Handle(DicomFindAnswers& answers,
+                        const DicomMap& input) = 0;
   };
 }
--- a/OrthancServer/Internals/FindScp.cpp	Fri Oct 25 11:28:02 2013 +0200
+++ b/OrthancServer/Internals/FindScp.cpp	Fri Oct 25 11:50:17 2013 +0200
@@ -74,7 +74,7 @@
 
         try
         {
-          data.handler_->Handle(data.input_, data.answers_);
+          data.handler_->Handle(data.answers_, data.input_);
         }
         catch (OrthancException& e)
         {
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Fri Oct 25 11:28:02 2013 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Fri Oct 25 11:50:17 2013 +0200
@@ -36,6 +36,7 @@
 
 #include "../Core/DicomFormat/DicomArray.h"
 #include "ServerToolbox.h"
+#include "OrthancInitialization.h"
 
 namespace Orthanc
 {
@@ -300,7 +301,6 @@
         std::string str = query.GetValue(tag).AsString();
         if (!IsWildcard(str))
         {
-          printf(">> [%s]\n", str.c_str());
           index.LookupTagValue(resources, tag, str/*, level*/);
           return true;
         }
@@ -358,11 +358,9 @@
   }
 
 
-  void OrthancFindRequestHandler::Handle(const DicomMap& input,
-                                         DicomFindAnswers& answers)
+  void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
+                                         const DicomMap& input)
   {
-    LOG(WARNING) << "Find-SCU request received";
-
     /**
      * Retrieve the query level.
      **/
--- a/OrthancServer/OrthancFindRequestHandler.h	Fri Oct 25 11:28:02 2013 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.h	Fri Oct 25 11:50:17 2013 +0200
@@ -48,7 +48,7 @@
     {
     }
 
-    virtual void Handle(const DicomMap& input,
-                        DicomFindAnswers& answers);
+    virtual void Handle(DicomFindAnswers& answers,
+                        const DicomMap& input);
   };
 }
--- a/OrthancServer/main.cpp	Fri Oct 25 11:28:02 2013 +0200
+++ b/OrthancServer/main.cpp	Fri Oct 25 11:50:17 2013 +0200
@@ -257,6 +257,25 @@
 };
 
 
+class OrthancApplicationEntityFilter : public IApplicationEntityFilter
+{
+public:
+  virtual bool IsAllowed(const std::string& /*callingIp*/,
+                         const std::string& callingAet)
+  {
+    if (!IsKnownAETitle(callingAet))
+    {
+      LOG(ERROR) << "Unkwnown remote DICOM modality AET: \"" << callingAet << "\"";
+      return false;
+    }
+    else
+    {
+      return true;
+    }
+  }
+};
+
+
 class MyIncomingHttpRequestFilter : public IIncomingHttpRequestFilter
 {
 private:
@@ -481,12 +500,14 @@
     {
       // DICOM server
       DicomServer dicomServer;
+      OrthancApplicationEntityFilter dicomFilter;
       dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false));
       dicomServer.SetStoreRequestHandlerFactory(serverFactory);
       dicomServer.SetMoveRequestHandlerFactory(serverFactory);
       dicomServer.SetFindRequestHandlerFactory(serverFactory);
       dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242));
       dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));
+      dicomServer.SetApplicationEntityFilter(dicomFilter);
 
       // HTTP server
       MyIncomingHttpRequestFilter httpFilter(context);