public class LdifAnonymizer extends Object
| Modifier and Type | Field and Description |
|---|---|
private Map<String,org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer> |
attributeAnonymizers
The map of AttributeType'sOID we want to anonymize.
|
private Map<Integer,byte[]> |
latestBytesMap
The latest anonymized byte[] value Map
|
private Map<Integer,String> |
latestStringMap
The latest anonymized String value Map
|
private Set<org.apache.directory.api.ldap.model.name.Dn> |
namingContexts
The list of existing NamingContexts
|
private PrintStream |
out
The PrintStream used to write informations about the processing
|
private org.apache.directory.api.ldap.model.schema.SchemaManager |
schemaManager
The schemaManager
|
private Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> |
valueMap
The map that stores the anonymized values associated to the original value
|
private Set<org.apache.directory.api.ldap.model.entry.Value<?>> |
valueSet
The set that contains all the values we already have anonymized
|
| Constructor and Description |
|---|
LdifAnonymizer()
Creates a default instance of LdifAnonymizer.
|
LdifAnonymizer(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager)
Creates a default instance of LdifAnonymizer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType)
Add an attributeType that has to be anonymized
|
void |
addAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType,
org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer<?> anonymizer)
Add an attributeType that has to be anonymized, with its associated anonymizer.
|
void |
addNamingContext(String dn)
Add a new NamingContext
|
String |
anonymize(String ldif)
Anonymize a LDIF
|
private org.apache.directory.api.ldap.model.name.Ava |
anonymizeAva(org.apache.directory.api.ldap.model.name.Ava ava)
Anonymize an AVA
|
private org.apache.directory.api.ldap.model.ldif.LdifEntry |
anonymizeChangeAdd(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
Anonymize a Add change
|
private org.apache.directory.api.ldap.model.ldif.LdifEntry |
anonymizeChangeDelete(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
Anonymize a Delete change
|
private org.apache.directory.api.ldap.model.ldif.LdifEntry |
anonymizeChangeModDn(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
Anonymize a Delete change
|
private org.apache.directory.api.ldap.model.ldif.LdifEntry |
anonymizeChangeModify(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
Anonymize a Modify change
|
private org.apache.directory.api.ldap.model.name.Dn |
anonymizeDn(org.apache.directory.api.ldap.model.name.Dn entryDn)
Anonymize the entry's DN
|
private org.apache.directory.api.ldap.model.entry.Entry |
anonymizeEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
Anonymize the full entry
|
void |
anonymizeFile(String ldifFile,
Writer writer)
Anonymize a LDIF
|
Map<String,org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer> |
getAttributeAnonymizers() |
Map<Integer,byte[]> |
getLatestBytesMap() |
Map<Integer,String> |
getLatestStringMap() |
Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> |
getValueMap() |
private void |
init(Map<Integer,String> stringLatestValueMap,
Map<Integer,byte[]> binaryLatestValueMap,
Map<Integer,String> integerLatestValueMap,
Map<Integer,String> telephoneNumberLatestValueMap)
Initialize the anonymizer, filling the maps we use.
|
static void |
main(String[] args)
The entry point, when used as a standalone application.
|
private void |
print(String str)
Print the string into the PrintStream
|
private void |
println()
Print a nl into the PrintStream
|
private void |
println(String str)
Print the string into the PrintStream, with a NL at the end
|
void |
removeAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType)
Remove an attributeType that has to be anonymized
|
void |
setAttributeLatestValueMap(org.apache.directory.api.ldap.model.schema.AttributeType attributeType,
Map<Integer,?> latestValueMap)
Set the latest value map to a defined anonymizer - if it exists -.
|
void |
setLatestBytesMap(Map<Integer,byte[]> latestBytesMap) |
void |
setLatestStringMap(Map<Integer,String> latestStringMap) |
void |
setOut(PrintStream out)
Set the PrintStream to use to print information about the processing
|
void |
setValueMap(Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> valueMap) |
private Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> valueMap
private Set<org.apache.directory.api.ldap.model.entry.Value<?>> valueSet
private Map<String,org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer> attributeAnonymizers
private Set<org.apache.directory.api.ldap.model.name.Dn> namingContexts
private org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager
private PrintStream out
public LdifAnonymizer()
public LdifAnonymizer(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager)
schemaManager - The SchemaManager instance we will usepublic void setOut(PrintStream out)
out - The PrintStream to useprivate void print(String str)
private void println(String str)
private void println()
private void init(Map<Integer,String> stringLatestValueMap, Map<Integer,byte[]> binaryLatestValueMap, Map<Integer,String> integerLatestValueMap, Map<Integer,String> telephoneNumberLatestValueMap)
public void setAttributeLatestValueMap(org.apache.directory.api.ldap.model.schema.AttributeType attributeType,
Map<Integer,?> latestValueMap)
attributeType - The AttributeType we are targettinglatestValueMap - The latest value map for this attributepublic void addAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType)
throws org.apache.directory.api.ldap.model.exception.LdapException
attributeType - the AttributeType that has to be anonymizedorg.apache.directory.api.ldap.model.exception.LdapException - If the attributeType cannot be addedpublic void addAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType,
org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer<?> anonymizer)
throws org.apache.directory.api.ldap.model.exception.LdapException
attributeType - the AttributeType that has to be anonymizedanonymizer - the instance of anonymizer to use with this AttributeTypeorg.apache.directory.api.ldap.model.exception.LdapException - If the attributeType cannot be addedpublic void removeAnonAttributeType(org.apache.directory.api.ldap.model.schema.AttributeType attributeType)
throws org.apache.directory.api.ldap.model.exception.LdapException
attributeType - the AttributeType that we don't want to be anonymizedorg.apache.directory.api.ldap.model.exception.LdapException - If the attributeType cannot be removedpublic Map<String,org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer> getAttributeAnonymizers()
public void addNamingContext(String dn) throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException
dn - The naming context to addorg.apache.directory.api.ldap.model.exception.LdapInvalidDnException - if it's an invalid naming contextprivate org.apache.directory.api.ldap.model.name.Ava anonymizeAva(org.apache.directory.api.ldap.model.name.Ava ava)
throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException,
org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException
org.apache.directory.api.ldap.model.exception.LdapInvalidDnExceptionorg.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueExceptionprivate org.apache.directory.api.ldap.model.name.Dn anonymizeDn(org.apache.directory.api.ldap.model.name.Dn entryDn)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionpublic void anonymizeFile(String ldifFile, Writer writer) throws org.apache.directory.api.ldap.model.exception.LdapException, IOException
ldifFile - The ldif file to anonymizewriter - The Writer to use to write the resultorg.apache.directory.api.ldap.model.exception.LdapException - If we got some LDAP related exceptionIOException - If we had some issue during some IO operationsprivate org.apache.directory.api.ldap.model.ldif.LdifEntry anonymizeChangeModify(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionprivate org.apache.directory.api.ldap.model.ldif.LdifEntry anonymizeChangeAdd(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionprivate org.apache.directory.api.ldap.model.ldif.LdifEntry anonymizeChangeDelete(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionprivate org.apache.directory.api.ldap.model.ldif.LdifEntry anonymizeChangeModDn(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionprivate org.apache.directory.api.ldap.model.entry.Entry anonymizeEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry ldifEntry)
throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionpublic String anonymize(String ldif) throws org.apache.directory.api.ldap.model.exception.LdapException, IOException
ldif - The ldif content to anonymizeorg.apache.directory.api.ldap.model.exception.LdapException - If we got some LDAP related exceptionIOException - If we had some issue during some IO operationspublic Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> getValueMap()
public void setValueMap(Map<org.apache.directory.api.ldap.model.entry.Value<?>,org.apache.directory.api.ldap.model.entry.Value<?>> valueMap)
valueMap - the valueMap to setpublic Map<Integer,String> getLatestStringMap()
public void setLatestStringMap(Map<Integer,String> latestStringMap)
latestStringMap - the latest String Value Map to setpublic Map<Integer,byte[]> getLatestBytesMap()
public void setLatestBytesMap(Map<Integer,byte[]> latestBytesMap)
latestBytesMap - the latest byte[] Value Map to setpublic static void main(String[] args) throws IOException, org.apache.directory.api.ldap.model.exception.LdapException
args - Contains the arguments : the file to convert. The anonymized
LDIF will be printed on stdoutIOException - If we had an issue opening the file to anonymise ot writing the resultorg.apache.directory.api.ldap.model.exception.LdapException - If we had some issue while processing the LDAP dataCopyright © 2009–2017 The Apache Software Foundation. All rights reserved.