Exception OnAsyncNegotiationFailure(Exception e) { EndpointAddress pinnedEpr = null; try { pinnedEpr = (this.negotiationState == null) ? null : this.negotiationState.RemoteAddress; Cleanup(); } catch (CommunicationException ex) { DiagnosticUtility.TraceHandledException(ex, TraceEventType.Information); } return(IssuanceTokenProviderBase <T> .WrapExceptionIfRequired(e, pinnedEpr, this.issuer)); }
private Exception OnAsyncNegotiationFailure(Exception e) { EndpointAddress targetAddress = null; try { targetAddress = (this.negotiationState == null) ? null : this.negotiationState.RemoteAddress; this.Cleanup(); } catch (CommunicationException exception) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information); } } return(IssuanceTokenProviderBase <T> .WrapExceptionIfRequired(e, targetAddress, this.issuer)); }
private Exception OnSyncNegotiationFailure(Exception e) { EndpointAddress targetAddress = (this.negotiationState == null) ? null : this.negotiationState.RemoteAddress; return(IssuanceTokenProviderBase <T> .WrapExceptionIfRequired(e, targetAddress, this.issuer)); }
protected SecurityToken DoNegotiation(TimeSpan timeout) { SecurityToken token2; this.ThrowIfClosedOrCreated(); SecurityTraceRecordHelper.TraceBeginSecurityNegotiation <T>((IssuanceTokenProviderBase <T>) this, this.targetAddress); TimeoutHelper helper = new TimeoutHelper(timeout); IRequestChannel rstChannel = null; T negotiationState = default(T); TimeSpan span = timeout; int num = 1; try { negotiationState = this.CreateNegotiationState(this.targetAddress, this.via, helper.RemainingTime()); this.InitializeNegotiationState(negotiationState); this.InitializeChannelFactories(negotiationState.RemoteAddress, helper.RemainingTime()); rstChannel = this.CreateClientChannel(negotiationState.RemoteAddress, this.via); rstChannel.Open(helper.RemainingTime()); Message nextOutgoingMessage = null; Message incomingMessage = null; SecurityToken serviceToken = null; while (true) { nextOutgoingMessage = this.GetNextOutgoingMessage(incomingMessage, negotiationState); if (incomingMessage != null) { incomingMessage.Close(); } if (nextOutgoingMessage == null) { break; } using (nextOutgoingMessage) { TraceUtility.ProcessOutgoingMessage(nextOutgoingMessage); span = helper.RemainingTime(); incomingMessage = rstChannel.Request(nextOutgoingMessage, span); if (incomingMessage == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("FailToRecieveReplyFromNegotiation"))); } TraceUtility.ProcessIncomingMessage(incomingMessage); } num += 2; } if (!negotiationState.IsNegotiationCompleted) { throw TraceUtility.ThrowHelperError(new SecurityNegotiationException(System.ServiceModel.SR.GetString("NoNegotiationMessageToSend")), incomingMessage); } try { rstChannel.Close(helper.RemainingTime()); } catch (CommunicationException exception) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information); } rstChannel.Abort(); } catch (TimeoutException exception2) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information); } rstChannel.Abort(); } rstChannel = null; this.ValidateAndCacheServiceToken(negotiationState); serviceToken = negotiationState.ServiceToken; SecurityTraceRecordHelper.TraceEndSecurityNegotiation <T>((IssuanceTokenProviderBase <T>) this, serviceToken, this.targetAddress); token2 = serviceToken; } catch (Exception exception3) { if (Fx.IsFatal(exception3)) { throw; } if (exception3 is TimeoutException) { exception3 = new TimeoutException(System.ServiceModel.SR.GetString("ClientSecurityNegotiationTimeout", new object[] { timeout, num, span }), exception3); } EndpointAddress targetAddress = (negotiationState == null) ? null : negotiationState.RemoteAddress; throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(IssuanceTokenProviderBase <T> .WrapExceptionIfRequired(exception3, targetAddress, this.issuerAddress)); } finally { this.Cleanup(rstChannel, negotiationState); } return(token2); }