public static Configuration useTicketCache(String principal, File credentialFile) { return new TicketCacheJaasConf(principal, credentialFile); }
public static Configuration useKeytab(String principal, File keytabFile) { return new KeytabJaasConf(principal, keytabFile); }
public void initKrb5conf() throws IOException { File confFile = generateConfFile(); System.setProperty(KRB5_CONF, confFile.getAbsolutePath()); }
final AdminConfig adminConfig = new AdminConfig(); adminConfig.addKrb5Config(confFile); Krb5Conf krb5Conf = new Krb5Conf(new File(confDirPath), tmpKdcConfig); krb5Conf.initKrb5conf(); } catch (IOException e) { throw new KrbException("Failed to make krb5.conf", e); adminClient = new AdminClient(adminConfig); File keytabFile = new File(adminConfig.getKeyTabFile()); if (keytabFile == null || !keytabFile.exists()) { System.err.println("Need the valid keytab file value in conf file."); String adminRealm = adminConfig.getAdminRealm(); adminClient.setAdminRealm(adminRealm); adminClient.setAllowTcp(true); adminClient.setAllowUdp(false); adminClient.setAdminTcpPort(adminConfig.getAdminPort()); adminClient.init(); System.out.println("admin init successful"); tpair = AdminUtil.getTransportPair(adminClient.getSetting()); } catch (KrbException e) { LOG.error("Fail to get transport pair. " + e); network.setSocketTimeout(adminClient.getSetting().getTimeout());
AdminServer adminServer = new AdminServer(new File(confDirPath)); AdminServerConfig adminServerConfig = adminServer.getAdminServerConfig(); adminServer.setAdminHost(adminServerConfig.getAdminHost()); adminServer.setAllowTcp(true); adminServer.setAllowUdp(false); adminServer.setAdminServerPort(adminServerConfig.getAdminPort()); Krb5Conf krb5Conf = new Krb5Conf(new File(confDirPath), kdcConfig); krb5Conf.initKrb5conf(); } catch (IOException e) { throw new KrbException("Failed to make krb5.conf", e); adminServer.init(); } catch (KrbException e) { System.err.println("Errors occurred when start admin server: " + e.getMessage()); System.exit(2); adminServer.start(); System.out.println("Admin server started!");
private void saslNegotiation() throws Exception { File keytabFile = new File(adminServerContext.getConfig().getKeyTabFile()); String principal = adminServerContext.getConfig().getProtocol() + "/" + adminServerContext.getConfig().getAdminHost(); Subject subject = AuthUtil.loginUsingKeytab(principal, keytabFile); Subject.doAs(subject, new PrivilegedAction<Object>() { @Override
public static Subject loginUsingKeytab( String principal, File keytabFile) throws LoginException { Set<Principal> principals = new HashSet<>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useKeytab(principal, keytabFile); String confName = "KeytabConf"; LoginContext loginContext = new LoginContext(confName, subject, null, conf); loginContext.login(); return loginContext.getSubject(); }
public static Subject loginUsingTicketCache( String principal, File cacheFile) throws LoginException { Set<Principal> principals = new HashSet<>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useTicketCache(principal, cacheFile); String confName = "TicketCacheConf"; LoginContext loginContext = new LoginContext(confName, subject, null, conf); loginContext.login(); return loginContext.getSubject(); }
final AdminConfig adminConfig = new AdminConfig(); adminConfig.addKrb5Config(confFile); Krb5Conf krb5Conf = new Krb5Conf(new File(confDirPath), tmpKdcConfig); krb5Conf.initKrb5conf(); } catch (IOException e) { throw new KrbException("Failed to make krb5.conf", e); adminClient = new AdminClient(adminConfig); File keytabFile = new File(adminConfig.getKeyTabFile()); if (keytabFile == null || !keytabFile.exists()) { System.err.println("Need the valid keytab file value in conf file."); String adminRealm = adminConfig.getAdminRealm(); adminClient.setAdminRealm(adminRealm); adminClient.setAllowTcp(true); adminClient.setAllowUdp(false); adminClient.setAdminTcpPort(adminConfig.getAdminPort()); adminClient.init(); System.out.println("admin init successful"); tpair = AdminUtil.getTransportPair(adminClient.getSetting()); } catch (KrbException e) { LOG.error("Fail to get transport pair. " + e); network.setSocketTimeout(adminClient.getSetting().getTimeout());
AdminServer adminServer = new AdminServer(new File(confDirPath)); AdminServerConfig adminServerConfig = adminServer.getAdminServerConfig(); adminServer.setAdminHost(adminServerConfig.getAdminHost()); adminServer.setAllowTcp(true); adminServer.setAllowUdp(false); adminServer.setAdminServerPort(adminServerConfig.getAdminPort()); Krb5Conf krb5Conf = new Krb5Conf(new File(confDirPath), kdcConfig); krb5Conf.initKrb5conf(); } catch (IOException e) { throw new KrbException("Failed to make krb5.conf", e); adminServer.init(); } catch (KrbException e) { System.err.println("Errors occurred when start admin server: " + e.getMessage()); System.exit(2); adminServer.start(); System.out.println("Admin server started!");
private void saslNegotiation() throws Exception { File keytabFile = new File(adminServerContext.getConfig().getKeyTabFile()); String principal = adminServerContext.getConfig().getProtocol() + "/" + adminServerContext.getConfig().getAdminHost(); Subject subject = AuthUtil.loginUsingKeytab(principal, keytabFile); Subject.doAs(subject, new PrivilegedAction<Object>() { @Override
public static Configuration useTicketCache(String principal, File credentialFile) { return new TicketCacheJaasConf(principal, credentialFile); }
public static Configuration useKeytab(String principal, File keytabFile) { return new KeytabJaasConf(principal, keytabFile); }
public void initKrb5conf() throws IOException { File confFile = generateConfFile(); System.setProperty(KRB5_CONF, confFile.getAbsolutePath()); }
public static Subject loginUsingKeytab( String principal, File keytabFile) throws LoginException { Set<Principal> principals = new HashSet<>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useKeytab(principal, keytabFile); String confName = "KeytabConf"; LoginContext loginContext = new LoginContext(confName, subject, null, conf); loginContext.login(); return loginContext.getSubject(); }
public static Subject loginUsingTicketCache( String principal, File cacheFile) throws LoginException { Set<Principal> principals = new HashSet<>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useTicketCache(principal, cacheFile); String confName = "TicketCacheConf"; LoginContext loginContext = new LoginContext(confName, subject, null, conf); loginContext.login(); return loginContext.getSubject(); }