/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception> protected MessagingCore( MessagingSettings settings, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (collaborationProtocolRegistry == null) { throw new ArgumentNullException(nameof(collaborationProtocolRegistry)); } if (addressRegistry == null) { throw new ArgumentNullException(nameof(addressRegistry)); } Settings = settings; CollaborationProtocolRegistry = collaborationProtocolRegistry; AddressRegistry = addressRegistry; DefaultCertificateValidator = new CertificateValidator(); DefaultMessageProtection = new SignThenEncryptMessageProtection(); ServiceBus = new ServiceBusCore(this); Settings.Validate(); }
/// <summary> /// Contstructor /// </summary> /// <param name="settings">Options for this instance</param> /// <param name="cache">Cache implementation to use</param> /// <param name="adressRegistry">AdressRegistry implementation to use</param> public CollaborationProtocolRegistry( CollaborationProtocolRegistrySettings settings, IDistributedCache cache, IAddressRegistry adressRegistry) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (cache == null) { throw new ArgumentNullException(nameof(cache)); } if (adressRegistry == null) { throw new ArgumentNullException(nameof(adressRegistry)); } _settings = settings; _cache = cache; _adressRegistry = adressRegistry; _invoker = new SoapServiceInvoker(settings.WcfConfiguration); _invoker.SetClientCredentials(_settings.UserName, _settings.Password); CertificateValidator = new CertificateValidator(_settings.UseOnlineRevocationCheck); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> public MessagingClient( MessagingSettings settings, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) : base(settings, collaborationProtocolRegistry, addressRegistry) { _asynchronousServiceBusSender = new AsynchronousSender(ServiceBus); _synchronousServiceBusSender = new SynchronousSender(ServiceBus); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="loggerFactory">Logger Factory</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> public MessagingServer( MessagingSettings settings, ILoggerFactory loggerFactory, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) : base(settings, collaborationProtocolRegistry, addressRegistry) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _logger = _loggerFactory.CreateLogger(nameof(MessagingServer)); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="logger">Logger used for generic messages</param> /// <param name="loggerFactory">Logger Factory</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> /// <param name="certificateStore">Reference to an implementation of <see cref="ICertificateStore"/>.</param> public MessagingServer( MessagingSettings settings, ILogger logger, ILoggerFactory loggerFactory, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry, ICertificateStore certificateStore) : base(settings, collaborationProtocolRegistry, addressRegistry, certificateStore) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="loggerFactory"></param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> public MessagingClient( MessagingSettings settings, ILoggerFactory loggerFactory, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) : base(settings, collaborationProtocolRegistry, addressRegistry) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _logger = _loggerFactory.CreateLogger(nameof(MessagingClient)); _asynchronousServiceBusSender = new AsynchronousSender(ServiceBus); _synchronousServiceBusSender = new SynchronousSender(ServiceBus); }
public MessagingClient( MessagingSettings settings, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry, ICertificateStore certificateStore, ICertificateValidator certificateValidator, IMessageProtection messageProtection) : base(settings, collaborationProtocolRegistry, addressRegistry, certificateStore, certificateValidator, messageProtection) { _asynchronousServiceBusSender = new AsynchronousSender(ServiceBus); _synchronousServiceBusSender = new SynchronousSender(ServiceBus); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="loggerFactory">Logger Factory</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> /// <param name="certificateStore">Reference to an implementation of <see cref="ICertificateStore"/>.</param> /// <param name="certificateValidator">Reference to an implementation of <see cref="ICertificateValidator"/>.</param> /// <param name="messageProtection">Reference to an implementation of <see cref="IMessageProtection"/>.</param> public MessagingServer( MessagingSettings settings, ILoggerFactory loggerFactory, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry, ICertificateStore certificateStore, ICertificateValidator certificateValidator, IMessageProtection messageProtection) : base(settings, collaborationProtocolRegistry, addressRegistry, certificateStore, certificateValidator, messageProtection) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _logger = _loggerFactory.CreateLogger(nameof(MessagingServer)); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception> protected MessagingCore( MessagingSettings settings, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); CollaborationProtocolRegistry = collaborationProtocolRegistry ?? throw new ArgumentNullException(nameof(collaborationProtocolRegistry)); AddressRegistry = addressRegistry ?? throw new ArgumentNullException(nameof(addressRegistry)); ServiceBus = new ServiceBusCore(this); Settings.Validate(); CertificateStore = GetDefaultCertificateStore(); CertificateValidator = GetDefaultCertificateValidator(); MessageProtection = GetDefaultMessageProtection(); }
public void Setup() { var settings = new CollaborationProtocolRegistrySettings() { UserName = "******", Password = "******", EndpointName = "BasicHttpBinding_ICommunicationPartyService", WcfConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None), CachingInterval = TimeSpan.FromSeconds(5), MyHerId = 93238 // matches a value in a CPA test file }; var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddDebug()); var provider = serviceCollection.BuildServiceProvider(); _loggerFactory = provider.GetRequiredService <ILoggerFactory>(); _logger = _loggerFactory.CreateLogger <CollaborationRegistryTests>(); var distributedCache = DistributedCacheFactory.Create(); IAddressRegistry addressRegistry = AddressRegistryTests.GetDefaultAddressRegistryMock(); _registry = new CollaborationProtocolRegistryMock(settings, distributedCache, addressRegistry); _registry.SetupFindAgreementById(i => { var file = Path.Combine("Files", $"CPA_{i:D}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); _registry.SetupFindAgreementForCounterparty(i => { var file = Path.Combine("Files", $"CPA_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); _registry.SetupFindProtocolForCounterparty(i => { if (i < 0) { throw new FaultException(new FaultReason("Dummy fault from mock")); } var file = Path.Combine("Files", $"CPP_{i}.xml"); return(File.Exists(file) == false ? null : File.ReadAllText(file)); }); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> /// <param name="certificateStore"> /// Reference to a custom implementation of <see cref="ICertificateStore"/>, if not set the library will default to Windows Certificate Store. /// Setting this argument to null must be done cautiously as the default implementation of <see cref="IMessageProtection"/> /// <see cref="SignThenEncryptMessageProtection"/> relies on an <see cref="ICertificateStore"/> implementation. /// </param> /// <param name="certificateValidator"> /// Reference to a custom implementation of <see cref="ICertificateValidator"/>, if not set the library will default to the standard implementation /// of <see cref="ICertificateValidator"/>. By setting this parameter to null you effectively disable certificate validation. /// </param> /// <param name="messageProtection"> /// Reference to custom implemenation of <see cref="IMessageProtection"/>, if not set the library will default to standard behavior which relies on /// certificates retrieved from <see cref="ICertificateStore"/>. Setting this parameter to null will throw an <see cref="ArgumentNullException"/>. /// </param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception> protected MessagingCore( MessagingSettings settings, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry, ICertificateStore certificateStore, ICertificateValidator certificateValidator, IMessageProtection messageProtection) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); CollaborationProtocolRegistry = collaborationProtocolRegistry ?? throw new ArgumentNullException(nameof(collaborationProtocolRegistry)); AddressRegistry = addressRegistry ?? throw new ArgumentNullException(nameof(addressRegistry)); ServiceBus = new ServiceBusCore(this); Settings.Validate(); CertificateStore = certificateStore; CertificateValidator = certificateValidator; MessageProtection = messageProtection ?? throw new ArgumentNullException(nameof(messageProtection)); }
/// <summary> /// Constructor /// </summary> /// <param name="settings">Set of options to use</param> /// <param name="logger">Logger used for generic messages</param> /// <param name="loggerFactory">Logger Factory</param> /// <param name="collaborationProtocolRegistry">Reference to the collaboration protocol registry</param> /// <param name="addressRegistry">Reference to the address registry</param> public MessagingServer( MessagingSettings settings, ILogger logger, ILoggerFactory loggerFactory, ICollaborationProtocolRegistry collaborationProtocolRegistry, IAddressRegistry addressRegistry) : base(settings, collaborationProtocolRegistry, addressRegistry) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _logger = logger; _loggerFactory = loggerFactory; }
/// <summary> /// Constructor /// </summary> /// <param name="settings"></param> /// <param name="cache"></param> /// <param name="addressRegistry"></param> public CollaborationProtocolRegistryMock( CollaborationProtocolRegistrySettings settings, IDistributedCache cache, IAddressRegistry addressRegistry) : base(settings, cache, addressRegistry) { }