public class LdifAnonymizer
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,Anonymizer> |
attributeAnonymizers
The map of AttributeType'sOID we want to anonymize.
|
private java.util.Set<Dn> |
namingContexts
The list of existing NamingContexts
|
private java.io.PrintStream |
out
The PrintStream used to write informations about the processing
|
private SchemaManager |
schemaManager
The schemaManager
|
private java.util.Map<Value<?>,Value<?>> |
valueMap
The map that stores the anonymized values associated to the original value
|
| Constructor and Description |
|---|
LdifAnonymizer()
Creates a default instance of LdifAnonymizer.
|
LdifAnonymizer(SchemaManager schemaManager)
Creates a default instance of LdifAnonymizer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAnonAttributeType(AttributeType attributeType)
Add an attributeType that has to be anonymized
|
void |
addAnonAttributeType(AttributeType attributeType,
Anonymizer<?> anonymizer)
Add an attributeType that has to be anonymized, with its associated anonymizer.
|
void |
addNamingContext(java.lang.String dn)
Add a new NamingContext
|
java.lang.String |
anonymize(java.lang.String ldif)
Anonymize a LDIF
|
private Ava |
anonymizeAva(Ava ava)
Anonymize an AVA
|
private LdifEntry |
anonymizeChangeAdd(LdifEntry ldifEntry)
Anonymize a Add change
|
private LdifEntry |
anonymizeChangeDelete(LdifEntry ldifEntry)
Anonymize a Delete change
|
private LdifEntry |
anonymizeChangeModDn(LdifEntry ldifEntry)
Anonymize a Delete change
|
private LdifEntry |
anonymizeChangeModify(LdifEntry ldifEntry)
Anonymize a Modify change
|
private Dn |
anonymizeDn(Dn entryDn)
Anonymize the entry's DN
|
private Entry |
anonymizeEntry(LdifEntry ldifEntry)
Anonymize the full entry
|
void |
anonymizeFile(java.lang.String ldifFile,
java.io.Writer writer)
Anonymize a LDIF
|
java.util.Map<java.lang.String,Anonymizer> |
getAttributeAnonymizers() |
java.util.Map<Value<?>,Value<?>> |
getValueMap() |
private void |
init()
Initialize the anonymizer, filling the maps we use.
|
static void |
main(java.lang.String[] args)
The entry point, when used as a standalone application.
|
private void |
print(java.lang.String str)
Print the string into the PrintStream
|
private void |
println()
Print a nl into the PrintStream
|
private void |
println(java.lang.String str)
Print the string into the PrintStream, with a NL at the end
|
void |
removeAnonAttributeType(AttributeType attributeType)
Remove an attributeType that has to be anonymized
|
void |
setOut(java.io.PrintStream out)
Set the PrintStream to use to print information about the processing
|
void |
setValueMap(java.util.Map<Value<?>,Value<?>> valueMap) |
private java.util.Map<Value<?>,Value<?>> valueMap
private java.util.Map<java.lang.String,Anonymizer> attributeAnonymizers
private java.util.Set<Dn> namingContexts
private SchemaManager schemaManager
private java.io.PrintStream out
public LdifAnonymizer()
public LdifAnonymizer(SchemaManager schemaManager)
schemaManager - The SchemaManager instance we will usepublic void setOut(java.io.PrintStream out)
out - The PrintStream to useprivate void print(java.lang.String str)
private void println(java.lang.String str)
private void println()
private void init()
public void addAnonAttributeType(AttributeType attributeType) throws LdapException
attributeType - the AttributeType that has to be anonymizedLdapException - If the attributeType cannot be addedpublic void addAnonAttributeType(AttributeType attributeType, Anonymizer<?> anonymizer) throws LdapException
attributeType - the AttributeType that has to be anonymizedanonymizer - the instance of anonymizer to use with this AttributeTypeLdapException - If the attributeType cannot be addedpublic void removeAnonAttributeType(AttributeType attributeType) throws LdapException
attributeType - the AttributeType that we don't want to be anonymizedLdapException - If the attributeType cannot be removedpublic java.util.Map<java.lang.String,Anonymizer> getAttributeAnonymizers()
public void addNamingContext(java.lang.String dn)
throws LdapInvalidDnException
dn - The naming context to addLdapInvalidDnException - if it's an invalid naming contextprivate Ava anonymizeAva(Ava ava) throws LdapInvalidDnException, LdapInvalidAttributeValueException
private Dn anonymizeDn(Dn entryDn) throws LdapException
LdapExceptionpublic void anonymizeFile(java.lang.String ldifFile,
java.io.Writer writer)
throws LdapException,
java.io.IOException
ldif - The ldif content to anonymizeLdapException - If we got some LDAP related exceptionjava.io.IOException - If we had some issue during some IO operationsprivate LdifEntry anonymizeChangeModify(LdifEntry ldifEntry) throws LdapException
LdapExceptionprivate LdifEntry anonymizeChangeAdd(LdifEntry ldifEntry) throws LdapException
LdapExceptionprivate LdifEntry anonymizeChangeDelete(LdifEntry ldifEntry) throws LdapException
LdapExceptionprivate LdifEntry anonymizeChangeModDn(LdifEntry ldifEntry) throws LdapException
LdapExceptionprivate Entry anonymizeEntry(LdifEntry ldifEntry) throws LdapException
LdapExceptionpublic java.lang.String anonymize(java.lang.String ldif)
throws LdapException,
java.io.IOException
ldif - The ldif content to anonymizeLdapException - If we got some LDAP related exceptionjava.io.IOException - If we had some issue during some IO operationspublic void setValueMap(java.util.Map<Value<?>,Value<?>> valueMap)
valueMap - the valueMap to setpublic static void main(java.lang.String[] args)
throws java.io.IOException,
LdapException
args - Contains the arguments : the file to convert. The anonymized
LDIF will be printed on stdoutjava.io.IOExceptionLdapException