@Test public void testLdifAnonymizer() throws Exception { String ldif = "dn: cn=test,dc=example,dc=com\n" + "ObjectClass: top\n" + "objectClass: person\n" + "cn: test\n" + "sn: Test\n" + "\n" + "dn: cn=emmanuel,dc=acme,dc=com\n" + "ObjectClass: top\n" + "objectClass: person\n" + "cn: emmanuel\n" + "sn: lecharnye\n"+ "\n" + "dn: cn=emmanuel,dc=test,dc=example,dc=com\n" + "ObjectClass: top\n" + "objectClass: person\n" + "cn: emmanuel\n" + "seeAlso: cn=emmanuel,dc=acme,dc=com\n" + "sn: elecharny\n"; SchemaManager schemaManager = null; try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { System.out.println( "Missing a SchemaManager !" ); System.exit( -1 ); } LdifAnonymizer anonymizer = new LdifAnonymizer( schemaManager ); anonymizer.addNamingContext( "dc=example,dc=com" ); anonymizer.addNamingContext( "dc=acme,dc=com" ); anonymizer.removeAnonAttributeType( schemaManager.getAttributeType( "sn" ) ); String result = anonymizer.anonymize( ldif ); List<LdifEntry> entries = ldifReader.parseLdif( result ); assertEquals( 3, entries.size() ); LdifEntry ldifEntry = entries.get( 0 ); assertTrue( ldifEntry.isEntry() ); Entry entry = ldifEntry.getEntry(); assertEquals( 3, entry.size() ); assertEquals( "cn=AAAA,dc=example,dc=com", entry.getDn().toString() ); Attribute cn = entry.get( "cn" ); assertEquals( "AAAA", cn.getString() ); Attribute sn = entry.get( "sn" ); assertEquals( "Test", sn.getString() ); ldifEntry = entries.get( 1 ); assertTrue( ldifEntry.isEntry() ); entry = ldifEntry.getEntry(); assertEquals( 3, entry.size() ); assertEquals( "cn=AAAAAAAA,dc=acme,dc=com", entry.getDn().toString() ); cn = entry.get( "cn" ); assertEquals( "AAAAAAAA", cn.getString() ); sn = entry.get( "sn" ); assertEquals( "lecharnye", sn.getString() ); ldifEntry = entries.get( 2 ); assertTrue( ldifEntry.isEntry() ); entry = ldifEntry.getEntry(); assertEquals( 4, entry.size() ); assertEquals( "cn=AAAAAAAA,dc=AAAA,dc=example,dc=com", entry.getDn().toString() ); cn = entry.get( "cn" ); assertEquals( "AAAAAAAA", cn.getString() ); sn = entry.get( "sn" ); assertEquals( "elecharny", sn.getString() ); Attribute seeAlso = entry.get( "seeAlso" ); assertEquals( "cn=AAAAAAAA,dc=acme,dc=com", seeAlso.getString() ); }
public LdifAnonymizer() { try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { println( "Missing a SchemaManager !" ); System.exit( -1 ); } init( null, null, null, null ); }
LdifAnonymizer { public LdifAnonymizer() { try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { println( "Missing a SchemaManager !" ); System.exit( -1 ); } init( null, null, null, null ); } }
LdifAnonymizer { public LdifAnonymizer() { try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { println( "Missing a SchemaManager !" ); System.exit( -1 ); } init( null, null, null, null ); } LdifAnonymizer();  LdifAnonymizer( SchemaManager schemaManager ); }
LdifAnonymizer { public LdifAnonymizer() { try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { println( "Missing a SchemaManager !" ); System.exit( -1 ); } init( null, null, null, null ); } LdifAnonymizer();  LdifAnonymizer( SchemaManager schemaManager ); void setOut( PrintStream out ); void setAttributeLatestValueMap( AttributeType attributeType, Map<Integer, ?> latestValueMap ); void addAnonAttributeType( AttributeType attributeType ); void addAnonAttributeType( AttributeType attributeType, Anonymizer<?> anonymizer ); void removeAnonAttributeType( AttributeType attributeType ); Map<String, Anonymizer> getAttributeAnonymizers(); void addNamingContext( String dn ); void anonymizeFile( String ldifFile, Writer writer ); String anonymize( String ldif ); Map<Value, Value> getValueMap(); void setValueMap( Map<Value, Value> valueMap ); Map<Integer, String> getLatestStringMap(); void setLatestStringMap( Map<Integer, String> latestStringMap ); Map<Integer, byte[]> getLatestBytesMap(); void setLatestBytesMap( Map<Integer, byte[]> latestBytesMap ); static void main( String[] args ); }
LdifAnonymizer { public LdifAnonymizer() { try { schemaManager = new DefaultSchemaManager(); } catch ( Exception e ) { println( "Missing a SchemaManager !" ); System.exit( -1 ); } init( null, null, null, null ); } LdifAnonymizer();  LdifAnonymizer( SchemaManager schemaManager ); void setOut( PrintStream out ); void setAttributeLatestValueMap( AttributeType attributeType, Map<Integer, ?> latestValueMap ); void addAnonAttributeType( AttributeType attributeType ); void addAnonAttributeType( AttributeType attributeType, Anonymizer<?> anonymizer ); void removeAnonAttributeType( AttributeType attributeType ); Map<String, Anonymizer> getAttributeAnonymizers(); void addNamingContext( String dn ); void anonymizeFile( String ldifFile, Writer writer ); String anonymize( String ldif ); Map<Value, Value> getValueMap(); void setValueMap( Map<Value, Value> valueMap ); Map<Integer, String> getLatestStringMap(); void setLatestStringMap( Map<Integer, String> latestStringMap ); Map<Integer, byte[]> getLatestBytesMap(); void setLatestBytesMap( Map<Integer, byte[]> latestBytesMap ); static void main( String[] args );  }