Class MiniKdc
java.lang.Object
org.springframework.security.kerberos.test.MiniKdc
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 one System property when started and un-set when stopped:
- sun.security.krb5.debug: set to the debug value provided in the configuration
MiniKdc default configuration values are:
- org.name=EXAMPLE (used to create the REALM)
- org.domain=COM (used to create the REALM)
- kdc.bind.address=localhost
- kdc.port=0 (ephemeral port)
- instance=DefaultKrbServer
- max.ticket.lifetime=86400000 (1 day)
- max.renewable.lifetime=604800000 (7 days)
- transport=TCP
- debug=false
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Properties
Convenience method that returns MiniKdc default configuration.void
createPrincipal
(File keytabFile, String... principals) Creates multiple principals in the KDC and adds them to a keytab file.void
createPrincipal
(String principal, String password) Creates a principal in the KDC with the specified user and password.getHost()
Returns the host of the MiniKdc.int
getPort()
Returns the port of the MiniKdc.getRealm()
Returns the realm of the MiniKdc.static void
void
setTransport
(String transport) void
start()
Starts the MiniKdc.void
stop()
Stops the MiniKdc
-
Field Details
-
JAVA_SECURITY_KRB5_CONF
- See Also:
-
SUN_SECURITY_KRB5_DEBUG
- See Also:
-
ORG_NAME
- See Also:
-
ORG_DOMAIN
- See Also:
-
KDC_BIND_ADDRESS
- See Also:
-
KDC_PORT
- See Also:
-
INSTANCE
- See Also:
-
MAX_TICKET_LIFETIME
- See Also:
-
MIN_TICKET_LIFETIME
- See Also:
-
MAX_RENEWABLE_LIFETIME
- See Also:
-
TRANSPORT
- See Also:
-
DEBUG
- See Also:
-
-
Constructor Details
-
MiniKdc
Creates a MiniKdc.- Parameters:
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.- Throws:
Exception
- thrown if the MiniKdc could not be created.
-
-
Method Details
-
main
- Throws:
Exception
-
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.
- Returns:
- a MiniKdc default configuration.
-
setTransport
-
getPort
public int getPort()Returns the port of the MiniKdc.- Returns:
- the port of the MiniKdc.
-
getHost
Returns the host of the MiniKdc.- Returns:
- the host of the MiniKdc.
-
getRealm
Returns the realm of the MiniKdc.- Returns:
- the realm of the MiniKdc.
-
getKrb5conf
-
start
Starts the MiniKdc.- Throws:
Exception
- thrown if the MiniKdc could not be started.
-
stop
public void stop()Stops the MiniKdc -
createPrincipal
Creates a principal in the KDC with the specified user and password.- Parameters:
principal
- principal name, do not include the domain.password
- password.- Throws:
Exception
- thrown if the principal could not be created.
-
createPrincipal
Creates multiple principals in the KDC and adds them to a keytab file.- Parameters:
keytabFile
- keytab file to add the created principals.principals
- principals to add to the KDC, do not include the domain.- Throws:
Exception
- thrown if the principals or the keytab file could not be created.
-