示例#1
0
        private void ShouldComplainIfMissingFile(File file)
        {
            // given
            FileUtils.deleteFile(file);

            IDictionary <string, string> @params = stringMap();

            SslPolicyConfig policyConfig = new SslPolicyConfig("default");

            @params[neo4j_home.name()] = _home.AbsolutePath;
            @params[policyConfig.BaseDirectory.name()] = "certificates/default";

            Config config = Config.defaults(@params);

            // when
            try
            {
                SslPolicyLoader.Create(config, NullLogProvider.Instance);
                fail();
            }
            catch (Exception e)
            {
                assertTrue(e.InnerException is FileNotFoundException);
            }
        }
示例#2
0
        /// <summary>
        /// Loads all the SSL policies as defined by the config.
        /// </summary>
        /// <param name="config"> The configuration for the SSL policies. </param>
        /// <returns> A factory populated with SSL policies. </returns>
        public static SslPolicyLoader Create(Config config, LogProvider logProvider)
        {
            SslPolicyLoader policyFactory = new SslPolicyLoader(config, logProvider);

            policyFactory.Load(config, logProvider.GetLog(typeof(SslPolicyLoader)));
            return(policyFactory);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullPolicyIfNullRequested()
        public virtual void ShouldReturnNullPolicyIfNullRequested()
        {
            // given
            SslPolicyLoader sslPolicyLoader = SslPolicyLoader.Create(Config.defaults(), NullLogProvider.Instance);

            // when
            SslPolicy sslPolicy = sslPolicyLoader.GetPolicy(null);

            // then
            assertNull(sslPolicy);
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowLegacyPolicyToBeConfigured()
        public virtual void ShouldNotAllowLegacyPolicyToBeConfigured()
        {
            // given
            IDictionary <string, string> @params = stringMap();

            SslPolicyConfig policyConfig = new SslPolicyConfig(LegacySslPolicyConfig.LEGACY_POLICY_NAME);

            @params[neo4j_home.name()] = _home.AbsolutePath;
            @params[policyConfig.BaseDirectory.name()] = "certificates/default";
            Config config = Config.defaults(@params);

            try
            {
                // when
                SslPolicyLoader.Create(config, NullLogProvider.Instance);
                fail();
            }
            catch (System.ArgumentException)
            {
                // expected
            }
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadBaseCryptographicObjects() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadBaseCryptographicObjects()
        {
            // given
            IDictionary <string, string> @params = stringMap();

            SslPolicyConfig policyConfig = new SslPolicyConfig("default");

            @params[neo4j_home.name()] = _home.AbsolutePath;
            @params[policyConfig.BaseDirectory.name()] = "certificates/default";
            Config config = Config.defaults(@params);

            // when
            SslPolicyLoader sslPolicyLoader = SslPolicyLoader.Create(config, NullLogProvider.Instance);

            // then
            SslPolicy sslPolicy = sslPolicyLoader.GetPolicy("default");

            assertNotNull(sslPolicy);
            assertNotNull(sslPolicy.PrivateKey());
            assertNotNull(sslPolicy.CertificateChain());
            assertNotNull(sslPolicy.NettyClientContext());
            assertNotNull(sslPolicy.NettyServerContext());
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIfPolicyNameDoesNotExist()
        public virtual void ShouldThrowIfPolicyNameDoesNotExist()
        {
            // given
            IDictionary <string, string> @params = stringMap();

            SslPolicyConfig policyConfig = new SslPolicyConfig("default");

            @params[neo4j_home.name()] = _home.AbsolutePath;
            @params[policyConfig.BaseDirectory.name()] = "certificates/default";
            Config config = Config.defaults(@params);

            SslPolicyLoader sslPolicyLoader = SslPolicyLoader.Create(config, NullLogProvider.Instance);

            // when
            try
            {
                sslPolicyLoader.GetPolicy("unknown");
                fail();
            }
            catch (System.ArgumentException)
            {
                // expected
            }
        }