Esempio n. 1
0
        protected override void OnReceiveAssociateReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
        {
            _handler.OnReceiveAssociateReject(this, _assoc as ClientAssociationParameters, result, source, reason);

            _closedOnError = true;
            CloseNetwork(System.Threading.Timeout.Infinite);
        }
        /// <summary>
        /// Do the actual verification if an association is acceptable.
        /// </summary>
        /// <remarks>
        /// This method primarily checks the remote AE title to see if it is a valid device that can 
        /// connect to the partition.
        /// </remarks>
        /// <param name="context">Generic parameter passed in, is a DicomScpParameters instance.</param>
        /// <param name="assocParms">The association parameters.</param>
        /// <param name="result">Output parameter with the DicomRejectResult for rejecting the association.</param>
        /// <param name="reason">Output parameter with the DicomRejectReason for rejecting the association.</param>
        /// <returns>true if the association should be accepted, false if it should be rejected.</returns>
        public static bool Verify(DicomScpContext context, ServerAssociationParameters assocParms,
                                  out DicomRejectResult result, out DicomRejectReason reason)
        {
            bool isNew;
            Device device = DeviceManager.LookupDevice(context.Partition, assocParms, out isNew);

            if (device == null)
            {
                if (context.Partition.AcceptAnyDevice)
                {
                    reason = DicomRejectReason.NoReasonGiven;
                    result = DicomRejectResult.Permanent;
                    return true;
                }

                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return false;
            }

            if (device.Enabled == false)
            {
                Platform.Log(LogLevel.Error, "Rejecting association from {0} to {1}.  Device is disabled.",
                                       assocParms.CallingAE, assocParms.CalledAE);

                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return false;
            }

            reason = DicomRejectReason.NoReasonGiven;
            result = DicomRejectResult.Permanent;

            return true;
        }
Esempio n. 3
0
 /// <summary>
 /// Reads A-ASSOCIATE-RJ from PDU buffer
 /// </summary>
 /// <param name="raw">PDU buffer</param>
 public void Read(RawPDU raw)
 {
     raw.ReadByte("Reserved");
     _rt = (DicomRejectResult)raw.ReadByte("Result");
     _so = (DicomRejectSource)raw.ReadByte("Source");
     _rn = (DicomRejectReason)raw.ReadByte("Reason");
 }
Esempio n. 4
0
        /// <summary>
        /// Do the actual verification if an association is acceptable.
        /// </summary>
        /// <remarks>
        /// This method primarily checks the remote AE title to see if it is a valid device that can
        /// connect to the partition.
        /// </remarks>
        /// <param name="context">Generic parameter passed in, is a DicomScpParameters instance.</param>
        /// <param name="assocParms">The association parameters.</param>
        /// <param name="result">Output parameter with the DicomRejectResult for rejecting the association.</param>
        /// <param name="reason">Output parameter with the DicomRejectReason for rejecting the association.</param>
        /// <returns>true if the association should be accepted, false if it should be rejected.</returns>
        public static bool Verify(DicomScpContext context, ServerAssociationParameters assocParms,
                                  out DicomRejectResult result, out DicomRejectReason reason)
        {
            bool   isNew;
            Device device = DeviceManager.LookupDevice(assocParms, out isNew);

            if (device == null)
            {
                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return(false);
            }

            if (device.Enabled == false)
            {
                LogAdapter.Logger.ErrorWithFormat("Rejecting association from {0} to {1}.  Device is disabled.",
                                                  assocParms.CallingAE, assocParms.CalledAE);

                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return(false);
            }

            reason = DicomRejectReason.NoReasonGiven;
            result = DicomRejectResult.Permanent;

            return(true);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes an instance of the <see cref="AssociationRejectedEventArgs"/> class.
 /// </summary>
 /// <param name="result">Association rejection result.</param>
 /// <param name="source">Source of association rejection.</param>
 /// <param name="reason">Reason for association rejection.</param>
 public AssociationRejectedEventArgs(DicomRejectResult result, DicomRejectSource source,
                                     DicomRejectReason reason)
 {
     Result = result;
     Source = source;
     Reason = reason;
 }
Esempio n. 6
0
 public void OnReceiveAssociationReject(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
 {
     this.SetComplete();
     throw new DicomAssociationRejectedException(result, source, reason);
 }
Esempio n. 7
0
 /// <summary>
 /// Callback for handling association reject scenarios.
 /// </summary>
 /// <param name="result">Specification of rejection result.</param>
 /// <param name="source">Source of rejection.</param>
 /// <param name="reason">Detailed reason for rejection.</param>
 public void OnReceiveAssociationReject(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
 {
     this.client.associateNotifier.TrySetResult(false);
     SetComplete(new DicomAssociationRejectedException(result, source, reason));
 }
 protected virtual bool CreateVerify(DicomScpContext context,
                                     ServerAssociationParameters assocParms,
                                     out DicomRejectResult result,
                                     out DicomRejectReason reason)
 {
     return(AssociationVerifier.Verify(context,
                                       assocParms,
                                       out result,
                                       out reason));
 }
 public DicomAssociationRejectedException(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
     : base("Association rejected [result: {0}; source: {1}; reason: {2}]", result, source, reason)
 {
     RejectResult = result;
     RejectSource = source;
     RejectReason = reason;
 }
Esempio n. 10
0
 /// <summary>
 ///     Called when [receive associate reject].
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="association">The association.</param>
 /// <param name="result">The result.</param>
 /// <param name="source">The source.</param>
 /// <param name="reason">The reason.</param>
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association,
                                      DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     FailureDescription =
         string.Format("Association Rejection when {0} connected to remote AE {1}:{2}, Reason {3}",
                       association.CallingAE,
                       association.CalledAE, association.RemoteEndPoint, reason);
     LogAdapter.Logger.Warn(FailureDescription);
     StopRunningOperation(ScuOperationStatus.AssociationRejected);
 }
 public DicomAssociationRejectedException(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
     : base($"Association rejected [result: {result}; source: {source}; reason: {reason}]")
 {
     RejectResult = result;
     RejectSource = source;
     RejectReason = reason;
 }
Esempio n. 12
0
            /// <inheritdoc />
            public void OnReceiveAssociationReject(
                DicomRejectResult result,
                DicomRejectSource source,
                DicomRejectReason reason)
            {
                SetHasAssociationFlag(false);
                _client.AssociationRejected(_client, new AssociationRejectedEventArgs(result, source, reason));

                SetCompletionFlag(new DicomAssociationRejectedException(result, source, reason));
            }
 public DicomAssociationRejectedException(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
     : base("Association rejected [result: {0}; source: {1}; reason: {2}]", result, source, reason)
 {
     RejectResult = result;
     RejectSource = source;
     RejectReason = reason;
 }
Esempio n. 14
0
            public void OnReceiveAssociationReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
            {
                if (_timer != null)
                {
                    _timer.Change(Timeout.Infinite, Timeout.Infinite);
                }

                _client._exception = new DicomAssociationRejectedException(result, source, reason);
                _client._async.Set();
            }
Esempio n. 15
0
        public static bool VerifyAssociation(IDicomServerContext context, AssociationParameters assoParams, 
            out DicomRejectResult result, out DicomRejectReason reason)
        {
            string calledAET = (assoParams.CalledAE ?? "").Trim();
            string callingAET = (assoParams.CallingAE ?? "").Trim();

            result = DicomRejectResult.Permanent;
            reason = DicomRejectReason.NoReasonGiven;

            return true;
        }
Esempio n. 16
0
            /// <inheritdoc />
            public void OnReceiveAssociationReject(
                DicomRejectResult result,
                DicomRejectSource source,
                DicomRejectReason reason)
            {
                SetAssociationRequestedFlag(false);
                _client.AssociationRejected(_client, new AssociationRejectedEventArgs(result, source, reason));

                SetCompletionFlag(new DicomAssociationRejectedException(result, source, reason));

                //  tell awaiters association was released unsuccessfully.
                this.SetAssociationReleasedFlag(false);
            }
Esempio n. 17
0
		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;
		}
Esempio n. 18
0
        public override Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
        {
            _onAssociationRejectedTaskCompletionSource.TrySetResultAsynchronously(new DicomAssociationRejectedEvent(result, source, reason));

            return(CompletedTaskProvider.CompletedTask);
        }
Esempio n. 19
0
            public void OnReceiveAssociationReject(
                DicomRejectResult result,
                DicomRejectSource source,
                DicomRejectReason reason)
            {
                if (_timer != null) _timer.Change(Timeout.Infinite, Timeout.Infinite);

                _client._exception = new DicomAssociationRejectedException(result, source, reason);
                _client._async.Set();
            }
Esempio n. 20
0
 /// <summary>
 /// Initializes new A-ASSOCIATE-RJ
 /// </summary>
 /// <param name="rt">Rejection result</param>
 /// <param name="so">Rejection source</param>
 /// <param name="rn">Rejection reason</param>
 public AAssociateRJ(DicomRejectResult rt, DicomRejectSource so, DicomRejectReason rn)
 {
     _rt = rt;
     _so = so;
     _rn = rn;
 }
Esempio n. 21
0
 public void Read(RawPDU raw)
 {
     raw.ReadByte("Reserved");
     _rt = (DicomRejectResult)raw.ReadByte("Result");
     _so = (DicomRejectSource)raw.ReadByte("Source");
     _rn = (DicomRejectReason)raw.ReadByte("Reason");
 }
 public abstract Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason);
        /// <summary>
        /// Do the actual verification if an association is acceptable.
        /// </summary>
        /// <remarks>
        /// This method primarily checks the remote AE title to see if it is a valid device that can
        /// connect to the partition.
        /// </remarks>
        /// <param name="context">Generic parameter passed in, is a DicomScpParameters instance.</param>
        /// <param name="assocParms">The association parameters.</param>
        /// <param name="result">Output parameter with the DicomRejectResult for rejecting the association.</param>
        /// <param name="reason">Output parameter with the DicomRejectReason for rejecting the association.</param>
        /// <returns>true if the association should be accepted, false if it should be rejected.</returns>
        public static bool Verify(DicomScpContext context, ServerAssociationParameters assocParms, out DicomRejectResult result, out DicomRejectReason reason)
        {
            bool isNew;

            context.Device = DeviceManager.LookupDevice(context.Partition, assocParms, out isNew);

            if (context.Device == null)
            {
                if (context.Partition.AcceptAnyDevice)
                {
                    reason = DicomRejectReason.NoReasonGiven;
                    result = DicomRejectResult.Permanent;
                    return(true);
                }

                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return(false);
            }

            if (context.Device.Enabled == false)
            {
                Platform.Log(LogLevel.Error,
                             "Rejecting association from {0} to {1}.  Device is disabled.",
                             assocParms.CallingAE, assocParms.CalledAE);

                reason = DicomRejectReason.CallingAENotRecognized;
                result = DicomRejectResult.Permanent;
                return(false);
            }

            reason = DicomRejectReason.NoReasonGiven;
            result = DicomRejectResult.Permanent;

            return(true);
        }
Esempio n. 24
0
 /// <summary>
 /// Callback for handling association reject scenarios.
 /// </summary>
 /// <param name="result">Specification of rejection result.</param>
 /// <param name="source">Source of rejection.</param>
 /// <param name="reason">Detailed reason for rejection.</param>
 public void OnReceiveAssociationReject(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
 {
     this.client.associateNotifier.TrySetResult(false);
     SetComplete(new DicomAssociationRejectedException(result, source, reason));
 }
Esempio n. 25
0
 internal Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 => ExecuteWithinTransitionLock(() => State.OnReceiveAssociationRejectAsync(result, source, reason));
Esempio n. 26
0
        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);
        }
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Console.WriteLine("Association was rejected!");
     Platform.Log(LogLevel.Info, "Association was rejected!");
     Assoc_Accept_Reject = true;
 }
Esempio n. 28
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Logger.LogInfo("Association Rejection when {0} connected to remote AE {1}", association.CallingAE, association.CalledAE);
     _dicomClient = null;
 }
Esempio n. 29
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Logger.LogInfo("Association Rejection when {0} connected to remote AE {1}", association.CallingAE, association.CalledAE);
     _verificationResult = VerificationResult.Failed;
     ProgressEvent.Set();
 }
Esempio n. 30
0
        public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
        {

        }
Esempio n. 31
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Logger.LogInfo("Association Rejection when {0} connected to remote AE {1}", association.CallingAE, association.CalledAE);
     _verificationResult = VerificationResult.Failed;
     ProgressEvent.Set();
 }
Esempio n. 32
0
        /// <summary>
        /// Method to send an association rejection.
        /// </summary>
        /// <param name="result">The </param>
        /// <param name="source"></param>
        /// <param name="reason"></param>
        public void SendAssociateReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
        {
            if (State != DicomAssociationState.Sta3_AwaitingLocalAAssociationResponsePrimative)
            {
                Platform.Log(LogLevel.Error, "Error attempting to send association reject at invalid time in association.");
                SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified);
                throw new DicomNetworkException(
                    "Attempting to send association reject at invalid time in association, aborting");
            }
            var pdu = new AAssociateRJ(result, source, reason);

            EnqueuePdu(pdu.Write());

            State = DicomAssociationState.Sta13_AwaitingTransportConnectionClose;

            if (AssociationRejected != null)
                AssociationRejected(source, reason);
        }
Esempio n. 33
0
 protected void SendAssociationReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Logger.Info("{0} -> Association reject [result: {1}; source: {2}; reason: {3}]", LogID, result, source, reason);
     SendPDU(new AAssociateRJ(result, source, reason));
 }
Esempio n. 34
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     if (_type == TestTypes.AssociationReject)
     {
         Assert.IsTrue(source == DicomRejectSource.ServiceProviderACSE);
         Assert.IsTrue(result == DicomRejectResult.Permanent);
         Assert.IsTrue(reason == DicomRejectReason.NoReasonGiven);
         _threadStop.Set();
     }
     else
     {
         Assert.Fail("Incorrectly received OnReceiveAssociateReject callback");
     }
 }
Esempio n. 35
0
 public AAssociateRJ(DicomRejectResult rt, DicomRejectSource so, DicomRejectReason rn)
 {
     _rt = rt;
     _so = so;
     _rn = rn;
 }
Esempio n. 36
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     Logger.LogInfo("Association Rejection when {0} connected to remote AE {1}", association.CallingAE, association.CalledAE);
     _dicomClient = null;
 }
Esempio n. 37
0
 /// <summary>
 /// Send association reject response.
 /// </summary>
 /// <param name="result">Rejection result.</param>
 /// <param name="source">Rejection source.</param>
 /// <param name="reason">Rejection reason.</param>
 protected void SendAssociationReject(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
 {
     Logger.Info(
         "{logId} -> Association reject [result: {result}; source: {source}; reason: {reason}]",
         LogID,
         result,
         source,
         reason);
     this.SendPDUAsync(new AAssociateRJ(result, source, reason)).Wait();
 }
Esempio n. 38
0
 public void OnReceiveAssociationReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     _client._exception = new DicomAssociationRejectedException(result, source, reason);
     _client._async.Set();
 }
Esempio n. 39
0
 public Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     return(DicomClient.OnReceiveAssociationRejectAsync(result, source, reason));
 }
Esempio n. 40
0
		protected override void OnReceiveAssociateReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason) {

            _handler.OnReceiveAssociateReject(this, _assoc as ClientAssociationParameters, result, source, reason);

            _closedOnError = true;
			CloseNetwork(System.Threading.Timeout.Infinite);
		}
Esempio n. 41
0
 public Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     return(CompletedTaskProvider.CompletedTask);
 }
Esempio n. 42
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     if (_type == TestTypes.AssociationReject)
     {
         Assert.IsTrue(source == DicomRejectSource.ServiceProviderACSE);
         Assert.IsTrue(result == DicomRejectResult.Permanent);
         Assert.IsTrue(reason == DicomRejectReason.NoReasonGiven);
         _threadStop.Set();
     }
     else
         Assert.Fail("Incorrectly received OnReceiveAssociateReject callback");
 }
Esempio n. 43
0
		protected void SendAssociationReject(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason) {
			Logger.Info("{0} -> Association reject [result: {1}; source: {2}; reason: {3}]", LogID, result, source, reason);
			SendPDU(new AAssociateRJ(result, source, reason));
		}
Esempio n. 44
0
 public Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason) => Task.CompletedTask;
Esempio n. 45
0
 protected virtual void OnReceiveAssociateReject(DicomRejectResult result, DicomRejectSource source,
                                                 DicomRejectReason reason)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public override Task OnReceiveAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
     _dicomClient.Logger.Warn($"[{this}] Received association reject but we already have an active association!");
     return(CompletedTaskProvider.CompletedTask);
 }
Esempio n. 47
0
 public void OnReceiveAssociateReject(DicomClient client, ClientAssociationParameters association, DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
 {
 }
Esempio n. 48
0
 public void OnReceiveAssociationReject(
     DicomRejectResult result,
     DicomRejectSource source,
     DicomRejectReason reason)
 {
     this.SetComplete();
     throw new DicomAssociationRejectedException(result, source, reason);
 }