com.sun.slamd.scripting.ldap
Class LDAPEntryGenerator

java.lang.Object
  extended bycom.sun.slamd.scripting.ldap.LDAPEntryGenerator

public class LDAPEntryGenerator
extends java.lang.Object

This class handles the work of generating LDAP entries based on information in a template file. The template files may contain various kinds of tokens that allow the entries generated to be highly customizeable. The tokens that are supported are:


Field Summary
static char[] ALPHA_CHARS
          The set of characters that should be included in alphabetic values.
static char[] ALPHANUMERIC_CHARS
          The set of characters that should be included in alphanumeric values.
static char[] BASE64_CHARS
          The set of characters that should be included in base64 values.
static java.lang.String EOL
          The end of line character that should be used on the current platform.
static char[] HEX_CHARS
          The set of characters that should be included in hexadecimal values.
static char[] NUMERIC_CHARS
          The set of characters that should be included in numeric values.
 
Constructor Summary
LDAPEntryGenerator()
          Creates a new instance of the LDIF generator that parses the command-line parameters and coordinates the LDIF creation.
 
Method Summary
 void addTemplate(LDAPEntryTemplate template)
          Adds the specified entry template for use with this entry generator.
 LDAPEntryVariable createTemplateEntry(java.lang.String parentDN, java.lang.String templateName)
          Creates a subordinate entry for the specified branch.
 java.lang.String generateGUID()
          Generates a globally-unique identifier.
 java.lang.String generateRandomValue(char[] charSet, int length)
          Generates a random value of the indicated length from the specified character set.
 void parseTemplateFile(java.lang.String[] templateFileLines)
          Reads the template file and extracts the branch and template definitions from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

public static final java.lang.String EOL
The end of line character that should be used on the current platform.


NUMERIC_CHARS

public static final char[] NUMERIC_CHARS
The set of characters that should be included in numeric values.


ALPHA_CHARS

public static final char[] ALPHA_CHARS
The set of characters that should be included in alphabetic values.


ALPHANUMERIC_CHARS

public static final char[] ALPHANUMERIC_CHARS
The set of characters that should be included in alphanumeric values.


HEX_CHARS

public static final char[] HEX_CHARS
The set of characters that should be included in hexadecimal values.


BASE64_CHARS

public static final char[] BASE64_CHARS
The set of characters that should be included in base64 values.

Constructor Detail

LDAPEntryGenerator

public LDAPEntryGenerator()
Creates a new instance of the LDIF generator that parses the command-line parameters and coordinates the LDIF creation.

Method Detail

addTemplate

public void addTemplate(LDAPEntryTemplate template)
Adds the specified entry template for use with this entry generator.

Parameters:
template - The template to use for this entry generator.

parseTemplateFile

public void parseTemplateFile(java.lang.String[] templateFileLines)
Reads the template file and extracts the branch and template definitions from it.

Parameters:
templateFileLines - The lines from the template file that will be used for the template generation.

createTemplateEntry

public LDAPEntryVariable createTemplateEntry(java.lang.String parentDN,
                                             java.lang.String templateName)
Creates a subordinate entry for the specified branch. Any translation that needs to be done on the attribute values will be taken care of here.

Parameters:
parentDN - The DN under which to create the entry.
templateName - The name of the template to use to generate the entry.
Returns:
The LDAP entry that was created, or a null entry if a problem occurred.

generateRandomValue

public java.lang.String generateRandomValue(char[] charSet,
                                            int length)
Generates a random value of the indicated length from the specified character set.

Parameters:
charSet - The character set from which the random characters are to be taken.
length - The length of the random value to generate.
Returns:
The random value that was generated.

generateGUID

public java.lang.String generateGUID()
Generates a globally-unique identifier. Technically speaking, it's not guaranteed to be globally unique, but this should be good enough for most purposes.

Returns:
The GUID that was generated.