本文整理了Java中org.apache.directory.server.kerberos.shared.keytab.Keytab.getInstance()
方法的一些代码示例,展示了Keytab.getInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keytab.getInstance()
方法的具体详情如下:
包路径:org.apache.directory.server.kerberos.shared.keytab.Keytab
类名称:Keytab
方法名:getInstance
暂无
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
/**
* Creates a keytab file for authenticating with a given principal.
*
* @param user Username to login with (i.e. cassandra).
* @param password Password to authenticate with.
* @param principal Principal representing the server (i.e. cassandra@DATASTAX.COM).
* @return Generated keytab file for this user.
*/
public File createKeytab(String user, String password, String principal) throws IOException {
File keytabFile = new File(confDir, user + ".keytab");
Keytab keytab = Keytab.getInstance();
KerberosTime timeStamp = new KerberosTime(System.currentTimeMillis());
Map<EncryptionType, EncryptionKey> keys =
KerberosKeyFactory.getKerberosKeys(principal, password);
KeytabEntry keytabEntry =
new KeytabEntry(
principal, 0, timeStamp, (byte) 0, keys.get(EncryptionType.AES128_CTS_HMAC_SHA1_96));
keytab.setEntries(Collections.singletonList(keytabEntry));
keytab.write(keytabFile);
return keytabFile;
}
代码示例来源:origin: hortonworks/registry
private void createKeyTab(String fileName, String[] principalNames)
throws IOException {
//create a test keytab file
List<KeytabEntry> lstEntries = new ArrayList<KeytabEntry>();
for (String principal : principalNames) {
// create 3 versions of the key to ensure methods don't return
// duplicate principals
for (int kvno = 1; kvno <= 3; kvno++) {
EncryptionKey key = new EncryptionKey(
EncryptionType.UNKNOWN, "samplekey1".getBytes(), kvno);
KeytabEntry keytabEntry = new KeytabEntry(
principal, 1, new KerberosTime(), (byte) 1, key);
lstEntries.add(keytabEntry);
}
}
Keytab keytab = Keytab.getInstance();
keytab.setEntries(lstEntries);
keytab.write(new File(testKeytab));
}
}
代码示例来源:origin: io.hops/hadoop-auth
private void createKeyTab(String fileName, String[] principalNames)
throws IOException {
//create a test keytab file
List<KeytabEntry> lstEntries = new ArrayList<KeytabEntry>();
for (String principal : principalNames){
// create 3 versions of the key to ensure methods don't return
// duplicate principals
for (int kvno=1; kvno <= 3; kvno++) {
EncryptionKey key = new EncryptionKey(
EncryptionType.UNKNOWN, "samplekey1".getBytes(), kvno);
KeytabEntry keytabEntry = new KeytabEntry(
principal, 1 , new KerberosTime(), (byte) 1, key);
lstEntries.add(keytabEntry);
}
}
Keytab keytab = Keytab.getInstance();
keytab.setEntries(lstEntries);
keytab.write(new File(testKeytab));
}
}
代码示例来源:origin: apache/hadoop-common
private void createKeyTab(String fileName, String[] principalNames)
throws IOException {
//create a test keytab file
List<KeytabEntry> lstEntries = new ArrayList<KeytabEntry>();
for (String principal : principalNames){
// create 3 versions of the key to ensure methods don't return
// duplicate principals
for (int kvno=1; kvno <= 3; kvno++) {
EncryptionKey key = new EncryptionKey(
EncryptionType.UNKNOWN, "samplekey1".getBytes(), kvno);
KeytabEntry keytabEntry = new KeytabEntry(
principal, 1 , new KerberosTime(), (byte) 1, key);
lstEntries.add(keytabEntry);
}
}
Keytab keytab = Keytab.getInstance();
keytab.setEntries(lstEntries);
keytab.write(new File(testKeytab));
}
}
代码示例来源:origin: hopshadoop/hops
private void createKeyTab(String fileName, String[] principalNames)
throws IOException {
//create a test keytab file
List<KeytabEntry> lstEntries = new ArrayList<KeytabEntry>();
for (String principal : principalNames){
// create 3 versions of the key to ensure methods don't return
// duplicate principals
for (int kvno=1; kvno <= 3; kvno++) {
EncryptionKey key = new EncryptionKey(
EncryptionType.UNKNOWN, "samplekey1".getBytes(), kvno);
KeytabEntry keytabEntry = new KeytabEntry(
principal, 1 , new KerberosTime(), (byte) 1, key);
lstEntries.add(keytabEntry);
}
}
Keytab keytab = Keytab.getInstance();
keytab.setEntries(lstEntries);
keytab.write(new File(testKeytab));
}
}
内容来源于网络,如有侵权,请联系作者删除!