Fix Kerberos tests on windows - another attempt
This commit is contained in:
parent
5fe0c38498
commit
a3c3a837ad
2 changed files with 16 additions and 13 deletions
|
@ -74,18 +74,6 @@ public class EmbeddedServersFactory {
|
|||
if (kdcEncryptionTypes == null || kdcEncryptionTypes.isEmpty()) {
|
||||
kdcEncryptionTypes = DEFAULT_KDC_ENCRYPTION_TYPES;
|
||||
}
|
||||
|
||||
if (ldapSaslPrincipal == null || ldapSaslPrincipal.isEmpty()) {
|
||||
try {
|
||||
// Same algorithm like sun.security.krb5.PrincipalName constructor
|
||||
GSSName gssName = GSSManager.getInstance().createName("ldap@localhost", GSSName.NT_HOSTBASED_SERVICE);
|
||||
GSSNameImpl gssName1 = (GSSNameImpl) gssName;
|
||||
Krb5NameElement krb5NameElement = (Krb5NameElement) gssName1.getElement(KerberosSerializationUtils.KRB5_OID);
|
||||
this.ldapSaslPrincipal = krb5NameElement.getKrb5PrincipalName().toString();
|
||||
} catch (GSSException uhe) {
|
||||
throw new RuntimeException(uhe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,6 +95,19 @@ public class EmbeddedServersFactory {
|
|||
ldifFile = DEFAULT_KERBEROS_LDIF_FILE;
|
||||
}
|
||||
|
||||
// Init ldap sasl principal just when creating kerberos server
|
||||
if (ldapSaslPrincipal == null || ldapSaslPrincipal.isEmpty()) {
|
||||
try {
|
||||
// Same algorithm like sun.security.krb5.PrincipalName constructor
|
||||
GSSName gssName = GSSManager.getInstance().createName("ldap@" + bindHost, GSSName.NT_HOSTBASED_SERVICE);
|
||||
GSSNameImpl gssName1 = (GSSNameImpl) gssName;
|
||||
Krb5NameElement krb5NameElement = (Krb5NameElement) gssName1.getElement(KerberosSerializationUtils.KRB5_OID);
|
||||
this.ldapSaslPrincipal = krb5NameElement.getKrb5PrincipalName().toString();
|
||||
} catch (GSSException uhe) {
|
||||
throw new RuntimeException(uhe);
|
||||
}
|
||||
}
|
||||
|
||||
return new KerberosEmbeddedServer(baseDN, bindHost, bindPort, ldifFile, ldapSaslPrincipal, kerberosRealm, kdcPort, kdcEncryptionTypes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,9 @@ public class LDAPEmbeddedServer {
|
|||
private void importLdif() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("hostname", this.bindHost);
|
||||
map.put("ldapSaslPrincipal", this.ldapSaslPrincipal);
|
||||
if (this.ldapSaslPrincipal != null) {
|
||||
map.put("ldapSaslPrincipal", this.ldapSaslPrincipal);
|
||||
}
|
||||
|
||||
// For now, assume that LDIF file is on classpath
|
||||
InputStream is = getClass().getClassLoader().getResourceAsStream(ldifFile);
|
||||
|
|
Loading…
Reference in a new issue