Java Code Examples for org.apache.directory.api.ldap.model.ldif.LdifEntry#getDn()
The following examples show how to use
org.apache.directory.api.ldap.model.ldif.LdifEntry#getDn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdifAnonymizer.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Anonymize a Delete change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeDelete( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); // Process the DN, there is nothing more in the entry Dn anonymizedDn = anonymizeDn( entryDn ); ldifEntry.setDn( anonymizedDn ); return ldifEntry; }
Example 2
Source File: LdifAnonymizer.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Anonymize a Delete change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeModDn( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); // Process the DN Dn anonymizedDn = anonymizeDn( entryDn ); ldifEntry.setDn( anonymizedDn ); // Anonymize the newRdn if any String newRdnStr = ldifEntry.getNewRdn(); if ( newRdnStr != null ) { Dn newRdn = new Dn( schemaManager, newRdnStr ); Dn anonymizedRdn = anonymizeDn( newRdn ); ldifEntry.setNewRdn( anonymizedRdn.toString() ); } // Anonymize the neSuperior if any String newSuperiorStr = ldifEntry.getNewSuperior(); if ( newSuperiorStr != null ) { Dn newSuperior = new Dn( schemaManager, newSuperiorStr ); Dn anonymizedSuperior = anonymizeDn( newSuperior ); ldifEntry.setNewSuperior( anonymizedSuperior.toString() ); } return ldifEntry; }
Example 3
Source File: LdapStandaloneServer.java From bouncr with Eclipse Public License 1.0 | 5 votes |
private void checkPartition(LdifEntry ldifEntry) throws Exception { Dn dn = ldifEntry.getDn(); Dn parent = dn.getParent(); try { directoryService.getAdminSession().exists(parent); } catch (Exception e) { System.out.println("Creating new partition for DN=" + dn + "\n"); AvlPartition partition = new AvlPartition(directoryService.getSchemaManager()); partition.setId(dn.getName()); partition.setSuffixDn(dn); directoryService.addPartition(partition); } }
Example 4
Source File: LdapServer.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void checkPartition(LdifEntry ldifEntry) throws Exception { Dn dn = ldifEntry.getDn(); Dn parent = dn.getParent(); try { directoryService.getAdminSession().exists(parent); } catch (Exception e) { System.out.println("Creating new partition for DN=" + dn + "\n"); AvlPartition partition = new AvlPartition(directoryService.getSchemaManager()); partition.setId(dn.getName()); partition.setSuffixDn(dn); directoryService.addPartition(partition); } }
Example 5
Source File: LdifAnonymizer.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Anonymize a Add change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeAdd( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); LdifEntry newLdifEntry = new LdifEntry( schemaManager ); newLdifEntry.setChangeType( ChangeType.Add ); // Process the DN first Dn anonymizedDn = anonymizeDn( entryDn ); newLdifEntry.setDn( anonymizedDn ); // Now, process the entry's attributes for ( Attribute attribute : ldifEntry ) { AttributeType attributeType = attribute.getAttributeType(); Attribute anonymizedAttribute = new DefaultAttribute( attributeType ); // Deal with the special case of a DN syntax if ( attributeType.getSyntax().getSyntaxChecker() instanceof DnSyntaxChecker ) { for ( Value dnValue : attribute ) { Dn dn = new Dn( schemaManager, dnValue.getString() ); Dn newdDn = anonymizeDn( dn ); anonymizedAttribute.add( newdDn.toString() ); } newLdifEntry.addAttribute( attribute ); } else { Anonymizer anonymizer = attributeAnonymizers.get( attribute.getAttributeType().getOid() ); if ( anonymizer == null ) { newLdifEntry.addAttribute( attribute ); } else { anonymizedAttribute = anonymizer.anonymize( valueMap, valueSet, attribute ); if ( anonymizedAttribute != null ) { newLdifEntry.addAttribute( anonymizedAttribute ); } } } } return newLdifEntry; }