Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDAP testing improvements. Support for embedded Kerberos server in te…
…stsuite
- Loading branch information
Showing
18 changed files
with
976 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
testsuite/integration/src/main/java/org/keycloak/testutils/ldap/EmbeddedServersFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.keycloak.testutils.ldap; | ||
|
||
/** | ||
* Factory for ApacheDS based LDAP and Kerberos servers | ||
* | ||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | ||
*/ | ||
public class EmbeddedServersFactory { | ||
|
||
private static final String DEFAULT_BASE_DN = "dc=keycloak,dc=org"; | ||
private static final String DEFAULT_BIND_HOST = "localhost"; | ||
private static final int DEFAULT_BIND_PORT = 10389; | ||
private static final String DEFAULT_LDIF_FILE = "ldap/users.ldif"; | ||
|
||
private static final String DEFAULT_KERBEROS_LDIF_FILE = "kerberos/users-kerberos.ldif"; | ||
|
||
private static final String DEFAULT_KERBEROS_REALM = "KEYCLOAK.ORG"; | ||
private static final int DEFAULT_KDC_PORT = 6088; | ||
|
||
private String baseDN; | ||
private String bindHost; | ||
private int bindPort; | ||
private String ldifFile; | ||
private String kerberosRealm; | ||
private int kdcPort; | ||
|
||
|
||
public static EmbeddedServersFactory readConfiguration() { | ||
EmbeddedServersFactory factory = new EmbeddedServersFactory(); | ||
factory.readProperties(); | ||
return factory; | ||
} | ||
|
||
|
||
protected void readProperties() { | ||
this.baseDN = System.getProperty("ldap.baseDN"); | ||
this.bindHost = System.getProperty("ldap.host"); | ||
String bindPort = System.getProperty("ldap.port"); | ||
this.ldifFile = System.getProperty("ldap.ldif"); | ||
|
||
this.kerberosRealm = System.getProperty("kerberos.realm"); | ||
String kdcPort = System.getProperty("kerberos.port"); | ||
|
||
if (baseDN == null || baseDN.isEmpty()) { | ||
baseDN = DEFAULT_BASE_DN; | ||
} | ||
if (bindHost == null || bindHost.isEmpty()) { | ||
bindHost = DEFAULT_BIND_HOST; | ||
} | ||
this.bindPort = (bindPort == null || bindPort.isEmpty()) ? DEFAULT_BIND_PORT : Integer.parseInt(bindPort); | ||
if (ldifFile == null || ldifFile.isEmpty()) { | ||
ldifFile = DEFAULT_LDIF_FILE; | ||
} | ||
|
||
if (kerberosRealm == null || kerberosRealm.isEmpty()) { | ||
kerberosRealm = DEFAULT_KERBEROS_REALM; | ||
} | ||
this.kdcPort = (kdcPort == null || kdcPort.isEmpty()) ? DEFAULT_KDC_PORT : Integer.parseInt(kdcPort); | ||
} | ||
|
||
|
||
public LDAPEmbeddedServer createLdapServer() { | ||
|
||
// Override LDIF file with default for embedded LDAP | ||
if (ldifFile.equals(DEFAULT_KERBEROS_LDIF_FILE)) { | ||
ldifFile = DEFAULT_LDIF_FILE; | ||
} | ||
|
||
return new LDAPEmbeddedServer(baseDN, bindHost, bindPort, ldifFile); | ||
} | ||
|
||
|
||
public KerberosEmbeddedServer createKerberosServer() { | ||
|
||
// Override LDIF file with default for embedded Kerberos | ||
if (ldifFile.equals(DEFAULT_LDIF_FILE)) { | ||
ldifFile = DEFAULT_KERBEROS_LDIF_FILE; | ||
} | ||
|
||
return new KerberosEmbeddedServer(baseDN, bindHost, bindPort, ldifFile, kerberosRealm, kdcPort); | ||
} | ||
} |
Oops, something went wrong.