public override void Init() { Trace.TraceInformation("{0} - MQTT Protocol Adapter intialization on Channel '{1}'.", DateTime.UtcNow.ToString("yyyy-MM-ddTHH-MM-ss.fffff"), Channel.Id); auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); forcePerReceiveAuthn = Channel as UdpChannel != null; session.OnPublish += Session_OnPublish; session.OnSubscribe += Session_OnSubscribe; session.OnUnsubscribe += Session_OnUnsubscribe; session.OnDisconnect += Session_OnDisconnect;; session.OnConnect += Session_OnConnect; logger?.LogInformation($"MQTT adpater on channel '{Channel.Id}' is initialized."); }
public Dependency( DbContext dbContext, IAuditFactory auditFactory) { DbContext = dbContext; AuditFactory = auditFactory; }
public override void Init() { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); logger?.LogDebugAsync("MQTT adapter audit factory added.").GetAwaiter(); forcePerReceiveAuthn = Channel as UdpChannel != null; session.OnPublish += Session_OnPublish; session.OnSubscribe += Session_OnSubscribe; session.OnUnsubscribe += Session_OnUnsubscribe; session.OnDisconnect += Session_OnDisconnect; ; session.OnConnect += Session_OnConnect; logger?.LogInformationAsync($"MQTT adpater on channel '{Channel.Id}' is initialized.").GetAwaiter(); }
private void InitializeAuditor(PiraeusConfig config) { if (!string.IsNullOrEmpty(config.AuditConnectionString) && AuditFactory.CreateSingleton().GetAuditor(AuditType.User) == null) { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString.ToLowerInvariant().Contains("AccountName=")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else { string pathString = config.AuditConnectionString.LastIndexOf("/") == config.AuditConnectionString.Length - 1 ? config.AuditConnectionString : config.AuditConnectionString + "/"; auditFactory.Add(new FileAuditor(string.Format($"{pathString}messageaudit.txt")), AuditType.Message); auditFactory.Add(new FileAuditor(string.Format($"{pathString}useraudit.txt")), AuditType.User); } } }
public Dependency( DbContext dbContext, IAuditFactory auditFactory, IConcreteDependency concreteDependency) { DbContext = dbContext; AuditFactory = auditFactory; ConcreteDependency = concreteDependency; }
private void InitializeAuditor(PiraeusConfig config) { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } userAuditor = auditFactory.GetAuditor(AuditType.User); }
public RestProtocolAdapter(PiraeusConfig config, GraphManager graphManager, IChannel channel, HttpContext context, ILog logger = null) { this.config = config; this.channel = channel; this.logger = logger; method = context.Request.Method.ToUpperInvariant(); messageUri = new MessageUri(context.Request); IdentityDecoder decoder = new IdentityDecoder(config.ClientIdentityNameClaimType, context, config.GetClientIndexes()); identity = decoder.Id; indexes = decoder.Indexes; adapter = new OrleansAdapter(identity, channel.TypeId, "REST", graphManager, logger); if (method == "GET") { adapter.OnObserve += Adapter_OnObserve; } protocolType = ProtocolType.REST; contentType = messageUri.ContentType; resource = messageUri.Resource; subscriptions = messageUri.Subscriptions; auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); }
public WsnProtocolAdapter(PiraeusConfig config, GraphManager graphManager, IChannel channel, HttpContext context, ILog logger = null) { this.config = config; this.graphManager = graphManager; Channel = channel; this.logger = logger; IdentityDecoder decoder = new IdentityDecoder(config.ClientIdentityNameClaimType, context, config.GetClientIndexes()); identity = decoder.Id; localIndexes = decoder.Indexes; MessageUri messageUri = new MessageUri(context.Request); contentType = messageUri.ContentType; cacheKey = messageUri.CacheKey; resource = messageUri.Resource; subscriptions = messageUri.Subscriptions != null ? new List <string>(messageUri.Subscriptions) : null; indexes = messageUri.Indexes != null ? new List <KeyValuePair <string, string> >(messageUri.Indexes) : null; auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); }