private static string GetRemoteHostName(AssociationParameters association) { string remoteHostName = null; try { if (association.RemoteEndPoint != null) { try { IPHostEntry entry = Dns.GetHostEntry(association.RemoteEndPoint.Address); remoteHostName = entry.HostName; } catch { remoteHostName = association.RemoteEndPoint.Address.ToString(); } } } catch (Exception e) { remoteHostName = null; Platform.Log(LogLevel.Warn, e, "Unable to resolve remote host name for auditing."); } return(remoteHostName); }
protected override DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid) { if (Device == null) { return(DicomPresContextResult.Accept); } if (!Device.AllowStorage) { return(DicomPresContextResult.RejectUser); } if (Device.AcceptKOPR || Context.AllowKOPR) { DicomPresContext context = association.GetPresentationContext(pcid); if (context.AbstractSyntax.Equals(SopClass.KeyObjectSelectionDocumentStorage) || context.AbstractSyntax.Equals(SopClass.GrayscaleSoftcopyPresentationStateStorageSopClass) || context.AbstractSyntax.Equals(SopClass.BlendingSoftcopyPresentationStateStorageSopClass) || context.AbstractSyntax.Equals(SopClass.ColorSoftcopyPresentationStateStorageSopClass) || context.AbstractSyntax.Equals(SopClass.PseudoColorSoftcopyPresentationStateStorageSopClass)) { return(DicomPresContextResult.Accept); } return(DicomPresContextResult.RejectUser); } return(DicomPresContextResult.Accept); }
public static bool VerifyAssociation(IDicomServerContext context, AssociationParameters assocParms, out DicomRejectResult result, out DicomRejectReason reason) { string calledTitle = (assocParms.CalledAE ?? "").Trim(); string callingAE = (assocParms.CallingAE ?? "").Trim(); result = DicomRejectResult.Permanent; reason = DicomRejectReason.NoReasonGiven; var extendedConfiguration = LocalDicomServer.GetExtendedConfiguration(); if (!extendedConfiguration.AllowUnknownCaller && ServerDirectory.GetRemoteServersByAETitle(callingAE).Count == 0) { reason = DicomRejectReason.CallingAENotRecognized; } else if (calledTitle != context.AETitle) { reason = DicomRejectReason.CalledAENotRecognized; } else { return(true); } return(false); }
protected override DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid) { if (!Device.AllowRetrieve) { return(DicomPresContextResult.RejectUser); } return(DicomPresContextResult.Accept); }
protected override DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid) { // if (!Device.AllowWorkList) // { // return DicomPresContextResult.RejectUser; // } return(DicomPresContextResult.Accept); }
protected override DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid) { // Add Verify Logic here to control who has privilege Store //bool isNew; //Device device = DeviceManager.LookupDevice(association, out isNew); //if (!device.AllowStorage) // return DicomPresContextResult.RejectUser; return(DicomPresContextResult.Accept); }
public static Device LookupDevice(AssociationParameters association, out bool isNew) { /* * Read From Config to Check if the AE is supported! */ isNew = true; return(new Device { Enabled = true }); }
/// <summary> /// Scan the files to send, and create presentation contexts for each abstract syntax to send. /// </summary> protected override void SetPresentationContexts() { byte pcid = AssociationParameters.FindAbstractSyntax(MoveSopClass); if (pcid == 0) { pcid = AssociationParameters.AddPresentationContext(MoveSopClass); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); } }
/// <summary> /// Scan the files to send, and create presentation contexts for each abstract syntax to send. /// </summary> protected override void SetPresentationContexts() { byte pcid = AssociationParameters.AddPresentationContext(SopClass.StorageCommitmentPushModelSopClass); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = AssociationParameters.AddPresentationContext(SopClass.MrImageStorage); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); }
public DicomPresContextResult VerifyAssociation(AssociationParameters association, byte pcid) { DicomRejectResult result; DicomRejectReason reason; if (!AssociationVerifier.VerifyAssociation(Context, association, out result, out reason)) { return(DicomPresContextResult.RejectUser); } return(OnVerifyAssociation(association, pcid)); }
/// <summary> /// Event handlers called when association has been established. /// </summary> /// <param name="assoc">The association</param> protected void OnAssociationEstablished(AssociationParameters assoc) { if (_assocStats == null) { _assocStats = new TransmissionStatistics(string.Format("DICOM association from {0} [{1}:{2}] to {3}", assoc.CallingAE, assoc.RemoteEndPoint.Address, assoc.RemoteEndPoint.Port, assoc.CalledAE)); } // start recording _assocStats.Begin(); }
public DicomPresContextResult VerifyAssociation(AssociationParameters association, byte pcid) { var result = OnVerifyAssociation(association, pcid); if (result != DicomPresContextResult.Accept) { LogAdapter.Logger.WarnWithFormat( "Rejecting Presentation Context {0}:{1} in association between {2} and {3}.", pcid, association.GetAbstractSyntax(pcid).Description, association.CallingAE, association.CalledAE); } return(result); }
/// <summary> /// Event handler called when an association has been aborted. /// </summary> /// <param name="assoc">The aborted association</param> /// <param name="reason">The abort reason</param> protected void OnAssociationAborted(AssociationParameters assoc, DicomAbortReason reason) { if (_assocStats == null) { return; } // update the association statistics _assocStats.IncomingBytes = assoc.TotalBytesRead; _assocStats.OutgoingBytes = assoc.TotalBytesSent; // signal stop recording.. the statistic object will fill out whatever // it needs at this point based on what we have set _assocStats.End(); }
/// <summary> /// Event handler called while a DICOM message has been sent. /// </summary> /// <param name="assoc">The association</param> /// <param name="dcmMsg">The request DICOM message sent</param> private void OnDicomMessageSent( AssociationParameters assoc, DicomMessage dcmMsg) { if (_assocStats == null) { return; } // update the association stats _assocStats.IncomingBytes = assoc.TotalBytesRead; _assocStats.OutgoingBytes = assoc.TotalBytesSent; _assocStats.OutgoingMessages++; }
/// <summary> /// Constructor. /// </summary> public DicomInstancesTransferredAuditHelper(DicomAuditSource auditSource, EventIdentificationContentsEventOutcomeIndicator outcome, EventIdentificationContentsEventActionCode action, AssociationParameters parms) : base("DicomInstancesTransferred") { AuditMessage.EventIdentification = new EventIdentificationContents(); AuditMessage.EventIdentification.EventID = EventID.DICOMInstancesTransferred; AuditMessage.EventIdentification.EventActionCode = action; AuditMessage.EventIdentification.EventActionCodeSpecified = true; AuditMessage.EventIdentification.EventDateTime = Platform.Time.ToUniversalTime(); AuditMessage.EventIdentification.EventOutcomeIndicator = outcome; InternalAddActiveDicomParticipant(parms); InternalAddAuditSource(auditSource); }
public QueryAuditHelper(DicomAuditSource auditSource, EventIdentificationTypeEventOutcomeIndicator outcome, AssociationParameters parms) : base("Query") { AuditMessage.EventIdentification = new EventIdentificationType(); AuditMessage.EventIdentification.EventID = CodedValueType.Query; AuditMessage.EventIdentification.EventActionCode = EventIdentificationTypeEventActionCode.E; AuditMessage.EventIdentification.EventActionCodeSpecified = true; AuditMessage.EventIdentification.EventDateTime = Platform.Time.ToUniversalTime(); AuditMessage.EventIdentification.EventOutcomeIndicator = outcome; InternalAddActiveDicomParticipant(parms); InternalAddAuditSource(auditSource); }
public BeginTransferringDicomInstancesAuditHelper(DicomAuditSource auditSource, EventIdentificationTypeEventOutcomeIndicator outcome, AssociationParameters parms, AuditPatientParticipantObject patient) : base("BeginTransferringDicomInstances") { AuditMessage.EventIdentification = new EventIdentificationType(); AuditMessage.EventIdentification.EventID = CodedValueType.BeginTransferringDICOMInstances; AuditMessage.EventIdentification.EventActionCode = EventIdentificationTypeEventActionCode.E; AuditMessage.EventIdentification.EventActionCodeSpecified = true; AuditMessage.EventIdentification.EventDateTime = Platform.Time.ToUniversalTime(); AuditMessage.EventIdentification.EventOutcomeIndicator = outcome; InternalAddAuditSource(auditSource); InternalAddActiveDicomParticipant(parms); InternalAddParticipantObject(patient.PatientId + patient.PatientsName, patient); }
/// <summary> /// Verify a presentation context. /// </summary> /// <param name="association"></param> /// <param name="pcid"></param> /// <returns></returns> public DicomPresContextResult VerifyAssociation(AssociationParameters association, byte pcid) { bool isNew; Device = DeviceManager.LookupDevice(Partition, association, out isNew); // Let the subclass perform the verification DicomPresContextResult result = OnVerifyAssociation(association, pcid); if (result != DicomPresContextResult.Accept) { Platform.Log(LogLevel.Debug, "Rejecting Presentation Context {0}:{1} in association between {2} and {3}.", pcid, association.GetAbstractSyntax(pcid).Description, association.CallingAE, association.CalledAE); } return(result); }
public DicomPresContextResult VerifyAssociation(AssociationParameters association, byte pcid) { bool isNew; var dm = IoC.Get <IDeviceManager>(); Device = dm.LookupDevice(_context.Partition, association, out isNew); var result = OnVerifyAssociation(association, pcid); if (result != DicomPresContextResult.Accept) { Log.Logger.Info( "Rejecting Presentation Context {0}:{1} in association between {2} and {3}.", pcid, association.GetAbstractSyntax(pcid).Description, association.CallingAE, association.CalledAE); } return(result); }
/// <summary> /// Event handler called when an association has been released. /// </summary> /// <param name="assoc">The association</param> protected void OnAssociationReleased(AssociationParameters assoc) { if (_assocStats == null) { return; } // update the association statistics _assocStats.IncomingBytes = assoc.TotalBytesRead; _assocStats.OutgoingBytes = assoc.TotalBytesSent; // signal stop recording.. the statistic object will fill out whatever // it needs at this point based on what we have set _assocStats.End(); if (_logInformation) { StatisticsLogger.Log(LogLevel.Info, _assocStats); } }
protected void InternalAddActiveDicomParticipant(AssociationParameters parms) { if (parms is ClientAssociationParameters) { _participantList.Add( new ActiveParticipantContents(RoleIDCode.Source, "AETITLE=" + parms.CallingAE, null, null, parms.LocalEndPoint.Address.ToString(), NetworkAccessPointTypeEnum.IpAddress, null)); _participantList.Add( new ActiveParticipantContents(RoleIDCode.Destination, "AETITLE=" + parms.CalledAE, null, null, parms.RemoteEndPoint.Address.ToString(), NetworkAccessPointTypeEnum.IpAddress, null)); } else { _participantList.Add( new ActiveParticipantContents(RoleIDCode.Source, "AETITLE=" + parms.CallingAE, null, null, parms.RemoteEndPoint.Address.ToString(), NetworkAccessPointTypeEnum.IpAddress, null)); _participantList.Add( new ActiveParticipantContents(RoleIDCode.Destination, "AETITLE=" + parms.CalledAE, null, null, parms.LocalEndPoint.Address.ToString(), NetworkAccessPointTypeEnum.IpAddress, null)); } }
/// <summary> /// Adds the sop class to presentation context for Explicit and Implicit Vr Little Endian /// </summary> /// <param name="sopClass">The sop class.</param> /// <exception cref="DicomException"/> /// <exception cref="ArgumentNullException"/> protected void AddSopClassToPresentationContext(SopClass sopClass) { if (sopClass == null) { throw new ArgumentNullException("sopClass"); } byte pcid = AssociationParameters.FindAbstractSyntax(sopClass); if (pcid == 0) { pcid = AssociationParameters.AddPresentationContext(sopClass); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); } else { throw new DicomException("Cannot find SopClass in association parameters: " + sopClass); } }
public QueryAuditHelper(DicomAuditSource auditSource, EventIdentificationContentsEventOutcomeIndicator outcome, AssociationParameters parms, string sopClassUid, DicomAttributeCollection msg) : base("Query") { AuditMessage.EventIdentification = new EventIdentificationContents() { EventID = EventID.Query, EventActionCode = EventIdentificationContentsEventActionCode.E, EventActionCodeSpecified = true, EventDateTime = Platform.Time.ToUniversalTime(), EventOutcomeIndicator = outcome }; InternalAddActiveDicomParticipant(parms); InternalAddAuditSource(auditSource); AuditQueryMessageParticipantObject o = new AuditQueryMessageParticipantObject(sopClassUid, msg); InternalAddParticipantObject("Query", o); }
private byte GetPresentationContextId(AssociationParameters association) { return association.FindAbstractSyntaxOrThrowException(this.ColorMode == ColorMode.Color ? SopClass.BasicColorPrintManagementMetaSopClass : SopClass.BasicGrayscalePrintManagementMetaSopClass); }
protected abstract DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid);
public virtual void AssociationRelease(DicomServer server, AssociationParameters assoc) { }
/// <summary> /// Scan the files to send, and create presentation contexts for each abstract syntax to send. /// </summary> protected override void SetPresentationContexts() { foreach (StorageInstance sendStruct in _storageInstanceList) { // skip if failed in LoadStorageInstanceInfo, ie file not found if (sendStruct.SendStatus == DicomStatuses.ProcessingFailure) { continue; } if (sendStruct.TransferSyntax.Encapsulated) { // If the image is encapsulated, make sure there's an exact match of the transfer // syntax, if not, just make sure there's an unencapsulated transfer syntax. byte pcid = AssociationParameters.FindAbstractSyntaxWithTransferSyntax(sendStruct.SopClass, sendStruct.TransferSyntax); if (pcid == 0) { pcid = AssociationParameters.AddPresentationContext(sendStruct.SopClass); AssociationParameters.AddTransferSyntax(pcid, sendStruct.TransferSyntax); } // Check for a codec, and if it exists, also register an uncompressed context. IDicomCodec codec = DicomCodecRegistry.GetCodec(sendStruct.TransferSyntax); if (codec != null) { pcid = AssociationParameters.FindAbstractSyntaxWithTransferSyntax(sendStruct.SopClass, TransferSyntax.ExplicitVrLittleEndian); if (pcid == 0) { pcid = AssociationParameters.AddPresentationContext(sendStruct.SopClass); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); } } } else { byte pcid = AssociationParameters.FindAbstractSyntaxWithTransferSyntax(sendStruct.SopClass, TransferSyntax.ExplicitVrLittleEndian); if (pcid == 0) { pcid = AssociationParameters.AddPresentationContext(sendStruct.SopClass); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); AssociationParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); } } // Now add the preferred syntaxes, if its been set. if (_preferredSyntaxes != null) { SupportedSop supportedSop; if (_preferredSyntaxes.TryGetValue(sendStruct.SopClass.Uid, out supportedSop)) { foreach (TransferSyntax syntax in supportedSop.SyntaxList) { byte pcid = AssociationParameters.FindAbstractSyntaxWithTransferSyntax(sendStruct.SopClass, syntax); // If we have more than 1 transfer syntax associated with the preferred, we want to // have a dedicated presentation context for the preferred, so that we ensure it // gets accepted if the SCP supports it. This is only really going to happen if // the preferred is Explicit VR Little Endian or Implicit VR Little Endian. if ((pcid == 0) || (AssociationParameters.GetPresentationContextTransferSyntaxes(pcid).Count > 1)) { pcid = AssociationParameters.AddPresentationContext(sendStruct.SopClass); AssociationParameters.AddTransferSyntax(pcid, syntax); } } } } } }
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 virtual void AssociationAbort(DicomServer server, AssociationParameters assoc) { }
public virtual void OnNetworkError(DicomServer server, AssociationParameters assoc) { }
protected override DicomPresContextResult OnVerifyAssociation(AssociationParameters association, byte pcid) { return(DicomPresContextResult.Accept); }