Beispiel #1
0
        public void DefaultsAreHandled()
        {
            var emptyObj = new Krb5Config().Serialize();

            var obj = Krb5ConfigurationSerializer.Deserialize(emptyObj).ToConfigObject();

            Assert.AreEqual(5, obj.Defaults.DefaultTgsEncTypes.Count());
        }
Beispiel #2
0
        public void ParseBasicConfiguration()
        {
            var conf = ParseConfiguration();

            var roundtrip = Krb5ConfigurationSerializer.Serialize(conf);

            var conf2 = Krb5ConfigurationSerializer.Deserialize(roundtrip);

            Assert.IsNotNull(conf2);

            Assert.AreEqual(conf.Get <bool>("appdefaults.kadmin.forwardable"), conf2.Get <bool>("appdefaults.kadmin.forwardable"));
        }
Beispiel #3
0
        /// <summary>
        /// Create a KerberosClient instance.
        /// </summary>
        /// <param name="config">The custom configuration this client should use when making Kerberos requests.</param>
        /// <param name="logger">A logger instance for recording client logs</param>
        /// <param name="transports">A collection of network transports that the client
        /// will attempt to use to communicate with the KDC</param>
        public KerberosClient(Krb5Config config = null, ILoggerFactory logger = null, params IKerberosTransport[] transports)
        {
            this.Configuration = config ?? Krb5ConfigurationSerializer.Deserialize(string.Empty).ToConfigObject();

            this.loggerFactory      = logger;
            this.logger             = logger.CreateLoggerSafe <KerberosClient>();
            this.clientLoggingScope = this.logger.BeginScope("KerberosClient");

            this.transport = new KerberosTransportSelector(transports, this.Configuration, logger)
            {
                ScopeId = this.ScopeId
            };

            this.MaximumRetries = 10;
        }
Beispiel #4
0
        public void HandleOptionalValues()
        {
            var conf = new ConfigurationSectionList();

            conf.Set("libdefaults.blah", "123", false);
            conf.Set("libdefaults.allow_weak_crypto", "true", false);

            var obj = conf.ToConfigObject();

            Assert.IsTrue(obj.Defaults.AllowWeakCrypto);
            Assert.AreEqual(obj.Defaults.OptionalProperties["blah"], "123");

            var roundtrip = Krb5ConfigurationSerializer.Serialize(obj);

            Assert.IsTrue(roundtrip.Contains("blah = 123"));

            var conf2 = Krb5ConfigurationSerializer.Deserialize(roundtrip);

            var blah = conf2.Get("libdefaults.blah", typeof(string)).ToString();

            Assert.AreEqual("123", blah);
        }
Beispiel #5
0
        private static ConfigurationSectionList ParseConfiguration()
        {
            var file = ReadDataFile("Configuration\\krb5.conf");

            return(Krb5ConfigurationSerializer.Deserialize(Encoding.Default.GetString(file)));
        }