public void Cleanup() { DebugTrace.TraceEnter(this, "Cleanup"); if (this.namedPipeActivationChannelFactory != null) { this.CloseChannelFactory(this.namedPipeActivationChannelFactory); this.namedPipeActivationChannelFactory = null; } if (this.windowsActivationChannelFactory != null) { this.CloseChannelFactory(this.windowsActivationChannelFactory); this.windowsActivationChannelFactory = null; } if (this.interopDatagramChannelFactory != null) { this.CloseChannelFactory(this.interopDatagramChannelFactory); this.interopDatagramChannelFactory = null; } if (this.interopRegistrationChannelFactory != null) { this.CloseChannelFactory(this.interopRegistrationChannelFactory); this.interopRegistrationChannelFactory = null; } if (this.interopActivationChannelFactory != null) { this.CloseChannelFactory(this.interopActivationChannelFactory); this.interopActivationChannelFactory = null; } DebugTrace.TraceLeave(this, "Cleanup"); }
protected override void InitializeRuntime() { DebugTrace.TraceEnter(this, "OnCreateListeners"); base.InitializeRuntime(); if (base.SingletonInstance is IWSActivationCoordinator) { if (DebugTrace.Info) { for (int i = 0; i < base.ChannelDispatchers.Count; i++) { ChannelDispatcher dispatcher = base.ChannelDispatchers[i] as ChannelDispatcher; if (dispatcher != null) { for (int j = 0; j < dispatcher.Endpoints.Count; j++) { EndpointDispatcher dispatcher2 = dispatcher.Endpoints[j]; DebugTrace.Trace(TraceLevel.Info, "Listening on {0}", dispatcher2.EndpointAddress.Uri); } } } } } else { this.CreateBaseEndpointAddress(); } DebugTrace.TraceLeave(this, "OnCreateListeners"); }
public bool FaultInSupportingToken(Message message) { DebugTrace.TraceEnter(this, "FaultInSupportingToken"); bool flag = false; WsatRegistrationHeader header = this.ReadRegistrationHeader(message); if (((header == null) || (header.TransactionId == Guid.Empty)) || string.IsNullOrEmpty(header.TokenId)) { if (DebugTrace.Warning) { DebugTrace.Trace(TraceLevel.Warning, "Invalid or absent RegisterInfo in register message"); } } else { currentSct = this.DeriveToken(header.TransactionId, header.TokenId); flag = true; if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Created SCT with id {0} for transaction {1}", header.TokenId, header.TransactionId); } } DebugTrace.TraceLeave(this, "FaultInSupportingToken"); return(flag); }
protected void OnReceive(Message message) { DebugTrace.TraceEnter(this, "OnReceive"); if ((message != null) && !this.tokenResolver.FaultInSupportingToken(message)) { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Failed to fault in SCT for supporting token signature"); } Fault invalidParameters = Faults.Version(this.protocolVersion).InvalidParameters; if (message.Headers.MessageId != null) { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Attempting to send {0} fault", invalidParameters.Code.Name); } Message reply = Library.CreateFaultMessage(message.Headers.MessageId, message.Version, invalidParameters); RequestReplyCorrelator.AddressReply(reply, new RequestReplyCorrelator.ReplyToInfo(message)); SendSecurityHeader header = SupportingTokenChannel <TChannel> .SecurityStandardsManager.CreateSendSecurityHeader(reply, string.Empty, true, false, SecurityAlgorithmSuite.Default, MessageDirection.Output); header.RequireMessageProtection = false; header.AddTimestamp(SecurityProtocolFactory.defaultTimestampValidityDuration); reply = header.SetupExecution(); this.TrySendFaultReply(reply); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(Microsoft.Transactions.SR.GetString("SupportingTokenSignatureExpected"))); } DebugTrace.TraceLeave(this, "OnReceive"); }
public ICoordinationListener Add(IRegistrationCoordinator serviceInstance) { DebugTrace.TraceEnter("CoordinationService.Add (IRegistrationCoordinator)"); this.AssertProtocolServiceMode(); IWSRegistrationCoordinator dispatcher = RegistrationCoordinatorDispatcher.Instance(this, serviceInstance); ICoordinationListener listener = this.CreateService(dispatcher, dispatcher.ContractType, BindingStrings.RegistrationCoordinatorSuffix(this.protocolVersion)); DebugTrace.TraceLeave("CoordinationService.Add (IRegistrationCoordinator)"); return(listener); }
public ICoordinationListener Add(ICompletionParticipant serviceInstance) { DebugTrace.TraceEnter("CoordinationService.Add (ICompletionParticipant)"); this.AssertProtocolServiceMode(); IWSCompletionParticipant dispatcher = CompletionParticipantDispatcher.Instance(this, serviceInstance); ICoordinationListener listener = this.CreateService(dispatcher, dispatcher.ContractType, BindingStrings.CompletionParticipantSuffix(this.protocolVersion)); DebugTrace.TraceLeave("CoordinationService.Add (ICompletionParticipant)"); return(listener); }
public SecurityContextSecurityToken GetContext(UniqueId contextId, UniqueId generation) { DebugTrace.TraceEnter(this, "GetContext"); SecurityContextSecurityToken currentSct = null; if (((SupportingTokenSecurityTokenResolver.currentSct != null) && (SupportingTokenSecurityTokenResolver.currentSct.ContextId == contextId)) && (SupportingTokenSecurityTokenResolver.currentSct.KeyGeneration == generation)) { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Found SCT with matching id {0}", contextId); } currentSct = SupportingTokenSecurityTokenResolver.currentSct; SupportingTokenSecurityTokenResolver.currentSct = null; } DebugTrace.TraceLeave(this, "GetContext"); return(currentSct); }
public CoordinationService(CoordinationServiceConfiguration config, Microsoft.Transactions.Wsat.Protocol.ProtocolVersion protocolVersion) { this.protocolVersion = protocolVersion; DebugTrace.TraceEnter(this, "CoordinationService"); try { this.Initialize(config); } catch { this.Cleanup(); throw; } finally { DebugTrace.TraceLeave(this, "CoordinationService"); } }
private void Initialize(CoordinationServiceConfiguration config) { DebugTrace.TraceEnter(this, "Initialize"); this.config = config; this.security = new CoordinationServiceSecurity(); if ((config.Mode == 0) || ((config.Mode & ~(CoordinationServiceMode.ProtocolService | CoordinationServiceMode.Formatter)) != 0)) { DiagnosticUtility.FailFast("Invalid CoordinationServiceMode"); } if ((config.Mode & CoordinationServiceMode.ProtocolService) == 0) { if (!string.IsNullOrEmpty(config.BasePath)) { DiagnosticUtility.FailFast("A base path must not be provided if protocol service mode is not enabled"); } if (!string.IsNullOrEmpty(config.HostName)) { DiagnosticUtility.FailFast("A hostname must not be provided if protocol service mode is not enabled"); } } else { if (string.IsNullOrEmpty(config.BasePath)) { DiagnosticUtility.FailFast("A base path must be provided if protocol service mode is enabled"); } if (string.IsNullOrEmpty(config.HostName)) { DiagnosticUtility.FailFast("A hostname must be provided if protocol service mode is enabled"); } if (config.X509Certificate == null) { DiagnosticUtility.FailFast("No authentication mechanism was provided for the protocol service"); } } this.globalAclAuthz = new GlobalAclOperationRequirement(config.GlobalAclWindowsIdentities, config.GlobalAclX509CertificateThumbprints, this.protocolVersion); if ((this.config.Mode & CoordinationServiceMode.ProtocolService) != 0) { this.httpsBaseAddressUri = new UriBuilder(Uri.UriSchemeHttps, this.config.HostName, this.config.HttpsPort, this.config.BasePath).Uri; this.namedPipeBaseAddressUri = new UriBuilder(Uri.UriSchemeNetPipe, "localhost", -1, this.config.HostName + "/" + this.config.BasePath).Uri; } this.namedPipeActivationBinding = new NamedPipeBinding(this.protocolVersion); if (this.config.RemoteClientsEnabled) { this.windowsActivationBinding = new WindowsRequestReplyBinding(this.protocolVersion); } this.interopDatagramBinding = new Microsoft.Transactions.Wsat.Messaging.InteropDatagramBinding(this.protocolVersion); this.interopRegistrationBinding = new Microsoft.Transactions.Wsat.Messaging.InteropRegistrationBinding(this.httpsBaseAddressUri, this.config.SupportingTokensEnabled, this.protocolVersion); this.interopActivationBinding = new Microsoft.Transactions.Wsat.Messaging.InteropActivationBinding(this.httpsBaseAddressUri, this.protocolVersion); ClientCredentials item = new ClientCredentials { ClientCertificate = { Certificate = this.config.X509Certificate }, ServiceCertificate = { DefaultCertificate = this.config.X509Certificate } }; if ((this.config.Mode & CoordinationServiceMode.ProtocolService) != 0) { this.interopDatagramChannelFactory = this.CreateChannelFactory <IDatagramService>(this.interopDatagramBinding); this.interopDatagramChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>(); this.interopDatagramChannelFactory.Endpoint.Behaviors.Add(item); this.OpenChannelFactory <IDatagramService>(this.interopDatagramChannelFactory); this.interopRegistrationChannelFactory = this.CreateChannelFactory <IRequestReplyService>(this.interopRegistrationBinding); this.interopRegistrationChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>(); this.interopRegistrationChannelFactory.Endpoint.Behaviors.Add(item); this.OpenChannelFactory <IRequestReplyService>(this.interopRegistrationChannelFactory); } if ((config.Mode & CoordinationServiceMode.Formatter) != 0) { if (this.config.X509Certificate != null) { this.interopActivationChannelFactory = this.CreateChannelFactory <IRequestReplyService>(this.interopActivationBinding); this.interopActivationChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>(); this.interopActivationChannelFactory.Endpoint.Behaviors.Add(item); this.OpenChannelFactory <IRequestReplyService>(this.interopActivationChannelFactory); } this.namedPipeActivationChannelFactory = this.CreateChannelFactory <IRequestReplyService>(this.namedPipeActivationBinding); this.OpenChannelFactory <IRequestReplyService>(this.namedPipeActivationChannelFactory); if (this.config.RemoteClientsEnabled) { this.windowsActivationChannelFactory = this.CreateChannelFactory <IRequestReplyService>(this.windowsActivationBinding); this.OpenChannelFactory <IRequestReplyService>(this.windowsActivationChannelFactory); } } this.requestReplyChannelCache = new ChannelMruCache <IRequestReplyService>(); if ((this.config.Mode & CoordinationServiceMode.ProtocolService) != 0) { this.datagramChannelCache = new ChannelMruCache <IDatagramService>(); } DebugTrace.TraceLeave(this, "Initialize"); }