Esempio n. 1
0
        public FilesWinService(ILog log, IDeaConfig config, IFirewallService firewallService) : base(log, true)
        {
            this.config          = config;
            this.firewallService = firewallService;

            Uri baseAddress = config.FilesServiceUri;

            var webHttpBinding = new WebHttpBinding();

            webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
            webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

            var serviceHost = new IocServiceHost(typeof(FilesService), baseAddress);

            base.serviceHost = serviceHost;

            ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(typeof(IFilesService), webHttpBinding, baseAddress);

            endpoint.Behaviors.Add(new WebHttpBehavior());
            ServiceCredential filesCredentials = config.FilesCredentials;

#if DEBUG
            log.Debug("FilesWinService baseAddress: {0} credentials: {1}:{2}",
                      baseAddress, filesCredentials.Username, filesCredentials.Password);
#endif
            serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(filesCredentials);
            serviceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode  = UserNamePasswordValidationMode.Custom;
        }
        public FilesWinService(ILog log, IConfig config, IFirewallService firewallService)
            : base(log, true)
        {
            this.config = config;
            this.firewallService = firewallService;

            Uri baseAddress = config.FilesServiceUri;

            var webHttpBinding = new WebHttpBinding();
            webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
            webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

            var serviceHost =  new IocServiceHost(typeof(FilesService), baseAddress);
            base.serviceHost = serviceHost;

            ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(typeof(IFilesService), webHttpBinding, baseAddress);
            endpoint.Behaviors.Add(new WebHttpBehavior());
            ServiceCredential filesCredentials = config.FilesCredentials;
            #if DEBUG
            log.Debug("FilesWinService baseAddress: {0} credentials: {1}:{2}",
                baseAddress, filesCredentials.Username, filesCredentials.Password);
            #endif
            serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(filesCredentials);
            serviceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
        }
 public WebServerAdministrationProvider(ILog log, IConfig config, IFirewallService firewallService)
 {
     this.log = log;
     this.localIPAddress = config.LocalIPAddress;
     this.firewallService = firewallService;
     this.appCmdPath = InitAppCmdPath();
 }
Esempio n. 4
0
 public WebServerAdministrationProvider(ILog log, IConfig config, IFirewallService firewallService)
 {
     this.log             = log;
     this.localIPAddress  = config.LocalIPAddress;
     this.firewallService = firewallService;
     this.appCmdPath      = config.AppCmdPath;
 }
 public WebServerAdministrationProvider(ILog log, IDeaConfig config, IFirewallService firewallService)
 {
     this.log = log;
     this.localIPAddress = config.LocalIPAddress;
     this.firewallService = firewallService;
     this.appCmdPath = config.AppCmdPath;
     UnlockLogging();
 }
Esempio n. 6
0
        public CreateFirewallRuleForm(
            Form main, IOptionsService optionsService, IFirewallService firewallService)
            : base(main, optionsService)
        {
            this.firewallService = firewallService;

            InitializeComponent();

            FillCombos();
        }
Esempio n. 7
0
        public AddRulesForm(MainForm main, IFirewallService firewallService,
                            IRuleService ruleService, IOptionsService optionsService)
            : base(main, optionsService)
        {
            this.firewallService = firewallService;
            this.ruleService     = ruleService;
            this.optionsService  = optionsService;

            InitializeComponent();

            FillCombos();
            LoadRules();
        }
Esempio n. 8
0
        public MainForm(IServiceProvider provider)
        {
            Provider        = provider;
            firewallService = Provider.GetRequiredService <IFirewallService>();;
            ruleService     = Provider.GetRequiredService <IRuleService>();
            optionsService  = Provider.GetRequiredService <IOptionsService>();
            LoadOptions();

            InitializeComponent();
            MyInitializeComponent();

            LoadRules();

            SetOutBoundConnectionState(publicAllowOutboundToolStripMenuItem, ProfileDto.Public);
            pnlRules.AutoScrollPosition = new Point(0, 0);
            pnlScrollUp.Disable();
        }
        public MonitoringWinService(ILog log, IDeaConfig config, IFirewallService firewallService)
            : base(log, true)
        {
            this.config = config;
            this.firewallService = firewallService;

            Uri baseAddress = config.MonitoringServiceUri;

            var webHttpBinding = new WebHttpBinding();
            webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
            webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            var serviceHost =  new IocServiceHost(typeof(MonitoringService), baseAddress);
            base.serviceHost = serviceHost;

            ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(typeof(IMonitoringService), webHttpBinding, baseAddress);
            endpoint.Behaviors.Add(new WebHttpBehavior());
            serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(config.MonitoringCredentials);
            serviceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
        }
Esempio n. 10
0
        private RuleControl(
            RuleDto rule, FirewallRuleDto firewallRuleDto,
            RuleControl previous, Point?location,
            IFirewallService firewallService)
        {
            if (previous == null && location == null)
            {
                throw new ArgumentNullException(
                          $"{nameof(previous)},{nameof(location)}");
            }

            InitializeComponent();

            Previous             = previous;
            Rule                 = rule;
            this.firewallRuleDto = firewallRuleDto;
            this.firewallService = firewallService;

            MyInitializeComponent(location);
        }
        public ResourceProvisioningService(
            IServiceProvider serviceProvider,
            IUserService userService,
            IRequestIdService requestIdService,
            IProvisioningQueueService provisioningQueueService,
            ICloudResourceReadService cloudResourceReadService,
            IResourceOperationModelService resourceOperationModelService,
            ICloudResourceOperationReadService resourceOperationReadService,
            ICloudResourceOperationUpdateService resourceOperationUpdateService,
            IProvisioningLogService provisioningLogService,
            IOperationCheckService operationCheckService,
            IOperationCompletedService operationCompletedService,
            ICreateAndUpdateService createAndUpdateService,
            IDeleteOperationService deleteOperationService,
            IRoleProvisioningService roleProvisioningService,
            ICorsRuleProvisioningService corsRuleProvisioningService,
            IFirewallService firewallService)
        {
            _serviceProvider          = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            _userService              = userService ?? throw new ArgumentNullException(nameof(userService));
            _requestIdService         = requestIdService ?? throw new ArgumentNullException(nameof(requestIdService));
            _provisioningQueueService = provisioningQueueService ?? throw new ArgumentNullException(nameof(provisioningQueueService));

            //Resource services
            _resourceReadService = cloudResourceReadService ?? throw new ArgumentNullException(nameof(cloudResourceReadService));

            //Resource operation services
            _resourceOperationModelService  = resourceOperationModelService ?? throw new ArgumentNullException(nameof(resourceOperationModelService));;
            _resourceOperationReadService   = resourceOperationReadService ?? throw new ArgumentNullException(nameof(resourceOperationReadService));
            _resourceOperationUpdateService = resourceOperationUpdateService ?? throw new ArgumentNullException(nameof(resourceOperationUpdateService));

            //Provisioning services
            _provisioningLogService      = provisioningLogService ?? throw new ArgumentNullException(nameof(provisioningLogService));
            _operationCheckService       = operationCheckService ?? throw new ArgumentNullException(nameof(operationCheckService));
            _operationCompletedService   = operationCompletedService ?? throw new ArgumentNullException(nameof(operationCompletedService));
            _createAndUpdateService      = createAndUpdateService ?? throw new ArgumentNullException(nameof(createAndUpdateService));
            _deleteOperationService      = deleteOperationService ?? throw new ArgumentNullException(nameof(deleteOperationService));
            _roleProvisioningService     = roleProvisioningService ?? throw new ArgumentNullException(nameof(roleProvisioningService));
            _corsRuleProvisioningService = corsRuleProvisioningService ?? throw new ArgumentNullException(nameof(corsRuleProvisioningService));
            _firewallService             = firewallService ?? throw new ArgumentNullException(nameof(firewallService));
        }
        public MonitoringWinService(ILog log, IConfig config, IFirewallService firewallService) : base(log, true)
        {
            this.config          = config;
            this.firewallService = firewallService;

            Uri baseAddress = config.MonitoringServiceUri;

            var webHttpBinding = new WebHttpBinding();

            webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
            webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            var serviceHost = new IocServiceHost(typeof(MonitoringService), baseAddress);

            base.serviceHost = serviceHost;

            ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(typeof(IMonitoringService), webHttpBinding, baseAddress);

            endpoint.Behaviors.Add(new WebHttpBehavior());
            serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(config.MonitoringCredentials);
            serviceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode  = UserNamePasswordValidationMode.Custom;
        }
Esempio n. 13
0
 public RuleControl(
     RuleDto rule, FirewallRuleDto firewallRuleDto,
     Point location, IFirewallService firewallService)
     : this(rule, firewallRuleDto, null, location, firewallService)
 {
 }
Esempio n. 14
0
 public RuleControl(
     RuleDto rule, FirewallRuleDto firewallRuleDto,
     RuleControl previous, IFirewallService firewallService)
     : this(rule, firewallRuleDto, previous, null, firewallService)
 {
 }
Esempio n. 15
0
    public static void Test()
    {
        IFirewallManager mgr = (IFirewallManager) new FirewallManager();

        Console.WriteLine("CurrentProfileType: " + mgr.CurrentProfileType);

        IFirewallProfile profile = mgr.LocalPolicy.CurrentProfile;

        Console.WriteLine("FirewallEnabled: " + profile.FirewallEnabled);

        /****************************************************/
        //IFirewallAllowedApplication newApp = (IFirewallAllowedApplication) new FirewallAllowedApplication();
        //   newApp.Enabled = true;
        //   newApp.Name = "FooTestApp";
        //   newApp.Scope = Scope.Subnet;
        //   newApp.ProcessImageFileName = "C:\\Documents and Settings\\Family\\my documents\\hao\\program Files\\colorPic.exe";
        //profile.AuthorizedApplications.Add(newApp);

        profile.AuthorizedApplications.Remove("C:\\Documents and Settings\\Family\\my documents\\hao\\program Files\\colorPic.exe");

        /****************************************************/
        System.Collections.IEnumerator e = profile.AuthorizedApplications._NewEnum;
        Console.WriteLine("\r\n-----  Applications  -----  ");
        while (e.MoveNext())
        {
            IFirewallAllowedApplication app = e.Current as IFirewallAllowedApplication;
            Console.WriteLine("\t{0}\r\n\t\tImageFileName={1}\r\n\t\tEnabled={2}\r\n\t\tIpVersion={3}\r\n\t\tScope={4}\r\n\t\tRemoteAddresses={5}",
                              app.Name, app.ProcessImageFileName, app.Enabled, app.IpVersion,
                              app.Scope, app.RemoteAddresses);
        }

        /****************************************************/
        e = profile.Services._NewEnum;
        Console.WriteLine("\r\n-----  Services  -----  ");
        while (e.MoveNext())
        {
            IFirewallService service = e.Current as IFirewallService;
            Console.WriteLine("\t{0}\r\n\t\tType={1}\r\n\t\tEnabled={2}\r\n\t\tIpVersion={3}" +
                              "\r\n\t\tScope={4}\r\n\t\tCustomized={5}\r\n\t\tRemoteAddresses={6}",
                              service.Name, service.Type, service.Enabled, service.IpVersion,
                              service.Scope, service.Customized, service.RemoteAddresses);
            System.Collections.IEnumerator f = service.GloballyOpenPorts._NewEnum;
            while (f.MoveNext())
            {
                IFirewallOpenPort x = f.Current as IFirewallOpenPort;
                Console.WriteLine("\tPortage: [Name: {0}] [Protocol: {1}] [Port: {2}]",
                                  x.Name, x.Protocol, x.Port);
            }
        }

        e = profile.GloballyOpenPorts._NewEnum;
        Console.WriteLine("\r\n-----  Globally open ports  -----  ");
        while (e.MoveNext())
        {
            IFirewallOpenPort port = e.Current as IFirewallOpenPort;
            Console.WriteLine("\t{0}\r\n\t\tIsBuiltIn={1}\r\n\t\tEnabled={2}\r\n\t\tIpVersion={3}" +
                              "\r\n\t\tScope={4}\r\n\t\tProtocol={5}\r\n\t\tRemoteAddresses={6}\r\n\t\tPort={7}",
                              port.Name, port.BuiltIn, port.Enabled, port.IpVersion,
                              port.Scope, port.Protocol, port.RemoteAddresses, port.Port
                              );
        }


        Console.ReadLine();
    }     // Test()