public class MiniKdc
extends java.lang.Object
Mini KDC based on Apache Directory Server that can be embedded in testcases or used from command line as a standalone KDC.
From within testcases:MiniKdc sets 2 System properties when started and un-sets them when stopped:
Because of this, multiple MiniKdc instances cannot be started in parallel. For example, running testcases in parallel that start a KDC each. To accomplish this a single MiniKdc should be used for all testcases running in parallel.
MiniKdc default configuration values are:Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEBUG |
static java.lang.String |
INSTANCE |
static java.lang.String |
KDC_BIND_ADDRESS |
static java.lang.String |
KDC_PORT |
static java.lang.String |
MAX_RENEWABLE_LIFETIME |
static java.lang.String |
MAX_TICKET_LIFETIME |
static java.lang.String |
ORG_DOMAIN |
static java.lang.String |
ORG_NAME |
static java.lang.String |
TRANSPORT |
Constructor and Description |
---|
MiniKdc(java.util.Properties conf,
java.io.File workDir)
Creates a MiniKdc.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Properties |
createConf()
Convenience method that returns MiniKdc default configuration.
|
void |
createPrincipal(java.io.File keytabFile,
java.lang.String... principals)
Creates multiple principals in the KDC and adds them to a keytab file.
|
void |
createPrincipal(java.lang.String principal,
java.lang.String password)
Creates a principal in the KDC with the specified user and password.
|
java.lang.String |
getHost()
Returns the host of the MiniKdc.
|
java.io.File |
getKrb5conf() |
int |
getPort()
Returns the port of the MiniKdc.
|
java.lang.String |
getRealm()
Returns the realm of the MiniKdc.
|
static void |
main(java.lang.String[] args) |
void |
start()
Starts the MiniKdc.
|
void |
stop()
Stops the MiniKdc
|
public static final java.lang.String ORG_NAME
public static final java.lang.String ORG_DOMAIN
public static final java.lang.String KDC_BIND_ADDRESS
public static final java.lang.String KDC_PORT
public static final java.lang.String INSTANCE
public static final java.lang.String MAX_TICKET_LIFETIME
public static final java.lang.String MAX_RENEWABLE_LIFETIME
public static final java.lang.String TRANSPORT
public static final java.lang.String DEBUG
public MiniKdc(java.util.Properties conf, java.io.File workDir) throws java.lang.Exception
conf
- MiniKdc configuration.workDir
- working directory, it should be the build directory. Under
this directory an ApacheDS working directory will be created,
this directory will be deleted when the MiniKdc stops.java.lang.Exception
- thrown if the MiniKdc could not be created.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public static java.util.Properties createConf()
Convenience method that returns MiniKdc default configuration.
The returned configuration is a copy, it can be customized before using it to create a MiniKdc.
public int getPort()
public java.lang.String getHost()
public java.lang.String getRealm()
public java.io.File getKrb5conf()
public void start() throws java.lang.Exception
java.lang.Exception
- thrown if the MiniKdc could not be started.public void stop()
public void createPrincipal(java.lang.String principal, java.lang.String password) throws java.lang.Exception
principal
- principal name, do not include the domain.password
- password.java.lang.Exception
- thrown if the principal could not be created.public void createPrincipal(java.io.File keytabFile, java.lang.String... principals) throws java.lang.Exception
keytabFile
- keytab file to add the created principal.sprincipals
- principals to add to the KDC, do not include the domain.java.lang.Exception
- thrown if the principals or the keytab file could not be created.