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); ServerPlatform.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); } } ServerPlatform.LogAuditMessage(audit); } }
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)); ServerPlatform.LogAuditMessage(audit); } }
protected void LoginClicked(object sender, EventArgs e) { if (SessionManager.Current != null) { // already logged in. Maybe from different page HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(SessionManager.Current.Credentials.UserName, false), true); } try { SessionManager.InitializeSession(UserName.Text, Password.Text); UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, UserAuthenticationEventType.Login); audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, SessionManager.Current.Credentials.DisplayName)); ServerPlatform.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)); ServerPlatform.LogAuditMessage(audit); } catch (UserAccessDeniedException ex) { Platform.Log(LogLevel.Error, 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)); ServerPlatform.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)); ServerPlatform.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)); ServerPlatform.LogAuditMessage(audit); } }
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)); ServerPlatform.LogAuditMessage(helper); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "DeleteClicked failed: Unable to delete studies"); throw; } } OnStudiesDeleted(); } finally { Close(); } } else { EnsureDialogVisible(); } }
/// <summary> /// Method called when stopping the DICOM SCP. /// </summary> protected override void Stop() { lock (_syncLock) { foreach (DicomScp <DicomScpContext> scp in _listenerList) { scp.Stop(); ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, ApplicationActivityType.ApplicationStopped, new AuditProcessActiveParticipant(scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); } ServerPartitionMonitor.Instance.Changed -= _changedEvent; } }
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)); ServerPlatform.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); } } ServerPlatform.LogAuditMessage(helper); } }
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)); ServerPlatform.LogAuditMessage(helper); IList <IDeleteStudyProcessorExtension> extensions = LoadExtensions(); foreach (IDeleteStudyProcessorExtension ext in extensions) { if (ext.Enabled) { ext.OnStudyDeleted(); } } }
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.Text)) { sb.AppendFormat("PatientId={0};", PatientId.Text); } if (!String.IsNullOrEmpty(PatientName.Text)) { sb.AppendFormat("PatientsName={0};", PatientName.Text); } if (!String.IsNullOrEmpty(AccessionNumber.Text)) { sb.AppendFormat("AccessionNumber={0};", AccessionNumber.Text); } if (!String.IsNullOrEmpty(ToStudyDate.Text) || !String.IsNullOrEmpty(FromStudyDate.Text)) { sb.AppendFormat("StudyDate={0}-{1};", FromStudyDate.Text, ToStudyDate.Text); } if (!String.IsNullOrEmpty(StudyDescription.Text)) { sb.AppendFormat("StudyDescription={0};", StudyDescription.Text); } 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()); ServerPlatform.LogAuditMessage(helper); }
private void StartListeners(ServerPartition part) { DicomScpContext parms = new DicomScpContext(part); if (DicomSettings.Default.ListenIPV4) { DicomScp <DicomScpContext> ipV4Scp = new DicomScp <DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger); ipV4Scp.ListenPort = part.Port; ipV4Scp.AeTitle = part.AeTitle; if (ipV4Scp.Start(IPAddress.Any)) { _listenerList.Add(ipV4Scp); ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, ApplicationActivityType.ApplicationStarted, new AuditProcessActiveParticipant(ipV4Scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); } else { ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, ApplicationActivityType.ApplicationStarted, new AuditProcessActiveParticipant(ipV4Scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); Platform.Log(LogLevel.Error, "Unable to add IPv4 SCP handler for server partition {0}", part.Description); Platform.Log(LogLevel.Error, "Partition {0} will not accept IPv4 incoming DICOM associations.", part.Description); ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener", AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv4 DICOM listener on {0} : {1}", ipV4Scp.AeTitle, ipV4Scp.ListenPort); } } if (DicomSettings.Default.ListenIPV6) { DicomScp <DicomScpContext> ipV6Scp = new DicomScp <DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger); ipV6Scp.ListenPort = part.Port; ipV6Scp.AeTitle = part.AeTitle; if (ipV6Scp.Start(IPAddress.IPv6Any)) { _listenerList.Add(ipV6Scp); ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, ApplicationActivityType.ApplicationStarted, new AuditProcessActiveParticipant(ipV6Scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); } else { ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, ApplicationActivityType.ApplicationStarted, new AuditProcessActiveParticipant(ipV6Scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); Platform.Log(LogLevel.Error, "Unable to add IPv6 SCP handler for server partition {0}", part.Description); Platform.Log(LogLevel.Error, "Partition {0} will not accept IPv6 incoming DICOM associations.", part.Description); ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener", AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv6 DICOM listener on {0} : {1}", ipV6Scp.AeTitle, ipV6Scp.ListenPort); } } }
private void CheckPartitions() { lock (_syncLock) { _partitions = new List <ServerPartition>(ServerPartitionMonitor.Instance); IList <DicomScp <DicomScpContext> > scpsToDelete = new List <DicomScp <DicomScpContext> >(); 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); ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper( ServerPlatform.AuditSource, EventIdentificationContentsEventOutcomeIndicator.Success, ApplicationActivityType.ApplicationStopped, new AuditProcessActiveParticipant(scp.AeTitle)); ServerPlatform.LogAuditMessage(helper); } } foreach (DicomScp <DicomScpContext> scp in scpsToDelete) { _listenerList.Remove(scp); } foreach (ServerPartition part in _partitions) { if (!part.Enabled) { continue; } bool bFound = false; foreach (DicomScp <DicomScpContext> scp in _listenerList) { if (part.Port != scp.ListenPort || !part.AeTitle.Equals(scp.AeTitle)) { continue; } // Reset the context partition, incase its changed. scp.Context.Partition = part; bFound = true; break; } if (!bFound) { Platform.Log(LogLevel.Info, "Detected partition was added, starting listener {0}:{1}", part.AeTitle, part.Port); StartListeners(part); } } } }