public DownloadInfo[] GetDownloadInfos
        (
            string authenticationCookie,
            PACSConnection server,
            string client,
            string patientID,
            string studyInstanceUID,
            string seriesInstanceUID,
            string sopInstanceUID,
            DownloadStatus status,
            ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

            return(_addin.GetDownloadInfos(userName,
                                           server,
                                           client,
                                           patientID,
                                           studyInstanceUID,
                                           seriesInstanceUID,
                                           sopInstanceUID,
                                           status));
        }
Exemple #2
0
        public InstanceData[] FindInstances(QueryOptions options, int maxQueryResults)
        {
            try
            {
                ValidateToken();

                Byte[] parameters = null;
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        JsonUtil.WriteJsonParam <string>(AuthenticationToken, ms, "authenticationCookie");

                        JsonUtil.WriteJsonParam <QueryOptions>(options, ms, "options");

                        ExtraOptions extraOptions = BuildExtraOptions(maxQueryResults);
                        extraOptions.UserData3 = "NoSort";

                        JsonUtil.WriteJsonParam <ExtraOptions>(extraOptions, ms, "extraOptions");

                        parameters = ms.ToArray();
                    }
                }

                IList <InstanceData> FindInstancesResult = null;
                FindInstancesResult = JsonUtil.POSTCallJson <IList <InstanceData> >(ServiceUrl, "FindInstances", parameters);

                return(FindInstancesResult.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string GetDicomJSON(string authenticationCookie, string studyInstanceUID, string seriesInstanceUID, string sopInstanceUID, string userData)
        {
            var user = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanRetrieve);

            ExtraOptions extraOptions = new ExtraOptions();
            ObjectUID    uid          = new ObjectUID();

            extraOptions.UserData = userData;
            uid.StudyInstanceUID  = studyInstanceUID;
            uid.SeriesInstanceUID = seriesInstanceUID;

            if (string.IsNullOrEmpty(sopInstanceUID))
            {
                var options = new QueryOptions();
                options.StudiesOptions = new StudiesQueryOptions();
                options.StudiesOptions.StudyInstanceUID = studyInstanceUID;
                options.SeriesOptions = new SeriesQueryOptions();
                options.SeriesOptions.SeriesInstanceUID = seriesInstanceUID;
                var objectsFound = AddinsFactory.CreateQueryAddin().FindInstances(user, options, 1, true);
                if (objectsFound.Length > 0)
                {
                    var objects = objectsFound.Where(o => o != null).ToArray();
                    if (objects.Length > 0)
                    {
                        sopInstanceUID = objects[0].SOPInstanceUID;
                    }
                }
            }

            uid.SOPInstanceUID = sopInstanceUID;

            return(AddinsFactory.CreateObjectRetrieveAddin().GetDicomJSON(uid));
        }
        public override void Start()
        {
            _currentTestReqIdx = -1;
            _currentReqIdx     = -1;
            string filePath = "";

            if (ExtraOptions.ContainsKey(TEST_FILE_PATH))
            {
                filePath = ExtraOptions[TEST_FILE_PATH];
                if (!String.IsNullOrWhiteSpace(filePath))
                {
                    try
                    {
                        CustomTestsFile testFile = new CustomTestsFile();
                        testFile.Load(filePath);
                        _testFile = testFile;
                    }
                    catch
                    {
                        HttpServerConsole.Instance.WriteLine(LogMessageType.Error,
                                                             "Could not load custom tests file located at: '{0}'.", filePath);
                    }
                }
            }

            _tester   = new Tester(_testController, _testFile);
            _workList = new Dictionary <int, Queue <TestJob> >();
            _patternOfRequestExclusion = _testFile.PatternRequestExclusion;
            base.Start();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="forwardingHost">The hosts thar requests will be sent to</param>
 /// <param name="forwardingPort">The forwarding port</param>
 /// <param name="host">The host of the proxy</param>
 /// <param name="port">The port of the proxy</param>
 /// <param name="dataStore">Data store where the requests will be saved</param>
 public ReverseProxy(string host, int port, int securePort, ITrafficDataAccessor dataStore) :
     base(host, port, securePort)
 {
     ExtraOptions.Add(ReverseProxy.FORWARDING_HOST_OPT, String.Empty);
     ExtraOptions.Add(ReverseProxy.FORWARDING_PORT_OPT, String.Empty);
     _dataStore = dataStore;
 }
Exemple #6
0
 public String getMenuName()
 {
     return(string.Format("dz191.vhr.{0}.{1}.{2}{3}",
                          MCategory.ToString().ToLower(),
                          MajorCategory.ToString().ToLower(),
                          MinorCategory.ToString().ToLower(),
                          ExtraOptions != null?ExtraOptions.ToLower():""));
 }
Exemple #7
0
 private int MaxQueryResults(ExtraOptions extraOptions)
 {
     if (extraOptions != null && extraOptions.UserData != null)
     {
         return(Convert.ToInt32(extraOptions.UserData));
     }
     return(0);
 }
Exemple #8
0
 private bool ReadModalitiesInStudy(ExtraOptions extraOptions)
 {
     if (extraOptions != null && extraOptions.UserData2 != null)
     {
         return(extraOptions.UserData2.ToLower() == "readmodalitiesinstudy");
     }
     return(false);
 }
Exemple #9
0
 private bool LightQuery(ExtraOptions extraOptions)
 {
     if (extraOptions != null && extraOptions.UserData2 != null)
     {
         return(extraOptions.UserData2.ToLower() == "lightQuery");
     }
     return(false);
 }
Exemple #10
0
 private bool NoSort(ExtraOptions extraOptions)
 {
     if (extraOptions != null && extraOptions.UserData3 != null)
     {
         return(extraOptions.UserData3.ToLower() == "nosort");
     }
     return(false);
 }
        public void DeleteDownloadInfos(string authenticationCookie, int[] jobIds, ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDeleteDownloadInfo);

            _addin.DeleteDownloadInfos(userName, jobIds);
        }
Exemple #12
0
        private static ExtraOptions BuildExtraOptions(int maxQueryResults)
        {
            ExtraOptions extraOptions = new ExtraOptions();

            if (maxQueryResults > 0)
            {
                extraOptions.UserData = maxQueryResults.ToString();
            }
            return(extraOptions);
        }
Exemple #13
0
 private string StackInstanceUID(ExtraOptions extraOptions)
 {
     if (!LightQuery(extraOptions))
     {
         if (extraOptions != null && extraOptions.UserData2 != null)
         {
             return(extraOptions.UserData2);
         }
     }
     return(string.Empty);
 }
        public void DeleteImages(string authenticationCookie,
                                 string patientID,
                                 string studyInstanceUID,
                                 string seriesInstanceUID,
                                 string sopInstanceUID, ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDeleteImages);

            _addin.DeleteImages(userName, patientID, studyInstanceUID, seriesInstanceUID, sopInstanceUID);
        }
Exemple #15
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="securePort"></param>
        /// <param name="forcePort">Do not automatically start on the next available port if the specified port is taken</param>
        public BaseProxy(string host, int port, int securePort, bool forcePort = false)
        {
            Host        = host;
            _port       = port;
            _securePort = securePort;
            _forcePort  = forcePort;

            ExtraOptions.Add(HTTP_CLIENT_PROXY_HOST, String.Empty);
            ExtraOptions.Add(HTTP_CLIENT_PROXY_PORT, String.Empty);


            // If port is 0, then dynamically get an available port when told to start
            _usesDynamicPort       = (_port == 0);
            _usesDynamicPortSecure = (_securePort == 0);
        }
Exemple #16
0
        /// <summary>
        /// Start listening for connections
        /// </summary>
        /// <exception cref="InvalidOperationException">Proxy was already started</exception>
        virtual public void Start()
        {
            //set network options
            int clientProxyPort = 0;

            if (ExtraOptions.ContainsKey(HTTP_CLIENT_PROXY_HOST) &&
                ExtraOptions.ContainsKey(HTTP_CLIENT_PROXY_PORT) &&
                !String.IsNullOrWhiteSpace(ExtraOptions[HTTP_CLIENT_PROXY_HOST]) &&
                !String.IsNullOrWhiteSpace(ExtraOptions[HTTP_CLIENT_PROXY_PORT]) &&
                int.TryParse(ExtraOptions[HTTP_CLIENT_PROXY_PORT], out clientProxyPort))
            {
                //override defaults
                _networkSettings.WebProxy = new WebProxy(ExtraOptions[HTTP_CLIENT_PROXY_HOST], clientProxyPort);
            }

            if (_listening)
            {
                throw new InvalidOperationException("Attempted to start proxy when already started");
            }


            _listener       = new TcpListener(_localAddress, Port);
            _secureListener = new TcpListener(_localAddress, SecurePort);

            //start the unsecure port
            StartListener(ref _listener, ref _usesDynamicPort);
            //start the secure port
            StartListener(ref _secureListener, ref _usesDynamicPortSecure);

            if (_listener != null && _secureListener != null)
            {
                // Expose which port we're using if it was dynamically selected
                if (_usesDynamicPort)
                {
                    _port = ((IPEndPoint)_listener.LocalEndpoint).Port;
                }
                if (_usesDynamicPortSecure)
                {
                    _securePort = ((IPEndPoint)_secureListener.LocalEndpoint).Port;
                }

                HttpServerConsole.Instance.WriteLine(String.Format("Waiting on Host: {0}, HTTP Port: {1}, Secure Port: {2}", _localAddress, _port, _securePort));

                _listener.BeginAcceptTcpClient(new AsyncCallback(OnAccept), _listener);
                _secureListener.BeginAcceptTcpClient(new AsyncCallback(OnAccept), _secureListener);
                _listening = true;
            }
        }
Exemple #17
0
        public Task <DownloadInfo> DownloadImages
        (
            string authenticationCookie,
            RemoteConnection server,
            string client,
            string PatientID,
            string StudyInstanceUID,
            string SeriesInstanceUID,
            string SOPInstanceUID,
            ExtraOptions extraOptions
        )
        {
            var userName = AuthHandler.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

            return(Task.Factory.StartNew(() => _addin.DownloadImages(userName, server as PACSConnection, "LTSTORAGESERVER", PatientID, StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID, null != extraOptions ? extraOptions.UserData : "")));
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="testController"></param>
 /// <param name="testFile"></param>
 /// <param name="dataStore"></param>
 /// <param name="patternOfTestRequest"></param>
 /// <param name="host">Host by default localhost</param>
 /// <param name="port">Port to use by default 9998</param>
 public BaseAttackProxy(ITestController testController, CustomTestsFile testFile, ITrafficDataAccessor dataStore, string host = "127.0.0.1", int port = 9998)
     : base(host, port, dataStore)
 {
     //it doesn't support these options because the http client is controlled by the tester
     //the tester could be either appscan or blackops
     ExtraOptions.Remove(HTTP_CLIENT_PROXY_HOST);
     ExtraOptions.Remove(HTTP_CLIENT_PROXY_PORT);
     _testController = testController;
     if (testFile != null)
     {
         _testFile = testFile;
     }
     else
     {
         ExtraOptions.Add(TEST_FILE_PATH, "CustomTests.xml");
     }
 }
        public DownloadInfo DownloadImages
        (
            string authenticationCookie,
            PACSConnection server,
            string client,
            string PatientID,
            string StudyInstanceUID,
            string SeriesInstanceUID,
            string SOPInstanceUID,
            ExtraOptions extraOptions
        )
        {
            string userName;

            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

            return(_addin.DownloadImages(userName, server, "LTSTORAGESERVER", PatientID, StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID, null != extraOptions?extraOptions.UserData:""));
        }
Exemple #20
0
        public async Task <DownloadInfo> DownloadImages
        (
            string authenticationCookie,
            RemoteConnection server,
            string client,
            string PatientID,
            string StudyInstanceUID,
            string SeriesInstanceUID,
            string SOPInstanceUID,
            ExtraOptions extraOptions
        )
        {
            try
            {
                var userName = AuthHandler.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

                var queries = await Query(server, PatientID, StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID);

                foreach (var query in queries)
                {
                    using (var stream = await _ret.RetrieveDataset(RemoteConnectionFactory.Config(server as WadoConnection), query))
                        using (var ds = new DicomDataSet())
                        {
                            ds.Load(stream, DicomDataSetLoadFlags.None);
                            _store.DoStore(ds);
                        }
                }

                return(new DownloadInfo()
                {
                    Id = "-1",
                    Status = DownloadStatus.Completed
                });
            }
            catch (Exception e)
            {
                return(new DownloadInfo()
                {
                    Id = "-1",
                    Status = DownloadStatus.Error,
                    ErrorMessage = e.Message
                });
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sourceStore"></param>
        /// <param name="saveStore"></param>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="securePort"></param>
        public TrafficStoreProxy(
            ITrafficDataAccessor sourceStore,
            ITrafficDataAccessor saveStore,
            string host,
            int port,
            int securePort
            )
            :
            base(host, port, securePort)
        {
            _sourceStore = sourceStore;
            _saveStore   = saveStore;

            ExtraOptions.Add("MatchMode", "BrowserFriendly");
            ExtraOptions.Add("IgnoreAuth", "false");



            TrafficServerCache.Instance.Clear();
        }
Exemple #22
0
        public override void Start()
        {
            if (ExtraOptions.ContainsKey(ReverseProxy.FORWARDING_HOST_OPT) && !String.IsNullOrWhiteSpace(ExtraOptions[ReverseProxy.FORWARDING_HOST_OPT]))
            {
                _forwardingHost = ExtraOptions[ReverseProxy.FORWARDING_HOST_OPT];
            }
            else
            {
                HttpServerConsole.Instance.WriteLine(LogMessageType.Error,
                                                     "Need to configure 'ForwardingHost' extra proxy option");
                return;
            }


            if (ExtraOptions.ContainsKey(ReverseProxy.FORWARDING_PORT_OPT) && !String.IsNullOrWhiteSpace(ExtraOptions[ReverseProxy.FORWARDING_PORT_OPT]))
            {
                string fwPortString = ExtraOptions[ReverseProxy.FORWARDING_PORT_OPT];
                if (!int.TryParse(fwPortString, out _forwardingPort))
                {
                    HttpServerConsole.Instance.WriteLine(LogMessageType.Error,
                                                         "Invalid value for 'ForwardingPort' extra option");
                    return;
                }
            }
            else
            {
                HttpServerConsole.Instance.WriteLine(LogMessageType.Error,
                                                     "Need to configure 'ForwardingPort' extra proxy option");
                return;
            }


            base.Start();
            HttpServerConsole.Instance.WriteLine(LogMessageType.Warning,
                                                 "All binary messages (including attacks) will be forwarded to {0}:{1}",
                                                 _forwardingHost,
                                                 _forwardingPort);
        }
Exemple #23
0
        public Task <PatientData[]> FindPatients(string authenticationCookie, DataContracts.QueryOptions options, ExtraOptions extraOptions)
        {
            var userName = AuthHandler.Authorize(authenticationCookie, PermissionsTable.Instance.CanQuery);

            return(Task.Factory.StartNew(() => _queryAddin.Value.FindPatients(userName, options, MaxQueryResults(extraOptions))));
        }
        public UserPermissions[]  GetUserAccess(string authenticationCookie, string user, ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authenticate(authenticationCookie);

            if (userName != user)
            {
                ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanManageAccessRight);
            }

            return(_addin.GetUserAccess(user));
        }
Exemple #25
0
 /// <summary>
 /// Checks if the user has permission to perform an operation and throws exception if not.
 /// </summary>
 /// <param name="authenticationService"></param>
 /// <param name="userName"></param>
 /// <param name="permission"></param>
 /// <param name="extraOptions"></param>
 private static void Authorize(IAuthenticationAddin authenticationService, string userName, Permission permission, ExtraOptions extraOptions)
 {
     if (!authenticationService.HasPermission(userName, permission.Name, null))
     {
         throw new ServiceAuthorizationException("Not enough permissions.");
     }
 }
Exemple #26
0
        /// <summary>
        /// Checks the authentication cookie and extract/returns the user name. If user is not authenticated it throws the appropriate exception
        /// </summary>
        /// <param name="authenticationService"></param>
        /// <param name="authenticationCookie"></param>
        /// <param name="userName"></param>
        /// <param name="extraOptions"></param>
        internal static void Authenticate(IAuthenticationAddin authenticationService, string authenticationCookie, out string userName, ExtraOptions extraOptions)
        {
            AuthenticationInfo info = null;

            try
            {
                info = authenticationService.GetAuthenticationInfo(authenticationCookie, null);
            }
            catch (Exception ex)
            {
                throw new ServiceAuthenticationException(ex.Message);
            }

            userName = "";

            if (null != info)
            {
                userName = info.UserName;

                if (authenticationService.IsTimedOut(info, null))
                {
                    throw new ServiceAuthenticationException("Timed-out");
                }
            }
            else
            {
                throw new ServiceAuthenticationException("Not Authenticated");
            }
        }
 /// <summary>
 /// Creates a  proxy to be used for traffic recording purposes which also allows trapping requests and responses
 /// </summary>
 /// <param name="host"></param>
 /// <param name="port"></param>
 /// <param name="dataStore">Where the traffic data will be stored</param>
 public AdvancedExploreProxy(string host, int port, ITrafficDataAccessor dataStore)
     : base(host, port, dataStore)
 {
     PatternTracker.Instance.PatternsToTrack = dataStore.Profile.GetTrackingPatterns();
     ExtraOptions.Add(TRACK_REQUEST_CONTEXT_OPTION, "false");
 }
Exemple #28
0
        public string Create3DObject(string authenticationCookie, QueryOptions options, string id, int renderingType, ExtraOptions extraOptions)
        {
            var userName = AuthHandler.Authorize(authenticationCookie, PermissionsTable.Instance.CanQuery);

            int MaxQueryResults = 0;

            if (extraOptions != null && extraOptions.UserData != null)
            {
                MaxQueryResults = Convert.ToInt32(extraOptions.UserData);
            }

            bool   lightQuery       = extraOptions != null && extraOptions.UserData2 != null ? (extraOptions.UserData2 == "lightQuery") : false;
            bool   noSort           = extraOptions != null && extraOptions.UserData3 != null ? (extraOptions.UserData3 == "NoSort") : false;
            string stackInstanceUID = !lightQuery && extraOptions != null && extraOptions.UserData2 != null ? extraOptions.UserData2 : string.Empty;

            _queryAddin.Value.Initialize3DObject(id);//embedded lock timeout

            try
            {
                var t = new Task(() =>
                {
                    _create3dSemaphore.Wait();

                    if (!_queryAddin.Value.ItemExists(id))
                    {
                        return;
                    }

                    try
                    {
                        _queryAddin.Value.Start3DObject(userName, options, LTCachingCtrl.CacheSettings.Enabled, Path.Combine(LTCachingCtrl.CacheSettings.Storage, "Cache3D"), id, stackInstanceUID, renderingType);
                    }
                    finally
                    {
                        _queryAddin.Value.UnlockTimeOut(id);
                        _create3dSemaphore.Release();
                    }
                });
                t.Start();
            }
            finally
            {
            }
            //we don't want to run on the iis tasks pool, because it will block other threads from running

            return("Success");
        }
        public JobStatus[] GetJobStatus(string authenticationCookie, string[] JobsIds, ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

            return(_addin.GetJobStatus(userName, JobsIds));
        }
        public DownloadInfo UpdateDownloadInfoStatus(string authenticationCookie, DownloadInfo info, ExtraOptions extraOptions)
        {
            string userName;


            userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanDownloadImages);

            return(_addin.UpdateDownloadInfoStatus(userName, info));
        }