Esempio n. 1
0
        public static IDictionary <string, string> GetFilterConfigMap(Configuration conf,
                                                                      string prefix)
        {
            IDictionary <string, string> filterConfig = new Dictionary <string, string>();

            //setting the cookie path to root '/' so it is used for all resources.
            filterConfig[AuthenticationFilter.CookiePath] = "/";
            foreach (KeyValuePair <string, string> entry in conf)
            {
                string name = entry.Key;
                if (name.StartsWith(prefix))
                {
                    string value = conf.Get(name);
                    name = Runtime.Substring(name, prefix.Length);
                    filterConfig[name] = value;
                }
            }
            //Resolve _HOST into bind address
            string bindAddress = conf.Get(HttpServer2.BindAddress);
            string principal   = filterConfig[KerberosAuthenticationHandler.Principal];

            if (principal != null)
            {
                try
                {
                    principal = SecurityUtil.GetServerPrincipal(principal, bindAddress);
                }
                catch (IOException ex)
                {
                    throw new RuntimeException("Could not resolve Kerberos principal name: " + ex.ToString
                                                   (), ex);
                }
                filterConfig[KerberosAuthenticationHandler.Principal] = principal;
            }
            return(filterConfig);
        }
Esempio n. 2
0
        public virtual void TestStartsWithIncorrectSettings()
        {
            Configuration conf = new Configuration();

            SecurityUtil.SetAuthenticationMethod(UserGroupInformation.AuthenticationMethod.Kerberos
                                                 , conf);
            string keyTabKey = "key";

            conf.Set(keyTabKey, string.Empty);
            UserGroupInformation.SetConfiguration(conf);
            bool gotException = false;

            try
            {
                SecurityUtil.Login(conf, keyTabKey, string.Empty, string.Empty);
            }
            catch (IOException)
            {
                // expected
                gotException = true;
            }
            Assert.True("Exception for empty keytabfile name was expected",
                        gotException);
        }