Exemple #1
0
        /// <exception cref="Javax.Security.Auth.Login.LoginException"/>
        public virtual LoginContext CreateLoginContextZookeeperLocalhost()
        {
            string principalAndRealm           = GetPrincipalAndRealm(ZookeeperLocalhost);
            ICollection <Principal> principals = new HashSet <Principal>();

            principals.AddItem(new KerberosPrincipal(ZookeeperLocalhost));
            Subject subject = new Subject(false, principals, new HashSet <object>(), new HashSet
                                          <object>());

            return(new LoginContext(string.Empty, subject, null, KerberosConfiguration.CreateServerConfig
                                        (ZookeeperLocalhost, keytab_zk)));
        }
Exemple #2
0
        /// <summary>Log in, defaulting to the client context</summary>
        /// <param name="principal">principal</param>
        /// <param name="context">context</param>
        /// <param name="keytab">keytab</param>
        /// <returns>the logged in context</returns>
        /// <exception cref="Javax.Security.Auth.Login.LoginException">failure to log in</exception>
        /// <exception cref="System.IO.FileNotFoundException">no keytab</exception>
        protected internal virtual LoginContext Login(string principal, string context, FilePath
                                                      keytab)
        {
            Log.Info("Logging in as {} in context {} with keytab {}", principal, context, keytab
                     );
            if (!keytab.Exists())
            {
                throw new FileNotFoundException(keytab.GetAbsolutePath());
            }
            ICollection <Principal> principals = new HashSet <Principal>();

            principals.AddItem(new KerberosPrincipal(principal));
            Subject subject = new Subject(false, principals, new HashSet <object>(), new HashSet
                                          <object>());
            LoginContext login;

            login = new LoginContext(context, subject, null, KerberosConfiguration.CreateClientConfig
                                         (principal, keytab));
            login.Login();
            return(login);
        }