예제 #1
0
        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;
 }
예제 #3
0
        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();
        }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
 public Dependency(
     DbContext dbContext,
     IAuditFactory auditFactory,
     IConcreteDependency concreteDependency)
 {
     DbContext          = dbContext;
     AuditFactory       = auditFactory;
     ConcreteDependency = concreteDependency;
 }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }