public static void SignOut(SessionInfo session)
        {
            FormsAuthentication.SignOut();

            if (session != null)
            {
                try
                {
                    ForceOtherPagesToLogout(session);

                    using (LoginService service = new LoginService())
                    {
                        service.Logout(session.Credentials.SessionToken.Id);
                    }
                }
                catch (NotSupportedException)
                {
                    //ignore this.
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Warn, e, "Failed to log user out.");
                }

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success,
                    UserAuthenticationEventType.Logout);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(
                                             session.Credentials.UserName,
                                             null,
                                             session.Credentials.DisplayName));
                ServerAuditHelper.LogAuditMessage(audit);
            }
        }
        /// <summary>
        /// Method called when stopping the DICOM SCP.
        /// </summary>
        protected override void Stop()
        {
            lock (_syncLock)
            {
                ServerPartitionMonitor.Instance.Changed -= _changedEvent;

                foreach (DicomScp <DicomScpContext> scp in _listenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                        ServerPlatform.AuditSource,
                        EventIdentificationContentsEventOutcomeIndicator.Success,
                        ApplicationActivityType.ApplicationStopped,
                        new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }

                foreach (DicomScp <DicomScpContext> scp in _alternateAeListenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                        ServerPlatform.AuditSource,
                        EventIdentificationContentsEventOutcomeIndicator.Success,
                        ApplicationActivityType.ApplicationStopped,
                        new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }
            }
        }
        public static void BeginInstancesTransferAuditLogger(List <StorageInstance> instances, AssociationParameters parms)
        {
            Dictionary <string, AuditPatientParticipantObject> list = new Dictionary <string, AuditPatientParticipantObject>();

            foreach (StorageInstance instance in instances)
            {
                string key = instance.PatientId + instance.PatientsName;
                if (!list.ContainsKey(key))
                {
                    AuditPatientParticipantObject patient =
                        new AuditPatientParticipantObject(instance.PatientsName, instance.PatientId);
                    list.Add(key, patient);
                }
            }

            foreach (AuditPatientParticipantObject patient in list.Values)
            {
                // Audit Log
                BeginTransferringDicomInstancesAuditHelper audit =
                    new BeginTransferringDicomInstancesAuditHelper(ServerPlatform.AuditSource,
                                                                   EventIdentificationContentsEventOutcomeIndicator.Success,
                                                                   parms, patient);

                foreach (StorageInstance instance in instances)
                {
                    if (patient.PatientId.Equals(instance.PatientId) &&
                        patient.PatientsName.Equals(instance.PatientsName))
                    {
                        audit.AddStorageInstance(instance);
                    }
                }

                ServerAuditHelper.LogAuditMessage(audit);
            }
        }
Beispiel #4
0
        private static void AuditLog(Study study, List <UpdateItem> fields)
        {
            Platform.CheckForNullReference(study, "study");
            Platform.CheckForNullReference(fields, "fields");

            var helper =
                new DicomInstancesAccessedAuditHelper(ServerPlatform.AuditSource,
                                                      EventIdentificationContentsEventOutcomeIndicator.Success,
                                                      EventIdentificationContentsEventActionCode.U);

            helper.AddUser(new AuditPersonActiveParticipant(
                               SessionManager.Current.Credentials.UserName,
                               null,
                               SessionManager.Current.Credentials.DisplayName));

            var participant = new AuditStudyParticipantObject(study.StudyInstanceUid, study.AccessionNumber);

            string updateDescription = StringUtilities.Combine(
                fields, ";",
                item => String.Format("Tag=\"{0}\" Value=\"{1}\"", item.DicomTag.Name, item.Value)
                );

            participant.ParticipantObjectDetailString = updateDescription;
            helper.AddStudyParticipantObject(participant);
            ServerAuditHelper.LogAuditMessage(helper);
        }
        protected void DeleteButton_Clicked(object sender, ImageClickEventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    string reason = ReasonListBox.SelectedItem.Text;
                    if (!String.IsNullOrEmpty(SaveReasonAsName.Text))
                    {
                        SaveCustomReason();
                        reason = SaveReasonAsName.Text;
                    }

                    OnDeletingStudies();
                    StudyController controller = new StudyController();
                    foreach (DeleteStudyInfo study in DeletingStudies)
                    {
                        try
                        {
                            controller.DeleteStudy(study.StudyKey, reason + "::" + Comment.Text);

                            // Audit log
                            DicomStudyDeletedAuditHelper helper = new DicomStudyDeletedAuditHelper(
                                ServerPlatform.AuditSource,
                                EventIdentificationContentsEventOutcomeIndicator.Success);
                            helper.AddUserParticipant(new AuditPersonActiveParticipant(
                                                          SessionManager.Current.Credentials.UserName,
                                                          null,
                                                          SessionManager.Current.Credentials.DisplayName));
                            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                                 study.StudyInstanceUid,
                                                                 study.AccessionNumber ?? string.Empty));
                            ServerAuditHelper.LogAuditMessage(helper);
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex, "DeleteClicked failed: Unable to delete studies");
                            throw;
                        }
                    }

                    OnStudiesDeleted();
                }
                finally
                {
                    Close();
                }
            }
            else
            {
                EnsureDialogVisible();
            }
        }
Beispiel #6
0
        private void GenerateAuditLog()
        {
            var audit = new DicomInstancesAccessedAuditHelper(ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, EventIdentificationContentsEventActionCode.R /* Read*/);

            audit.AddUser(new AuditPersonActiveParticipant(SessionManager.Current.Credentials.UserName, null, SessionManager.Current.Credentials.DisplayName));

            var participant = new AuditStudyParticipantObject(_study.StudyInstanceUid, _study.AccessionNumber);

            participant.ParticipantObjectDetailString = string.Format("Partition: {0}", string.IsNullOrEmpty(_study.ThePartition.Description) ? _study.ThePartition.AeTitle : _study.ThePartition.Description);
            audit.AddStudyParticipantObject(participant);

            ServerAuditHelper.LogAuditMessage(audit);
        }
Beispiel #7
0
        private void AuditLog(Study affectedStudy)
        {
            // Audit log
            DicomStudyDeletedAuditHelper helper =
                new DicomStudyDeletedAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success);

            helper.AddUserParticipant(new AuditPersonActiveParticipant(
                                          SessionManager.Current.Credentials.
                                          UserName,
                                          null,
                                          SessionManager.Current.Credentials.
                                          DisplayName));
            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                 affectedStudy.StudyInstanceUid,
                                                 affectedStudy.AccessionNumber ??
                                                 string.Empty));
            ServerAuditHelper.LogAuditMessage(helper);
        }
        private void StartScp(DicomScp <DicomScpContext> listener, List <DicomScp <DicomScpContext> > list)
        {
            if (listener.Start())
            {
                list.Add(listener);
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);
            }
            else
            {
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);

                Platform.Log(LogLevel.Error, "Unable to add {1} SCP handler for server partition {0}",
                             listener.Context.Partition.Description,
                             listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                 ? "IPv6"
                                 : "IPv4");
                Platform.Log(LogLevel.Error,
                             "Partition {0} will not accept IPv6 incoming DICOM associations.",
                             listener.Context.Partition.Description);

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                     AlertTypeCodes.UnableToStart, null, TimeSpan.Zero,
                                     "Unable to start {2} DICOM listener on {0} : {1}",
                                     listener.AeTitle, listener.ListenPort,
                                     listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                         ? "IPv6"
                                         : "IPv4");
            }
        }
        private void RemoveDisabledAlternateAes()
        {
            var alternateAeScpsToDelete = new List <DicomScp <DicomScpContext> >();

            // Now search for any alternate AEs that are disabled/missing
            foreach (DicomScp <DicomScpContext> alternateAeScp in _alternateAeListenerList)
            {
                bool bFound = false;
                foreach (ServerPartitionAlternateAeTitle altAe in _alternateAes)
                {
                    if (altAe.Port == alternateAeScp.ListenPort && altAe.AeTitle.Equals(alternateAeScp.AeTitle) && altAe.Enabled &&
                        (altAe.AllowKOPR || altAe.AllowQuery || altAe.AllowRetrieve || altAe.AllowStorage))
                    {
                        bFound = true;
                        break;
                    }
                }

                if (!bFound)
                {
                    Platform.Log(LogLevel.Info, "Shutting down Alternate AE listener {0}:{1}", alternateAeScp.AeTitle, alternateAeScp.ListenPort);
                    alternateAeScp.Stop();
                    alternateAeScpsToDelete.Add(alternateAeScp);

                    ServerAuditHelper.LogAuditMessage(new ApplicationActivityAuditHelper(
                                                          ServerPlatform.AuditSource,
                                                          EventIdentificationContentsEventOutcomeIndicator.Success,
                                                          ApplicationActivityType.ApplicationStopped,
                                                          new AuditProcessActiveParticipant(alternateAeScp.AeTitle)));
                }
            }

            foreach (DicomScp <DicomScpContext> scp in alternateAeScpsToDelete)
            {
                _alternateAeListenerList.Remove(scp);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Method called when stopping the DICOM SCP.
        /// </summary>
        protected override void Stop()
        {
            //TODO CR (Jan 2014): Move this into the base if it applies to all subclasses?
            PersistentStoreRegistry.GetDefaultStore().ShutdownRequested = true;

            lock (_syncLock)
            {
                if (_changedEvent == null)
                {
                    return;
                }

                ServerPartitionMonitor.Instance.Changed -= _changedEvent;

                foreach (DicomScp <DicomScpContext> scp in _listenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                        ServerPlatform.AuditSource,
                        EventIdentificationContentsEventOutcomeIndicator.Success,
                        ApplicationActivityType.ApplicationStopped,
                        new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }

                foreach (DicomScp <DicomScpContext> scp in _alternateAeListenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                        ServerPlatform.AuditSource,
                        EventIdentificationContentsEventOutcomeIndicator.Success,
                        ApplicationActivityType.ApplicationStopped,
                        new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }
            }
        }
        public static void InstancesTransferredAuditLogger(DicomScpContext context, ServerAssociationParameters assocParams, List <StorageInstance> instances)
        {
            Dictionary <string, AuditPatientParticipantObject> list = new Dictionary <string, AuditPatientParticipantObject>();

            foreach (StorageInstance instance in instances)
            {
                string key = instance.PatientId + instance.PatientsName;
                if (!list.ContainsKey(key))
                {
                    AuditPatientParticipantObject patient =
                        new AuditPatientParticipantObject(instance.PatientsName, instance.PatientId);
                    list.Add(key, patient);
                }
            }

            foreach (AuditPatientParticipantObject patient in list.Values)
            {
                // Audit Log
                DicomInstancesTransferredAuditHelper helper =
                    new DicomInstancesTransferredAuditHelper(ServerPlatform.AuditSource,
                                                             EventIdentificationContentsEventOutcomeIndicator.Success,
                                                             EventIdentificationContentsEventActionCode.E,
                                                             assocParams);

                foreach (StorageInstance instance in instances)
                {
                    if (patient.PatientId.Equals(instance.PatientId) &&
                        patient.PatientsName.Equals(instance.PatientsName))
                    {
                        helper.AddStorageInstance(instance);
                    }
                }

                ServerAuditHelper.LogAuditMessage(helper);
            }
        }
Beispiel #12
0
        protected virtual void OnStudyDeleted()
        {
            // Audit log
            DicomStudyDeletedAuditHelper helper = new DicomStudyDeletedAuditHelper(
                ServerPlatform.AuditSource,
                EventIdentificationContentsEventOutcomeIndicator.Success);

            helper.AddUserParticipant(new AuditProcessActiveParticipant(ServerPartition.AeTitle));
            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                 StorageLocation.StudyInstanceUid,
                                                 Study == null ? string.Empty : Study.AccessionNumber));
            ServerAuditHelper.LogAuditMessage(helper);


            IList <IDeleteStudyProcessorExtension> extensions = LoadExtensions();

            foreach (IDeleteStudyProcessorExtension ext in extensions)
            {
                if (ext.Enabled)
                {
                    ext.OnStudyDeleted();
                }
            }
        }
        private void RemoveDisabledPartitions()
        {
            var scpsToDelete            = new List <DicomScp <DicomScpContext> >();
            var alternateAeScpsToDelete = new List <DicomScp <DicomScpContext> >();

            // First, search for removed ServerPartitions, then remove all related ServerPartitionAlternateAeTitles
            foreach (DicomScp <DicomScpContext> scp in _listenerList)
            {
                bool bFound = false;
                foreach (ServerPartition part in _partitions)
                {
                    if (part.Port == scp.ListenPort && part.AeTitle.Equals(scp.AeTitle) && part.Enabled)
                    {
                        bFound = true;
                        break;
                    }
                }

                if (!bFound)
                {
                    Platform.Log(LogLevel.Info, "Partition was deleted, shutting down listener {0}:{1}", scp.AeTitle,
                                 scp.ListenPort);
                    scp.Stop();
                    scpsToDelete.Add(scp);

                    ServerAuditHelper.LogAuditMessage(new ApplicationActivityAuditHelper(
                                                          ServerPlatform.AuditSource,
                                                          EventIdentificationContentsEventOutcomeIndicator.Success,
                                                          ApplicationActivityType.ApplicationStopped,
                                                          new AuditProcessActiveParticipant(scp.AeTitle)));

                    // Cleanup any alternate AEs for the partition
                    foreach (DicomScp <DicomScpContext> alternateAeScp in _alternateAeListenerList)
                    {
                        if (scp.Context.Partition.Key.Equals(alternateAeScp.Context.AlternateAeTitle.ServerPartitionKey))
                        {
                            Platform.Log(LogLevel.Info,
                                         "Partition was deleted, shutting down Alternate AE listener {0}:{1}",
                                         alternateAeScp.AeTitle, alternateAeScp.ListenPort);

                            alternateAeScp.Stop();
                            alternateAeScpsToDelete.Add(alternateAeScp);

                            ServerAuditHelper.LogAuditMessage(new ApplicationActivityAuditHelper(
                                                                  ServerPlatform.AuditSource,
                                                                  EventIdentificationContentsEventOutcomeIndicator.Success,
                                                                  ApplicationActivityType.ApplicationStopped,
                                                                  new AuditProcessActiveParticipant(alternateAeScp.AeTitle)));
                        }
                    }
                }
            }

            foreach (DicomScp <DicomScpContext> scp in scpsToDelete)
            {
                _listenerList.Remove(scp);
            }
            foreach (DicomScp <DicomScpContext> scp in alternateAeScpsToDelete)
            {
                _alternateAeListenerList.Remove(scp);
            }
        }
Beispiel #14
0
        protected void SearchButton_Click(object sender, ImageClickEventArgs e)
        {
            if (DisplaySearchWarning)
            {
                StudyListGridView.DataBindOnPreRender     = false;
                ConfirmStudySearchMessageBox.Message      = SR.NoFiltersSearchWarning;
                ConfirmStudySearchMessageBox.MessageStyle = "font-weight: bold; color: #205F87;";
                ConfirmStudySearchMessageBox.Show();
            }
            else
            {
                StudyListGridView.Refresh();
            }
            var sb = new StringBuilder();

            if (!String.IsNullOrEmpty(PatientId.TrimText))
            {
                sb.AppendFormat("PatientId={0};", PatientId.TrimText);
            }
            if (!String.IsNullOrEmpty(PatientName.TrimText))
            {
                sb.AppendFormat("PatientsName={0};", PatientName.TrimText);
            }
            if (!String.IsNullOrEmpty(AccessionNumber.TrimText))
            {
                sb.AppendFormat("AccessionNumber={0};", AccessionNumber.TrimText);
            }
            if (!String.IsNullOrEmpty(ToStudyDate.Text) || !String.IsNullOrEmpty(FromStudyDate.Text))
            {
                sb.AppendFormat("StudyDate={0}-{1};", FromStudyDate.Text, ToStudyDate.Text);
            }
            if (!String.IsNullOrEmpty(StudyDescription.TrimText))
            {
                sb.AppendFormat("StudyDescription={0};", StudyDescription.TrimText);
            }
            if (ModalityListBox.SelectedIndex < 0)
            {
                bool first = true;
                foreach (ListItem item in ModalityListBox.Items)
                {
                    if (!item.Selected)
                    {
                        continue;
                    }

                    if (first)
                    {
                        sb.AppendFormat("ModalitiesInStudy={0}", item.Value);
                        first = false;
                    }
                    else
                    {
                        sb.AppendFormat(",{0}", item.Value);
                    }
                }
                if (!first)
                {
                    sb.Append(';');
                }
            }

            var helper = new QueryAuditHelper(ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success,
                                              new AuditPersonActiveParticipant(SessionManager.Current.Credentials.UserName,
                                                                               null,
                                                                               SessionManager.Current.Credentials.DisplayName),
                                              ServerPartition.AeTitle, ServerPlatform.HostId, sb.ToString());

            ServerAuditHelper.LogAuditMessage(helper);
        }
Beispiel #15
0
        protected void LoginClicked(object sender, EventArgs e)
        {
            if (SessionManager.Current != null)
            {
                // already logged in. Maybe from different page
                RedirectAfterLogin();
            }

            try
            {
                SessionManager.InitializeSession(UserName.Text, Password.Text, ApplicationName ?? ImageServerConstants.DefaultApplicationName);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.Success, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, SessionManager.Current.Credentials.DisplayName));
                ServerAuditHelper.LogAuditMessage(audit);
            }
            catch (PasswordExpiredException)
            {
                Platform.Log(LogLevel.Info, "Password for {0} has expired. Requesting new password.", UserName.Text);
                PasswordExpiredDialog.Show(UserName.Text, Password.Text);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.Success, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerAuditHelper.LogAuditMessage(audit);
            }
            catch (UserAccessDeniedException ex)
            {
                Platform.Log(LogLevel.Warn, "Login unsuccessful for {0}.  {1}", UserName.Text, ErrorMessages.UserAccessDenied);
                Platform.Log(LogLevel.Debug, ex, ex.Message);
                ShowError(ErrorMessages.UserAccessDenied);
                UserName.Focus();

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.SeriousFailureActionTerminated, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerAuditHelper.LogAuditMessage(audit);
            }
            catch (CommunicationException ex)
            {
                Platform.Log(LogLevel.Error, ex, "Unable to contact A/A server");
                ShowError(ErrorMessages.CannotContactEnterpriseServer);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerAuditHelper.LogAuditMessage(audit);
            }
            catch (ArgumentException ex)
            {
                Platform.Log(LogLevel.Warn, ex.Message);
                Platform.Log(LogLevel.Debug, ex, "Login error:");
                ShowError(ex.Message);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerAuditHelper.LogAuditMessage(audit);
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Error, ex, "Login error:");
                ShowError(ex.Message);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerAuditHelper.LogAuditMessage(audit);
            }
        }