org.apache.hadoop.minikdc
Class MiniKdc

java.lang.Object
  extended by org.apache.hadoop.minikdc.MiniKdc

public class MiniKdc
extends 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:

The generated krb5.conf forces TCP connections.


Field Summary
static String DEBUG
           
static String INSTANCE
           
static String KDC_BIND_ADDRESS
           
static String KDC_PORT
           
static String MAX_RENEWABLE_LIFETIME
           
static String MAX_TICKET_LIFETIME
           
static String ORG_DOMAIN
           
static String ORG_NAME
           
static String TRANSPORT
           
 
Constructor Summary
MiniKdc(Properties conf, File workDir)
          Creates a MiniKdc.
 
Method Summary
static Properties createConf()
          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.
 String getHost()
          Returns the host of the MiniKdc.
 File getKrb5conf()
           
 int getPort()
          Returns the port of the MiniKdc.
 String getRealm()
          Returns the realm of the MiniKdc.
static void main(String[] args)
           
 void start()
          Starts the MiniKdc.
 void stop()
          Stops the MiniKdc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORG_NAME

public static final String ORG_NAME
See Also:
Constant Field Values

ORG_DOMAIN

public static final String ORG_DOMAIN
See Also:
Constant Field Values

KDC_BIND_ADDRESS

public static final String KDC_BIND_ADDRESS
See Also:
Constant Field Values

KDC_PORT

public static final String KDC_PORT
See Also:
Constant Field Values

INSTANCE

public static final String INSTANCE
See Also:
Constant Field Values

MAX_TICKET_LIFETIME

public static final String MAX_TICKET_LIFETIME
See Also:
Constant Field Values

MAX_RENEWABLE_LIFETIME

public static final String MAX_RENEWABLE_LIFETIME
See Also:
Constant Field Values

TRANSPORT

public static final String TRANSPORT
See Also:
Constant Field Values

DEBUG

public static final String DEBUG
See Also:
Constant Field Values
Constructor Detail

MiniKdc

public MiniKdc(Properties conf,
               File workDir)
        throws Exception
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 Detail

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

createConf

public static 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.

Returns:
a MiniKdc default configuration.

getPort

public int getPort()
Returns the port of the MiniKdc.

Returns:
the port of the MiniKdc.

getHost

public String getHost()
Returns the host of the MiniKdc.

Returns:
the host of the MiniKdc.

getRealm

public String getRealm()
Returns the realm of the MiniKdc.

Returns:
the realm of the MiniKdc.

getKrb5conf

public File getKrb5conf()

start

public void start()
           throws Exception
Starts the MiniKdc.

Throws:
Exception - thrown if the MiniKdc could not be started.

stop

public void stop()
Stops the MiniKdc

Throws:
Exception

createPrincipal

public void createPrincipal(String principal,
                            String password)
                     throws Exception
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

public void createPrincipal(File keytabFile,
                            String... principals)
                     throws Exception
Creates multiple principals in the KDC and adds them to a keytab file.

Parameters:
keytabFile - keytab file to add the created principal.s
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.


Copyright © 2014 Apache Software Foundation. All Rights Reserved.