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()) {
|
if (kdcEncryptionTypes == null || kdcEncryptionTypes.isEmpty()) {
|
||||||
kdcEncryptionTypes = DEFAULT_KDC_ENCRYPTION_TYPES;
|
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;
|
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);
|
return new KerberosEmbeddedServer(baseDN, bindHost, bindPort, ldifFile, ldapSaslPrincipal, kerberosRealm, kdcPort, kdcEncryptionTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,9 @@ public class LDAPEmbeddedServer {
|
||||||
private void importLdif() throws Exception {
|
private void importLdif() throws Exception {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("hostname", this.bindHost);
|
map.put("hostname", this.bindHost);
|
||||||
|
if (this.ldapSaslPrincipal != null) {
|
||||||
map.put("ldapSaslPrincipal", this.ldapSaslPrincipal);
|
map.put("ldapSaslPrincipal", this.ldapSaslPrincipal);
|
||||||
|
}
|
||||||
|
|
||||||
// For now, assume that LDIF file is on classpath
|
// For now, assume that LDIF file is on classpath
|
||||||
InputStream is = getClass().getClassLoader().getResourceAsStream(ldifFile);
|
InputStream is = getClass().getClassLoader().getResourceAsStream(ldifFile);
|
||||||
|
|
Loading…
Reference in a new issue