org.apache.kerby.kerberos.kerb.keytab.Keytab.getPrincipals()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.apache.kerby.kerberos.kerb.keytab.Keytab.getPrincipals()方法的一些代码示例,展示了Keytab.getPrincipals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keytab.getPrincipals()方法的具体详情如下:
包路径:org.apache.kerby.kerberos.kerb.keytab.Keytab
类名称:Keytab
方法名:getPrincipals

Keytab.getPrincipals介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

@Test(timeout = 60000)
public void testKeytabGen() throws Exception {
  MiniKdc kdc = getKdc();
  File workDir = getWorkDir();
  kdc.createPrincipal(new File(workDir, "keytab"), "foo/bar", "bar/foo");
  List<PrincipalName> principalNameList =
      Keytab.loadKeytab(new File(workDir, "keytab")).getPrincipals();
  Set<String> principals = new HashSet<String>();
  for (PrincipalName principalName : principalNameList) {
   principals.add(principalName.getName());
  }
  Assert.assertEquals(new HashSet<String>(Arrays.asList(
      "foo/bar@" + kdc.getRealm(), "bar/foo@" + kdc.getRealm())),
      principals);
 }

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Dump a keytab: list all principals.
 *
 * @param keytabFile the keytab file
 * @throws IOException IO problems
 */
private void dumpKeytab(File keytabFile) throws IOException {
 title("Examining keytab %s", keytabFile);
 File kt = keytabFile.getCanonicalFile();
 verifyFileIsValid(kt, CAT_KERBEROS, "keytab");
 Keytab loadKeytab = Keytab.loadKeytab(kt);
 List<PrincipalName> principals = loadKeytab.getPrincipals();
 println("keytab principal count: %d", principals.size());
 int entrySize = 0;
 for (PrincipalName princ : principals) {
  List<KeytabEntry> entries = loadKeytab.getKeytabEntries(princ);
  entrySize = entrySize + entries.size();
  for (KeytabEntry entry : entries) {
   EncryptionKey key = entry.getKey();
   println(" %s: version=%d expires=%s encryption=%s",
       entry.getPrincipal(),
       entry.getKvno(),
       entry.getTimestamp(),
       key.getKeyType());
  }
 }
 println("keytab entry count: %d", entrySize);
 endln();
}

代码示例来源:origin: org.apache.hadoop/hadoop-auth

/**
 * Get all the unique principals present in the keytabfile.
 * 
 * @param keytabFileName 
 *          Name of the keytab file to be read.
 * @return list of unique principals in the keytab.
 * @throws IOException 
 *          If keytab entries cannot be read from the file.
 */
static final String[] getPrincipalNames(String keytabFileName) throws IOException {
 Keytab keytab = Keytab.loadKeytab(new File(keytabFileName));
 Set<String> principals = new HashSet<String>();
 List<PrincipalName> entries = keytab.getPrincipals();
 for (PrincipalName entry : entries) {
  principals.add(entry.getName().replace("\\", "/"));
 }
 return principals.toArray(new String[0]);
}

代码示例来源:origin: apache/directory-kerby

/**
 * Get all the unique principals present in the keytabfile.
 * 
 * @param keytabFileName 
 *          Name of the keytab file to be read.
 * @return list of unique principals in the keytab.
 * @throws IOException
 *          If keytab entries cannot be read from the file.
 */
static final String[] getPrincipalNames(String keytabFileName) throws IOException {
 Keytab keytab = Keytab.loadKeytab(new File(keytabFileName));
 Set<String> principals = new HashSet<>();
 List<PrincipalName> entries = keytab.getPrincipals();
 for (PrincipalName entry : entries) {
  principals.add(entry.getName().replace("\\", "/"));
 }
 return principals.toArray(new String[0]);
}

代码示例来源:origin: org.apache.kerby/client-tool

SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Keytab keytab = Keytab.loadKeytab(keytabFile);
List<PrincipalName> principals = keytab.getPrincipals();
for (PrincipalName principal : principals) {
  List<KeytabEntry> keytabEntries = keytab.getKeytabEntries(principal);

代码示例来源:origin: apache/directory-kerby

SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Keytab keytab = Keytab.loadKeytab(keytabFile);
List<PrincipalName> principals = keytab.getPrincipals();
for (PrincipalName principal : principals) {
  List<KeytabEntry> keytabEntries = keytab.getKeytabEntries(principal);

相关文章