target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testReverseAdd() throws LdapInvalidDnException { Dn dn = new Dn( "dc=apache, dc=com" ); LdifEntry reversed = LdifRevertor.reverseAdd( dn ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Delete, reversed.getChangeType() ); assertNull( reversed.getEntry() ); }
public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseDel() throws LdapException { Dn dn = new Dn( "dc=apache, dc=com" ); Entry deletedEntry = new DefaultEntry( dn , "objectClass: top", "objectClass: person", "cn: test", "sn: apache", "dc: apache" ); LdifEntry reversed = LdifRevertor.reverseDel( dn, deletedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Add, reversed.getChangeType() ); assertNotNull( reversed.getEntry() ); assertEquals( deletedEntry, reversed.getEntry() ); }
public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; }
LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } }
LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyDelExistingOuValue() throws LdapException { Entry modifiedEntry = buildEntry(); modifiedEntry.put( "ou", "apache", "acme corp" ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute( "ou", "acme corp" ) ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertEquals( "acme corp", attr.getString() ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyDeleteOU() throws LdapException { Entry modifiedEntry = buildEntry(); modifiedEntry.put( "ou", "apache", "acme corp" ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute( "ou" ) ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertTrue( attr.contains( "apache", "acme corp" ) ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyDelExistingOuWithAllValues() throws LdapException { Entry modifiedEntry = buildEntry(); Attribute ou = new DefaultAttribute( "ou", "apache", "acme corp" ); modifiedEntry.put( ou ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, ou ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertTrue( ou.contains( "apache", "acme corp" ) ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyReplaceExistingOuValues() throws LdapException { Entry modifiedEntry = buildEntry(); Attribute ou = new DefaultAttribute( "ou", "apache", "acme corp" ); modifiedEntry.put( ou ); Dn dn = new Dn( "cn=test, ou=system" ); Attribute ouModified = new DefaultAttribute( "ou", "directory", "BigCompany inc." ); Modification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, ouModified ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( ou, attr ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyReplaceNewAttribute() throws LdapException { Entry modifiedEntry = buildEntry(); Dn dn = new Dn( "cn=test, ou=system" ); Attribute newOu = new DefaultAttribute( "ou", "apache", "acme corp" ); Modification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertNull( attr.get() ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyReplaceExistingOuWithNothing() throws LdapException { Entry modifiedEntry = buildEntry(); modifiedEntry.put( "ou", "apache", "acme corp" ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( "ou" ) ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertTrue( attr.contains( "apache", "acme corp" ) ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testGetAllBundleExports() { OsgiUtils.getAllBundleExports( null, null ); }
public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17000_NO_EXPORT_FOUND, candidate ) ); } continue; } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17001_PROCESSING_EXPORTS, candidate, exports ) ); } splitIntoPackages( exports, pkgs ); } return pkgs; }
OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17000_NO_EXPORT_FOUND, candidate ) ); } continue; } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17001_PROCESSING_EXPORTS, candidate, exports ) ); } splitIntoPackages( exports, pkgs ); } return pkgs; } }
OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17000_NO_EXPORT_FOUND, candidate ) ); } continue; } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17001_PROCESSING_EXPORTS, candidate, exports ) ); } splitIntoPackages( exports, pkgs ); } return pkgs; } private OsgiUtils(); }
OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17000_NO_EXPORT_FOUND, candidate ) ); } continue; } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17001_PROCESSING_EXPORTS, candidate, exports ) ); } splitIntoPackages( exports, pkgs ); } return pkgs; } private OsgiUtils(); static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ); static Set<String> splitIntoPackages( String exports, Set<String> pkgs ); static Set<File> getClasspathCandidates( FileFilter filter ); static String getBundleExports( File bundle ); }
OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17000_NO_EXPORT_FOUND, candidate ) ); } continue; } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17001_PROCESSING_EXPORTS, candidate, exports ) ); } splitIntoPackages( exports, pkgs ); } return pkgs; } private OsgiUtils(); static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ); static Set<String> splitIntoPackages( String exports, Set<String> pkgs ); static Set<File> getClasspathCandidates( FileFilter filter ); static String getBundleExports( File bundle ); }
@Test public void testReverseMultipleModifications() throws Exception { String initialEntryLdif = "dn: cn=test, ou=system\n" + "objectclass: top\n" + "objectclass: person\n" + "cn: test\n" + "sn: joe doe\n" + "l: USA\n" + "ou: apache\n" + "ou: acme corp\n"; LdifReader reader = new LdifReader(); List<LdifEntry> entries = reader.parseLdif( initialEntryLdif ); reader.close(); LdifEntry initialEntry = entries.get( 0 ); Dn dn = new Dn( "cn=test, ou=system" ); List<Modification> modifications = new ArrayList<Modification>(); Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute( "ou", "BigCompany inc." ) ); modifications.add( mod ); mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute( "l" ) ); modifications.add( mod ); mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute( "l", "FR" ) ); modifications.add( mod ); mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( "l", "USA" ) ); modifications.add( mod ); mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( "ou", "apache" ) ); modifications.add( mod ); LdifEntry reversedEntry = LdifRevertor.reverseModify( dn, modifications, initialEntry.getEntry() ); String expectedEntryLdif = "dn: cn=test, ou=system\n" + "changetype: modify\n" + "replace: ou\n" + "ou: apache\n" + "ou: acme corp\n" + "ou: BigCompany inc.\n" + "-\n" + "replace: l\n" + "l: FR\n" + "-\n" + "delete: l\n" + "l: FR\n" + "-\n" + "add: l\n" + "l: USA\n" + "-\n" + "delete: ou\n" + "ou: BigCompany inc.\n" + "-\n\n"; reader = new LdifReader(); entries = reader.parseLdif( expectedEntryLdif ); reader.close(); LdifEntry expectedEntry = entries.get( 0 ); assertEquals( expectedEntry, reversedEntry ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyAddNewOuValue() throws LdapException { Entry modifiedEntry = buildEntry(); modifiedEntry.put( "ou", "apache", "acme corp" ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute( "ou", "BigCompany inc." ) ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertEquals( "BigCompany inc.", attr.getString() ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyAddNewOu() throws LdapException { Entry modifiedEntry = buildEntry(); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute( "ou", "BigCompany inc." ) ); LdifEntry reversed = LdifRevertor.reverseModify( dn, Collections.<Modification> singletonList( mod ), modifiedEntry ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); assertNull( reversed.getEntry() ); List<Modification> mods = reversed.getModifications(); assertNotNull( mods ); assertEquals( 1, mods.size() ); Modification modif = mods.get( 0 ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() ); Attribute attr = modif.getAttribute(); assertNotNull( attr ); assertEquals( "ou", attr.getId() ); assertEquals( "BigCompany inc.", attr.getString() ); }
public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifications = new ArrayList<>(); for ( Modification modification : forwardModifications ) { switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute mod = modification.getAttribute(); Attribute previous = clonedEntry.get( mod.getId() ); if ( mod.equals( previous ) ) { continue; } Modification reverseModification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REMOVE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( previous == null ) { continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; } reverseModification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, mod ); reverseModifications.add( 0, reverseModification ); break; case REPLACE_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); if ( ( mod.get() == null ) && ( previous == null ) ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( mod.getId() ) ); reverseModifications.add( 0, reverseModification ); continue; } if ( mod.get() == null ) { reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); continue; } if ( previous == null ) { Attribute emptyAttribute = new DefaultAttribute( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, emptyAttribute ); reverseModifications.add( 0, reverseModification ); continue; } reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; case INCREMENT_ATTRIBUTE: mod = modification.getAttribute(); previous = clonedEntry.get( mod.getId() ); reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous ); reverseModifications.add( 0, reverseModification ); break; default: break; } AttributeUtils.applyModification( clonedEntry, modification ); } if ( reverseModifications.isEmpty() ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13465_CANT_DEDUCE_REVERSE_FOR_MOD, forwardModifications ) ); } for ( Modification modification : reverseModifications ) { entry.addModification( modification ); } return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseAddBase64DN() throws LdapException { Dn dn = new Dn( "dc=Emmanuel L\u00c9charny" ); LdifEntry reversed = LdifRevertor.reverseAdd( dn ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Delete, reversed.getChangeType() ); assertNull( reversed.getEntry() ); }
public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testReverseModifyDNMove() throws LdapException { Dn dn = new Dn( "cn=john doe, dc=example, dc=com" ); Dn newSuperior = new Dn( "ou=system" ); Rdn rdn = new Rdn( "cn=john doe" ); LdifEntry reversed = LdifRevertor.reverseMove( newSuperior, dn ); assertNotNull( reversed ); assertEquals( "cn=john doe,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModDn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( rdn.getName(), reversed.getNewRdn() ); assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) ); assertNull( reversed.getEntry() ); }
public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException { LdifEntry entry = new LdifEntry(); Dn currentParent; Rdn currentRdn; Dn newDn; if ( newSuperiorDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13466_NEW_SUPERIOR_DN_NULL ) ); } if ( modifiedDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13467_NULL_MODIFIED_DN ) ); } if ( modifiedDn.size() == 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13468_DONT_MOVE_ROOTDSE ) ); } currentParent = modifiedDn; currentRdn = currentParent.getRdn(); currentParent = currentParent.getParent(); newDn = newSuperiorDn; newDn = newDn.add( modifiedDn.getRdn() ); entry.setChangeType( ChangeType.ModDn ); entry.setDn( newDn ); entry.setNewRdn( currentRdn.getName() ); entry.setNewSuperior( currentParent.getName() ); entry.setDeleteOldRdn( false ); return entry; }
LdifRevertor { public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException { LdifEntry entry = new LdifEntry(); Dn currentParent; Rdn currentRdn; Dn newDn; if ( newSuperiorDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13466_NEW_SUPERIOR_DN_NULL ) ); } if ( modifiedDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13467_NULL_MODIFIED_DN ) ); } if ( modifiedDn.size() == 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13468_DONT_MOVE_ROOTDSE ) ); } currentParent = modifiedDn; currentRdn = currentParent.getRdn(); currentParent = currentParent.getParent(); newDn = newSuperiorDn; newDn = newDn.add( modifiedDn.getRdn() ); entry.setChangeType( ChangeType.ModDn ); entry.setDn( newDn ); entry.setNewRdn( currentRdn.getName() ); entry.setNewSuperior( currentParent.getName() ); entry.setDeleteOldRdn( false ); return entry; } }
LdifRevertor { public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException { LdifEntry entry = new LdifEntry(); Dn currentParent; Rdn currentRdn; Dn newDn; if ( newSuperiorDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13466_NEW_SUPERIOR_DN_NULL ) ); } if ( modifiedDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13467_NULL_MODIFIED_DN ) ); } if ( modifiedDn.size() == 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13468_DONT_MOVE_ROOTDSE ) ); } currentParent = modifiedDn; currentRdn = currentParent.getRdn(); currentParent = currentParent.getParent(); newDn = newSuperiorDn; newDn = newDn.add( modifiedDn.getRdn() ); entry.setChangeType( ChangeType.ModDn ); entry.setDn( newDn ); entry.setNewRdn( currentRdn.getName() ); entry.setNewSuperior( currentParent.getName() ); entry.setDeleteOldRdn( false ); return entry; } private LdifRevertor(); }
LdifRevertor { public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException { LdifEntry entry = new LdifEntry(); Dn currentParent; Rdn currentRdn; Dn newDn; if ( newSuperiorDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13466_NEW_SUPERIOR_DN_NULL ) ); } if ( modifiedDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13467_NULL_MODIFIED_DN ) ); } if ( modifiedDn.size() == 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13468_DONT_MOVE_ROOTDSE ) ); } currentParent = modifiedDn; currentRdn = currentParent.getRdn(); currentParent = currentParent.getParent(); newDn = newSuperiorDn; newDn = newDn.add( modifiedDn.getRdn() ); entry.setChangeType( ChangeType.ModDn ); entry.setDn( newDn ); entry.setNewRdn( currentRdn.getName() ); entry.setNewSuperior( currentParent.getName() ); entry.setDeleteOldRdn( false ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException { LdifEntry entry = new LdifEntry(); Dn currentParent; Rdn currentRdn; Dn newDn; if ( newSuperiorDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13466_NEW_SUPERIOR_DN_NULL ) ); } if ( modifiedDn == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13467_NULL_MODIFIED_DN ) ); } if ( modifiedDn.size() == 0 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13468_DONT_MOVE_ROOTDSE ) ); } currentParent = modifiedDn; currentRdn = currentParent.getRdn(); currentParent = currentParent.getParent(); newDn = newSuperiorDn; newDn = newDn.add( modifiedDn.getRdn() ); entry.setChangeType( ChangeType.ModDn ); entry.setDn( newDn ); entry.setNewRdn( currentRdn.getName() ); entry.setNewSuperior( currentParent.getName() ); entry.setDeleteOldRdn( false ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test11ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test12ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=small" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=small,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test21ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test22ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=small" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=small,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=joe" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testOneByteChar() { char res = Unicode.bytesToChar( new byte[] { 0x30 } ); assertEquals( '0', res ); }
public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnExistsInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test4ReverseRenameCompositeSimpleNotOverlappingDeleteOldRdnDontExistsInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=joe" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test4ReverseRenameCompositeSimpleNotOverlappingDeleteOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test5ReverseRenameCompositeSimpleOverlappingKeepOldRdn() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test5ReverseRenameCompositeSimpleOverlappingDeleteOldRdn() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test61ReverseRenameSimpleCompositeNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=plumber" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test62ReverseRenameSimpleCompositeNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=small" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=small,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "cn", mods[0].getAttribute().getId() ); assertEquals( "joe", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test71ReverseRenameSimpleCompositeNotOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=plumber" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test72ReverseRenameSimpleCompositeNotOverlappingDeleteOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=small" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=small,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "cn", mods[0].getAttribute().getId() ); assertEquals( "joe", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test81ReverseRenameSimpleCompositeOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "sn=small+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testOneByteChar00() { char res = Unicode.bytesToChar( new byte[] { 0x00 } ); assertEquals( 0x00, res ); }
public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void test82ReverseRenameSimpleCompositeOverlappingKeepOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "sn=small+cn=test+seeAlso=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "seeAlso: big", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=small+cn=test+seeAlso=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "sn", mods[0].getAttribute().getId() ); assertEquals( "small", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test91ReverseRenameSimpleCompositeOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "sn=small+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test92ReverseRenameSimpleCompositeOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "cn=test,ou=system" ); Rdn oldRdn = new Rdn( "cn=test" ); Rdn newRdn = new Rdn( "sn=small+cn=test+seeAlso=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "seeAlso: big", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=small+cn=test+seeAlso=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "sn", mods[0].getAttribute().getId() ); assertEquals( "small", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test101ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=plumber" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "sn=joe+cn=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=joe+cn=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "sn", mods[0].getAttribute().getId() ); assertEquals( "joe", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test111ReverseRenameCompositeCompositeNotOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=plumber" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test112ReverseRenameCompositeCompositeNotOverlappingDeleteOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "cn=joe+sn=big" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 2, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "cn=joe+sn=big,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); reversed = reverseds.get( 1 ); assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.Modify, reversed.getChangeType() ); Modification[] mods = reversed.getModificationArray(); assertNotNull( mods ); assertEquals( 1, mods.length ); assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() ); assertNotNull( mods[0].getAttribute() ); assertEquals( "cn", mods[0].getAttribute().getId() ); assertEquals( "joe", mods[0].getAttribute().getString() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test121ReverseRenameCompositeCompositeOverlappingKeepOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "sn=joe+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=joe+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test122ReverseRenameCompositeCompositeOverlappingKeepOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "sn=big+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=big+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void test131ReverseRenameCompositeCompositeOverlappingDeleteOldRdnDontExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "sn=joe+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=joe+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertTrue( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testOneByteChar7F() { char res = Unicode.bytesToChar( new byte[] { 0x7F } ); assertEquals( 0x7F, res ); }
public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void test132ReverseRenameCompositeCompositeOverlappingDeleteOldRdnExistInEntry() throws LdapException { Dn dn = new Dn( "sn=small+cn=test,ou=system" ); Rdn oldRdn = new Rdn( "sn=small+cn=test" ); Rdn newRdn = new Rdn( "sn=big+cn=test" ); Entry entry = new DefaultEntry( dn, "objectClass: top", "objectClass: person", "cn: test", "sn: small", "sn: big", "sn: this is a test" ); List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN ); assertNotNull( reverseds ); assertEquals( 1, reverseds.size() ); LdifEntry reversed = reverseds.get( 0 ); assertEquals( "sn=big+cn=test,ou=system", reversed.getDn().getName() ); assertEquals( ChangeType.ModRdn, reversed.getChangeType() ); assertFalse( reversed.isDeleteOldRdn() ); assertEquals( oldRdn.getName(), reversed.getNewRdn() ); assertNull( reversed.getNewSuperior() ); }
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); }
LdifRevertor { public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ); static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ); static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ); static List<LdifEntry> reverseMoveAndRename( Entry entry, Dn newSuperior, Rdn newRdn, boolean deleteOldRdn ); static final boolean DELETE_OLD_RDN; static final boolean KEEP_OLD_RDN; }
@Test public void testIsLdifNullString() { assertTrue( LdifUtils.isLDIFSafe( null ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifEmptyString() { assertTrue( LdifUtils.isLDIFSafe( "" ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithNUL() { char c = ( char ) 0; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithLF() { char c = ( char ) 10; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithCR() { char c = ( char ) 13; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithSpace() { char c = ( char ) 32; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithColon() { char c = ( char ) 58; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithLessThan() { char c = ( char ) 60; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeStartingWithCharGreaterThan127() { char c = ( char ) 127; assertTrue( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testTwoBytesChar() { char res = Unicode.bytesToChar( new byte[] { ( byte ) 0xCE, ( byte ) 0x91 } ); assertEquals( 0x0391, res ); }
public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void testSingleBitBitString() throws DecoderException { BitString bitString = new BitString( new byte[] { 0x07, ( byte ) 0x80 } ); assertEquals( true, bitString.getBit( 0 ) ); }
public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return res != 0; }
BitString { public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return res != 0; } }
BitString { public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return res != 0; } BitString( int length ); BitString( byte[] bytes ); }
BitString { public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return res != 0; } BitString( int length ); BitString( byte[] bytes ); void setData( byte[] data ); byte[] getData(); byte getUnusedBits(); void setBit( int pos ); void clearBit( int pos ); boolean getBit( int pos ); int size(); @Override String toString(); }
BitString { public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return res != 0; } BitString( int length ); BitString( byte[] bytes ); void setData( byte[] data ); byte[] getData(); byte getUnusedBits(); void setBit( int pos ); void clearBit( int pos ); boolean getBit( int pos ); int size(); @Override String toString(); static final BitString EMPTY_STRING; }
@Test public void testIsLdifSafeStartingWithCharGreaterThan127Bis() { char c = ( char ) 222; assertFalse( LdifUtils.isLDIFSafe( c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeContainsNUL() { char c = ( char ) 0; assertFalse( LdifUtils.isLDIFSafe( testString + c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeContainsLF() { char c = ( char ) 10; assertFalse( LdifUtils.isLDIFSafe( testString + c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeContainsCR() { char c = ( char ) 13; assertFalse( LdifUtils.isLDIFSafe( testString + c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeContainsCharGreaterThan127() { char c = ( char ) 127; assertTrue( LdifUtils.isLDIFSafe( testString + c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeContainsCharGreaterThan127Bis() { char c = ( char ) 328; assertFalse( LdifUtils.isLDIFSafe( testString + c + testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeEndingWithSpace() { char c = ( char ) 32; assertFalse( LdifUtils.isLDIFSafe( testString + c ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testIsLdifSafeCorrectString() { assertTrue( LdifUtils.isLDIFSafe( testString ) ); }
public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static boolean isLDIFSafe( String str ) { if ( Strings.isEmpty( str ) ) { return true; } char currentChar = str.charAt( 0 ); if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] ) { return false; } for ( int i = 1; i < str.length(); i++ ) { currentChar = str.charAt( i ); if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] ) { return false; } } return currentChar != ' '; } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testStripLineToNChars() { String line = "abc"; try { LdifUtils.stripLineToNChars( line, 1 ); fail(); } catch ( IllegalArgumentException iae ) { } String res = LdifUtils.stripLineToNChars( line, 2 ); assertEquals( "ab\n c", res ); assertEquals( "abc", LdifUtils.stripLineToNChars( line, 3 ) ); }
public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testStripLineTo5Chars() { assertEquals( "a", LdifUtils.stripLineToNChars( "a", 5 ) ); assertEquals( "ab", LdifUtils.stripLineToNChars( "ab", 5 ) ); assertEquals( "abc", LdifUtils.stripLineToNChars( "abc", 5 ) ); assertEquals( "abcd", LdifUtils.stripLineToNChars( "abcd", 5 ) ); assertEquals( "abcde", LdifUtils.stripLineToNChars( "abcde", 5 ) ); assertEquals( "abcde\n f", LdifUtils.stripLineToNChars( "abcdef", 5 ) ); assertEquals( "abcde\n fg", LdifUtils.stripLineToNChars( "abcdefg", 5 ) ); assertEquals( "abcde\n fgh", LdifUtils.stripLineToNChars( "abcdefgh", 5 ) ); assertEquals( "abcde\n fghi", LdifUtils.stripLineToNChars( "abcdefghi", 5 ) ); assertEquals( "abcde\n fghi\n j", LdifUtils.stripLineToNChars( "abcdefghij", 5 ) ); assertEquals( "abcde\n fghi\n jk", LdifUtils.stripLineToNChars( "abcdefghijk", 5 ) ); assertEquals( "abcde\n fghi\n jkl", LdifUtils.stripLineToNChars( "abcdefghijkl", 5 ) ); assertEquals( "abcde\n fghi\n jklm", LdifUtils.stripLineToNChars( "abcdefghijklm", 5 ) ); assertEquals( "abcde\n fghi\n jklm\n n", LdifUtils.stripLineToNChars( "abcdefghijklmn", 5 ) ); assertEquals( "abcde\n fghi\n jklm\n no", LdifUtils.stripLineToNChars( "abcdefghijklmno", 5 ) ); assertEquals( "abcde\n fghi\n jklm\n nop", LdifUtils.stripLineToNChars( "abcdefghijklmnop", 5 ) ); }
public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String stripLineToNChars( String str, int nbChars ) { int strLength = str.length(); if ( strLength <= nbChars ) { return str; } if ( nbChars < 2 ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_13474_LINE_LENGTH_TOO_SHORT ) ); } int charsPerLine = nbChars - 1; int remaining = ( strLength - nbChars ) % charsPerLine; int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 ); int nbCharsTotal = strLength + nbLines + nbLines - 2; char[] buffer = new char[nbCharsTotal]; char[] orig = str.toCharArray(); int posSrc = 0; int posDst = 0; System.arraycopy( orig, posSrc, buffer, posDst, nbChars ); posSrc += nbChars; posDst += nbChars; for ( int i = 0; i < nbLines - 2; i++ ) { buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, charsPerLine ); posSrc += charsPerLine; posDst += charsPerLine; } buffer[posDst++] = '\n'; buffer[posDst++] = ' '; System.arraycopy( orig, posSrc, buffer, posDst, remaining == 0 ? charsPerLine : remaining ); return new String( buffer ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testThreeBytesChar() { char res = Unicode.bytesToChar( new byte[] { ( byte ) 0xE2, ( byte ) 0x89, ( byte ) 0xA2 } ); assertEquals( 0x2262, res ); }
public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void testConvertToLdifEncoding() throws LdapException { Attributes attributes = new BasicAttributes( "cn", "Saarbr\u00FCcken" ); String ldif = LdifUtils.convertToLdif( attributes ); assertEquals( "cn:: U2FhcmJyw7xja2Vu\n", ldif ); }
public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testConvertToLdifAttrWithNullValues() throws LdapException { Attributes attributes = new BasicAttributes( "cn", null ); String ldif = LdifUtils.convertToLdif( attributes ); assertEquals( "cn:\n", ldif ); }
public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testConvertToLdif() throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( "cn=Saarbr\u00FCcken, dc=example, dc=com" ); entry.setChangeType( ChangeType.Add ); entry.addAttribute( "objectClass", "top", "person", "inetorgPerson" ); entry.addAttribute( "cn", "Saarbr\u00FCcken" ); entry.addAttribute( "sn", "test" ); LdifUtils.convertToLdif( entry, 15 ); }
public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testCreateAttributesVarargs() throws LdapException, LdapLdifException, NamingException { String mOid = "m-oid: 1.2.3.4"; String description = "description"; Attributes attrs = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: metaTop", "objectClass: metaSyntax", mOid, "m-description", description ); assertEquals( "top", attrs.get( "objectClass" ).get( 0 ) ); assertEquals( "metaTop", attrs.get( "objectClass" ).get( 1 ) ); assertEquals( "metaSyntax", attrs.get( "objectClass" ).get( 2 ) ); assertEquals( "1.2.3.4", attrs.get( "m-oid" ).get() ); assertEquals( "description", attrs.get( "m-description" ).get() ); try { LdifUtils.createJndiAttributes( "objectClass", "top", "objectClass" ); fail(); } catch ( LdapInvalidAttributeValueException iave ) { assertTrue( true ); } }
public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } }
LdifUtils { public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } } }
LdifUtils { public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } } private LdifUtils(); }
LdifUtils { public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testConvertEntryNoControls() throws Exception { LdifReader reader = new LdifReader(); String expected = "dn: ou=test\n" + "ObjectClass: top\n" + "ObjectClass: metaTop\n" + "ObjectClass: metaSyntax\n" + "m-oid: 1.2.3.4\n" + "m-description: description\n\n"; List<LdifEntry> entries = reader.parseLdif( expected ); LdifEntry expectedEntry = entries.get( 0 ); LdifEntry entry = new LdifEntry(); entry.setDn( "ou=test" ); entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" ); entry.addAttribute( "m-oid", "1.2.3.4" ); entry.addAttribute( "m-description", "description" ); String converted = LdifUtils.convertToLdif( entry ); assertNotNull( converted ); entries = reader.parseLdif( converted ); LdifEntry convertedEntry = entries.get( 0 ); assertEquals( expectedEntry, convertedEntry ); reader.close(); }
public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testConvertEntryOneControl() throws Exception { LdifReader reader = new LdifReader(); String expected = "dn: ou=test\n" + "control: 2.16.840.1.113730.3.4.2 false\n" + "changetype: add\n" + "ObjectClass: top\n" + "ObjectClass: metaTop\n" + "ObjectClass: metaSyntax\n" + "m-oid: 1.2.3.4\n" + "m-description: description\n\n"; List<LdifEntry> entries = reader.parseLdif( expected ); LdifEntry expectedEntry = entries.get( 0 ); LdifEntry entry = new LdifEntry(); entry.setDn( "ou=test" ); entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" ); entry.addAttribute( "m-oid", "1.2.3.4" ); entry.addAttribute( "m-description", "description" ); ManageDsaITImpl control = new ManageDsaITImpl(); entry.addControl( control ); String converted = LdifUtils.convertToLdif( entry ); assertNotNull( converted ); entries = reader.parseLdif( converted ); LdifEntry convertedEntry = entries.get( 0 ); assertEquals( expectedEntry, convertedEntry ); reader.close(); }
public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
LdifUtils { public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toEntry( attrs, null ), DEFAULT_LINE_LENGTH ); } private LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas ); }
@Test public void testChangeTypeDeleteBadEntry() throws Exception { String ldif = "version: 1\n" + "dn: dc=example,dc=com\n" + "changetype: delete\n" + "attr1: test"; try ( LdifReader reader = new LdifReader() ) { assertThrows( LdapLdifException.class, () -> { reader.parseLdif( ldif ); } ); } }
public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
@Test public void testLdifContentWithControl() throws Exception { String ldif = "version: 1\n" + "dn: dc=example,dc=com\n" + "control: 1.1.1\n" + "attr1: test"; try ( LdifReader reader = new LdifReader() ) { assertThrows( LdapLdifException.class, () -> { reader.parseLdif( ldif ); } ); } }
public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
@Test public void testLdifParserRootDSE() throws Exception { String ldif = "version: 1\n" + "dn:\n" + "cn:: YXBwMQ==\n" + "objectClass: top\n" + "objectClass: apApplication\n" + "displayName: app1 \n" + "dependencies:\n" + "envVars:"; try ( LdifReader reader = new LdifReader() ) { List<LdifEntry> entries = reader.parseLdif( ldif ); assertNotNull( entries ); LdifEntry entry = entries.get( 0 ); assertTrue( entry.isLdifContent() ); assertEquals( "", entry.getDn().getName() ); Attribute attr = entry.get( "cn" ); assertTrue( attr.contains( "app1" ) ); attr = entry.get( "objectclass" ); assertTrue( attr.contains( "top" ) ); assertTrue( attr.contains( "apApplication" ) ); attr = entry.get( "displayname" ); assertTrue( attr.contains( "app1" ) ); attr = entry.get( "dependencies" ); assertEquals( "", attr.get().getString() ); attr = entry.get( "envvars" ); assertEquals( "", attr.get().getString() ); } }
public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
@Test public void testLdifParserWithNullDn() throws Exception, Exception { String ldif1 = "dn: ads-authenticatorid=anonymousauthenticator,ou=authenticators,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config\n" + "ads-authenticatorid: anonymousauthenticator\n" + "objectclass: top\n" + "objectclass: ads-base\n" + "objectClass: ads-authenticator\n" + "objectClass: ads-authenticatorImpl\n" + "ads-authenticatorClass: org.apache.directory.server.core.authn.AnonymousAuthenticator\n" + "ads-baseDn: \n" + "ads-enabled: TRUE"; String ldif2 = "dn: ads-authenticatorid=anonymousauthenticator,ou=authenticators,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config\n" + "ads-authenticatorid: anonymousauthenticator\n" + "objectclass: top\n" + "objectclass: ads-base\n" + "objectClass: ads-authenticator\n" + "objectClass: ads-authenticatorImpl\n" + "ads-authenticatorClass: org.apache.directory.server.core.authn.AnonymousAuthenticator\n" + "ads-baseDn:\n" + "ads-enabled: TRUE"; try ( LdifReader reader = new LdifReader() ) { List<LdifEntry> entries1 = reader.parseLdif( ldif1 ); LdifEntry entry1 = entries1.get( 0 ); List<LdifEntry> entries2 = reader.parseLdif( ldif2 ); LdifEntry entry2 = entries2.get( 0 ); assertEquals( entry1, entry2 ); } }
public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
LdifReader implements Iterable<LdifEntry>, Closeable { public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13407_STARTS_PARSING_LDIF ) ); } if ( Strings.isEmpty( ldif ) ) { return new ArrayList<>(); } try ( BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) ) ) { List<LdifEntry> entries = parseLdif( bufferReader ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13403_PARSED_N_ENTRIES, Integer.valueOf( entries.size() ) ) ); } return entries; } catch ( LdapLdifException ne ) { LOG.error( I18n.err( I18n.ERR_13428_CANNOT_PARSE_LDIF, ne.getLocalizedMessage() ) ); throw new LdapLdifException( I18n.err( I18n.ERR_13442_ERROR_PARSING_LDIF_BUFFER ), ne ); } catch ( LdapException le ) { throw new LdapLdifException( le.getMessage(), le ); } catch ( IOException ioe ) { throw new LdapLdifException( I18n.err( I18n.ERR_13450_CANNOT_CLOSE_FILE ), ioe ); } } LdifReader(); LdifReader( SchemaManager schemaManager ); LdifReader( String ldifFileName ); LdifReader( Reader in ); LdifReader( InputStream in ); LdifReader( File file ); LdifReader( File file, SchemaManager schemaManager ); void init(); int getVersion(); long getSizeLimit(); void setSizeLimit( long sizeLimit ); static Attribute parseAttributeValue( String line ); void parseAttributeValue( LdifEntry entry, String line, String lowerLine ); List<LdifEntry> parseLdifFile( String fileName ); List<LdifEntry> parseLdifFile( String fileName, String encoding ); List<LdifEntry> parseLdif( String ldif ); LdifEntry next(); LdifEntry fetch(); boolean hasNext(); void remove(); @Override Iterator<LdifEntry> iterator(); boolean hasError(); Exception getError(); List<LdifEntry> parseLdif( BufferedReader reader ); boolean containsEntries(); int getLineNumber(); boolean isValidateDn(); void setValidateDn( boolean validateDn ); void setSchemaManager( SchemaManager schemaManager ); @Override void close(); }
@Test public void testcharToBytesOne() { assertEquals( "0x00 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0000 ) ) ); assertEquals( "0x61 ", Strings.dumpBytes( Unicode.charToBytes( 'a' ) ) ); assertEquals( "0x7F ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x007F ) ) ); }
public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void testNullTrustManagers() { LdapConnectionConfig config = new LdapConnectionConfig(); Assertions.assertThrows(IllegalArgumentException.class, () -> { config.setTrustManagers((TrustManager)null); }); }
public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); boolean isUseSsl(); void setUseSsl( boolean useSsl ); int getLdapPort(); void setLdapPort( int ldapPort ); String getLdapHost(); void setLdapHost( String ldapHost ); String getName(); void setName( String name ); String getCredentials(); void setCredentials( String credentials ); int getDefaultLdapPort(); int getDefaultLdapsPort(); String getDefaultLdapHost(); long getDefaultTimeout(); long getTimeout(); void setTimeout( long timeout ); int getSupportedLdapVersion(); TrustManager[] getTrustManagers(); void setTrustManagers( TrustManager... trustManagers ); String getSslProtocol(); void setSslProtocol( String sslProtocol ); KeyManager[] getKeyManagers(); void setKeyManagers( KeyManager[] keyManagers ); SecureRandom getSecureRandom(); void setSecureRandom( SecureRandom secureRandom ); String[] getEnabledCipherSuites(); void setEnabledCipherSuites( String[] enabledCipherSuites ); String[] getEnabledProtocols(); void setEnabledProtocols( String... enabledProtocols ); BinaryAttributeDetector getBinaryAttributeDetector(); void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector ); boolean isUseTls(); void setUseTls( boolean useTls ); LdapApiService getLdapApiService(); void setLdapApiService( LdapApiService ldapApiService ); }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); boolean isUseSsl(); void setUseSsl( boolean useSsl ); int getLdapPort(); void setLdapPort( int ldapPort ); String getLdapHost(); void setLdapHost( String ldapHost ); String getName(); void setName( String name ); String getCredentials(); void setCredentials( String credentials ); int getDefaultLdapPort(); int getDefaultLdapsPort(); String getDefaultLdapHost(); long getDefaultTimeout(); long getTimeout(); void setTimeout( long timeout ); int getSupportedLdapVersion(); TrustManager[] getTrustManagers(); void setTrustManagers( TrustManager... trustManagers ); String getSslProtocol(); void setSslProtocol( String sslProtocol ); KeyManager[] getKeyManagers(); void setKeyManagers( KeyManager[] keyManagers ); SecureRandom getSecureRandom(); void setSecureRandom( SecureRandom secureRandom ); String[] getEnabledCipherSuites(); void setEnabledCipherSuites( String[] enabledCipherSuites ); String[] getEnabledProtocols(); void setEnabledProtocols( String... enabledProtocols ); BinaryAttributeDetector getBinaryAttributeDetector(); void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector ); boolean isUseTls(); void setUseTls( boolean useTls ); LdapApiService getLdapApiService(); void setLdapApiService( LdapApiService ldapApiService ); static final int DEFAULT_LDAP_PORT; static final int DEFAULT_LDAPS_PORT; static final String DEFAULT_LDAP_HOST; static final int LDAP_V3; static final long DEFAULT_TIMEOUT; static final String DEFAULT_SSL_PROTOCOL; }
@Test public void testNullTrustManagers2() { LdapConnectionConfig config = new LdapConnectionConfig(); Assertions.assertThrows(IllegalArgumentException.class, () -> { config.setTrustManagers(null); }); }
public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); boolean isUseSsl(); void setUseSsl( boolean useSsl ); int getLdapPort(); void setLdapPort( int ldapPort ); String getLdapHost(); void setLdapHost( String ldapHost ); String getName(); void setName( String name ); String getCredentials(); void setCredentials( String credentials ); int getDefaultLdapPort(); int getDefaultLdapsPort(); String getDefaultLdapHost(); long getDefaultTimeout(); long getTimeout(); void setTimeout( long timeout ); int getSupportedLdapVersion(); TrustManager[] getTrustManagers(); void setTrustManagers( TrustManager... trustManagers ); String getSslProtocol(); void setSslProtocol( String sslProtocol ); KeyManager[] getKeyManagers(); void setKeyManagers( KeyManager[] keyManagers ); SecureRandom getSecureRandom(); void setSecureRandom( SecureRandom secureRandom ); String[] getEnabledCipherSuites(); void setEnabledCipherSuites( String[] enabledCipherSuites ); String[] getEnabledProtocols(); void setEnabledProtocols( String... enabledProtocols ); BinaryAttributeDetector getBinaryAttributeDetector(); void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector ); boolean isUseTls(); void setUseTls( boolean useTls ); LdapApiService getLdapApiService(); void setLdapApiService( LdapApiService ldapApiService ); }
LdapConnectionConfig { public void setTrustManagers( TrustManager... trustManagers ) { if ( ( trustManagers == null ) || ( trustManagers.length == 0 ) || ( trustManagers.length == 1 && trustManagers[0] == null ) ) { throw new IllegalArgumentException( "TrustManagers must not be null or empty" ); } this.trustManagers = trustManagers; } LdapConnectionConfig(); boolean isUseSsl(); void setUseSsl( boolean useSsl ); int getLdapPort(); void setLdapPort( int ldapPort ); String getLdapHost(); void setLdapHost( String ldapHost ); String getName(); void setName( String name ); String getCredentials(); void setCredentials( String credentials ); int getDefaultLdapPort(); int getDefaultLdapsPort(); String getDefaultLdapHost(); long getDefaultTimeout(); long getTimeout(); void setTimeout( long timeout ); int getSupportedLdapVersion(); TrustManager[] getTrustManagers(); void setTrustManagers( TrustManager... trustManagers ); String getSslProtocol(); void setSslProtocol( String sslProtocol ); KeyManager[] getKeyManagers(); void setKeyManagers( KeyManager[] keyManagers ); SecureRandom getSecureRandom(); void setSecureRandom( SecureRandom secureRandom ); String[] getEnabledCipherSuites(); void setEnabledCipherSuites( String[] enabledCipherSuites ); String[] getEnabledProtocols(); void setEnabledProtocols( String... enabledProtocols ); BinaryAttributeDetector getBinaryAttributeDetector(); void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetector ); boolean isUseTls(); void setUseTls( boolean useTls ); LdapApiService getLdapApiService(); void setLdapApiService( LdapApiService ldapApiService ); static final int DEFAULT_LDAP_PORT; static final int DEFAULT_LDAPS_PORT; static final String DEFAULT_LDAP_HOST; static final int LDAP_V3; static final long DEFAULT_TIMEOUT; static final String DEFAULT_SSL_PROTOCOL; }
@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 ); }
@Test public void testNot() { AttributeDescriptionFilter attributeFilter = AttributeDescriptionFilter.present( "objectClass" ); assertEquals( "(!" + attributeFilter.build().toString() + ")", UnaryFilter.not( attributeFilter ).build().toString() ); AttributeValueAssertionFilter attributeValueAssertionFilter = AttributeValueAssertionFilter.equal( "objectClass", "person" ); assertEquals( "(!" + attributeValueAssertionFilter.build().toString() + ")", UnaryFilter.not( attributeValueAssertionFilter ).build().toString() ); }
public static UnaryFilter not() { return new UnaryFilter(); }
UnaryFilter extends AbstractFilter { public static UnaryFilter not() { return new UnaryFilter(); } }
UnaryFilter extends AbstractFilter { public static UnaryFilter not() { return new UnaryFilter(); } private UnaryFilter(); }
UnaryFilter extends AbstractFilter { public static UnaryFilter not() { return new UnaryFilter(); } private UnaryFilter(); static UnaryFilter not(); static UnaryFilter not( Filter filter ); @Override StringBuilder build( StringBuilder builder ); }
UnaryFilter extends AbstractFilter { public static UnaryFilter not() { return new UnaryFilter(); } private UnaryFilter(); static UnaryFilter not(); static UnaryFilter not( Filter filter ); @Override StringBuilder build( StringBuilder builder ); }
@Test public void testAnd() { AttributeDescriptionFilter attributeFilter = AttributeDescriptionFilter.present( "objectClass" ); AttributeValueAssertionFilter attributeValueAssertionFilter = AttributeValueAssertionFilter.equal( "objectClass", "person" ); String expected = expected( FilterOperator.AND, attributeFilter, attributeValueAssertionFilter ); assertEquals( expected, SetOfFiltersFilter.and( attributeFilter, attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.and() .add( attributeFilter ) .add( attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.and() .addAll( attributeFilter, attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.and() .addAll( Arrays.asList( ( Filter ) attributeFilter, ( Filter ) attributeValueAssertionFilter ) ) .build().toString() ); }
public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); } }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filter... filters ); SetOfFiltersFilter addAll( List<Filter> filters ); static SetOfFiltersFilter and( Filter... filters ); static SetOfFiltersFilter or( Filter... filters ); @Override StringBuilder build( StringBuilder builder ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filter... filters ); SetOfFiltersFilter addAll( List<Filter> filters ); static SetOfFiltersFilter and( Filter... filters ); static SetOfFiltersFilter or( Filter... filters ); @Override StringBuilder build( StringBuilder builder ); }
@Test public void testOr() { AttributeDescriptionFilter attributeFilter = AttributeDescriptionFilter.present( "objectClass" ); AttributeValueAssertionFilter attributeValueAssertionFilter = AttributeValueAssertionFilter.equal( "objectClass", "person" ); String expected = expected( FilterOperator.OR, attributeFilter, attributeValueAssertionFilter ); assertEquals( expected, SetOfFiltersFilter.or( attributeFilter, attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.or() .add( attributeFilter ) .add( attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.or() .addAll( attributeFilter, attributeValueAssertionFilter ) .build().toString() ); assertEquals( expected, SetOfFiltersFilter.or() .addAll( Arrays.asList( ( Filter ) attributeFilter, ( Filter ) attributeValueAssertionFilter ) ) .build().toString() ); }
public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); } }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filter... filters ); SetOfFiltersFilter addAll( List<Filter> filters ); static SetOfFiltersFilter and( Filter... filters ); static SetOfFiltersFilter or( Filter... filters ); @Override StringBuilder build( StringBuilder builder ); }
SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filter... filters ); SetOfFiltersFilter addAll( List<Filter> filters ); static SetOfFiltersFilter and( Filter... filters ); static SetOfFiltersFilter or( Filter... filters ); @Override StringBuilder build( StringBuilder builder ); }
@Test public void testExtensible() { assertEquals( "(cn:caseExactMatch:=Fred Flintstone)", extensible( "cn", "Fred Flintstone" ) .setMatchingRule( "caseExactMatch" ).toString() ); }
public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); }
FilterBuilder { public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); } }
FilterBuilder { public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); } FilterBuilder( Filter filter ); }
FilterBuilder { public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, String value ); static FilterBuilder equal( String attribute, String value ); static MatchingRuleAssertionFilterBuilder extensible( String value ); static MatchingRuleAssertionFilterBuilder extensible( String attribute, String value ); static FilterBuilder greaterThanOrEqual( String attribute, String value ); static FilterBuilder lessThanOrEqual( String attribute, String value ); static FilterBuilder not( FilterBuilder builder ); static FilterBuilder or( FilterBuilder... builders ); static FilterBuilder present( String attribute ); static FilterBuilder startsWith( String attribute, String... parts ); static FilterBuilder endsWith( String attribute, String... parts ); static FilterBuilder contains( String attribute, String... parts ); static FilterBuilder substring( String attribute, String... parts ); @Override String toString(); }
FilterBuilder { public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, String value ); static FilterBuilder equal( String attribute, String value ); static MatchingRuleAssertionFilterBuilder extensible( String value ); static MatchingRuleAssertionFilterBuilder extensible( String attribute, String value ); static FilterBuilder greaterThanOrEqual( String attribute, String value ); static FilterBuilder lessThanOrEqual( String attribute, String value ); static FilterBuilder not( FilterBuilder builder ); static FilterBuilder or( FilterBuilder... builders ); static FilterBuilder present( String attribute ); static FilterBuilder startsWith( String attribute, String... parts ); static FilterBuilder endsWith( String attribute, String... parts ); static FilterBuilder contains( String attribute, String... parts ); static FilterBuilder substring( String attribute, String... parts ); @Override String toString(); }
@Test public void testFilterBuilder() { assertEquals( "(cn=Babs Jensen)", equal( "cn", "Babs Jensen" ).toString() ); assertEquals( "(!(cn=Tim Howes))", not( equal( "cn", "Tim Howes" ) ).toString() ); assertEquals( "(&(objectClass=Person)(|(sn=Jensen)(cn=Babs J\\2A)))", and( equal( "objectClass", "Person" ), or( equal( "sn", "Jensen" ), equal( "cn", "Babs J*" ) ) ).toString() ); assertEquals( "(o=univ\\2Aof\\2Amich\\2A)", equal( "o", "univ*of*mich*" ).toString() ); }
FilterBuilder( Filter filter ) { this.filter = filter; }
FilterBuilder { FilterBuilder( Filter filter ) { this.filter = filter; } }
FilterBuilder { FilterBuilder( Filter filter ) { this.filter = filter; } FilterBuilder( Filter filter ); }
FilterBuilder { FilterBuilder( Filter filter ) { this.filter = filter; } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, String value ); static FilterBuilder equal( String attribute, String value ); static MatchingRuleAssertionFilterBuilder extensible( String value ); static MatchingRuleAssertionFilterBuilder extensible( String attribute, String value ); static FilterBuilder greaterThanOrEqual( String attribute, String value ); static FilterBuilder lessThanOrEqual( String attribute, String value ); static FilterBuilder not( FilterBuilder builder ); static FilterBuilder or( FilterBuilder... builders ); static FilterBuilder present( String attribute ); static FilterBuilder startsWith( String attribute, String... parts ); static FilterBuilder endsWith( String attribute, String... parts ); static FilterBuilder contains( String attribute, String... parts ); static FilterBuilder substring( String attribute, String... parts ); @Override String toString(); }
FilterBuilder { FilterBuilder( Filter filter ) { this.filter = filter; } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, String value ); static FilterBuilder equal( String attribute, String value ); static MatchingRuleAssertionFilterBuilder extensible( String value ); static MatchingRuleAssertionFilterBuilder extensible( String attribute, String value ); static FilterBuilder greaterThanOrEqual( String attribute, String value ); static FilterBuilder lessThanOrEqual( String attribute, String value ); static FilterBuilder not( FilterBuilder builder ); static FilterBuilder or( FilterBuilder... builders ); static FilterBuilder present( String attribute ); static FilterBuilder startsWith( String attribute, String... parts ); static FilterBuilder endsWith( String attribute, String... parts ); static FilterBuilder contains( String attribute, String... parts ); static FilterBuilder substring( String attribute, String... parts ); @Override String toString(); }
@Test public void testExtensible() { assertEquals( "(cn:caseExactMatch:=Fred Flintstone)", extensible( "cn", "Fred Flintstone" ) .setMatchingRule( "caseExactMatch" ).toString() ); assertEquals( "(cn:=Betty Rubble)", extensible( "cn", "Betty Rubble" ).toString() ); assertEquals( "(sn:dn:2.4.6.8.10:=Barney Rubble)", extensible( "sn", "Barney Rubble" ) .useDnAttributes() .setMatchingRule( "2.4.6.8.10" ).toString() ); assertEquals( "(o:dn:=Ace Industry)", extensible( "o", "Ace Industry" ) .useDnAttributes().toString() ); assertEquals( "(:1.2.3:=Wilma Flintstone)", extensible( "Wilma Flintstone" ) .setMatchingRule( "1.2.3" ).toString() ); assertEquals( "(:dn:2.4.6.8.10:=Dino)", extensible( "Dino" ) .useDnAttributes() .setMatchingRule( "2.4.6.8.10" ).toString() ); }
public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); }
MatchingRuleAssertionFilter extends AbstractFilter { public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); } }
MatchingRuleAssertionFilter extends AbstractFilter { public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); } MatchingRuleAssertionFilter( String attribute, String value, FilterOperator operator ); }
MatchingRuleAssertionFilter extends AbstractFilter { public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); } MatchingRuleAssertionFilter( String attribute, String value, FilterOperator operator ); static MatchingRuleAssertionFilter extensible( String value ); static MatchingRuleAssertionFilter extensible( String attribute, String value ); MatchingRuleAssertionFilter setMatchingRule( String matchingRule ); MatchingRuleAssertionFilter useDnAttributes(); @Override StringBuilder build( StringBuilder builder ); }
MatchingRuleAssertionFilter extends AbstractFilter { public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); } MatchingRuleAssertionFilter( String attribute, String value, FilterOperator operator ); static MatchingRuleAssertionFilter extensible( String value ); static MatchingRuleAssertionFilter extensible( String attribute, String value ); MatchingRuleAssertionFilter setMatchingRule( String matchingRule ); MatchingRuleAssertionFilter useDnAttributes(); @Override StringBuilder build( StringBuilder builder ); }
@Test public void testPresent() { assertEquals( "(objectClass=*)", AttributeDescriptionFilter.present( "objectClass" ).build().toString() ); assertEquals( "(uid=*)", AttributeDescriptionFilter.present( "uid" ).build().toString() ); assertEquals( "(userPassword=*)", AttributeDescriptionFilter.present( "userPassword" ).build().toString() ); assertEquals( "(cn=*)", AttributeDescriptionFilter.present( "cn" ).build().toString() ); }
public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); }
AttributeDescriptionFilter extends AbstractFilter { public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); } }
AttributeDescriptionFilter extends AbstractFilter { public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); } private AttributeDescriptionFilter( String attribute ); }
AttributeDescriptionFilter extends AbstractFilter { public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); } private AttributeDescriptionFilter( String attribute ); static AttributeDescriptionFilter present( String attribute ); @Override StringBuilder build( StringBuilder builder ); }
AttributeDescriptionFilter extends AbstractFilter { public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); } private AttributeDescriptionFilter( String attribute ); static AttributeDescriptionFilter present( String attribute ); @Override StringBuilder build( StringBuilder builder ); }
@Test public void testcharToBytesTwo() { assertEquals( "0xC2 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0080 ) ) ); assertEquals( "0xC3 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x00FF ) ) ); assertEquals( "0xC4 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0100 ) ) ); assertEquals( "0xDF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x07FF ) ) ); }
public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void testJarLdifSchemaLoader() throws Exception { JarLdifSchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager sm = new DefaultSchemaManager( loader ); sm.loadWithDeps( "system" ); assertTrue( sm.getRegistries().getAttributeTypeRegistry().contains( "cn" ) ); assertFalse( sm.getRegistries().getAttributeTypeRegistry().contains( "m-aux" ) ); sm.loadWithDeps( "apachemeta" ); assertTrue( sm.getRegistries().getAttributeTypeRegistry().contains( "m-aux" ) ); }
public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); }
JarLdifSchemaLoader extends AbstractSchemaLoader { public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); } }
JarLdifSchemaLoader extends AbstractSchemaLoader { public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); } JarLdifSchemaLoader(); }
JarLdifSchemaLoader extends AbstractSchemaLoader { public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); } JarLdifSchemaLoader(); @Override List<Entry> loadComparators( Schema... schemas ); @Override List<Entry> loadSyntaxCheckers( Schema... schemas ); @Override List<Entry> loadNormalizers( Schema... schemas ); @Override List<Entry> loadMatchingRules( Schema... schemas ); @Override List<Entry> loadSyntaxes( Schema... schemas ); @Override List<Entry> loadAttributeTypes( Schema... schemas ); @Override List<Entry> loadMatchingRuleUses( Schema... schemas ); @Override List<Entry> loadNameForms( Schema... schemas ); @Override List<Entry> loadDitContentRules( Schema... schemas ); @Override List<Entry> loadDitStructureRules( Schema... schemas ); @Override List<Entry> loadObjectClasses( Schema... schemas ); }
JarLdifSchemaLoader extends AbstractSchemaLoader { public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); } JarLdifSchemaLoader(); @Override List<Entry> loadComparators( Schema... schemas ); @Override List<Entry> loadSyntaxCheckers( Schema... schemas ); @Override List<Entry> loadNormalizers( Schema... schemas ); @Override List<Entry> loadMatchingRules( Schema... schemas ); @Override List<Entry> loadSyntaxes( Schema... schemas ); @Override List<Entry> loadAttributeTypes( Schema... schemas ); @Override List<Entry> loadMatchingRuleUses( Schema... schemas ); @Override List<Entry> loadNameForms( Schema... schemas ); @Override List<Entry> loadDitContentRules( Schema... schemas ); @Override List<Entry> loadDitStructureRules( Schema... schemas ); @Override List<Entry> loadObjectClasses( Schema... schemas ); }
@Test public void testConvertOC() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOC, ou=schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: objectClass\n" + "m-description: An objectClass\n" + "m-obsolete: TRUE\n" + "m-supObjectClass: top\n" + "m-typeObjectClass: ABSTRACT\n" + "m-must: attr1\n" + "m-must: attr2\n" + "m-may: attr3\n" + "m-may: attr4\n\n"; assertEquals( expected, transform( "testOC" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCMinimal() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMinimal, ou=s\n" + " chema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n\n"; assertEquals( expected, transform( "testOCMinimal" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCNoName() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCNoName, ou=sc\n" + " hema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-description: An objectClass\n" + "m-obsolete: TRUE\n" + "m-supObjectClass: top\n" + "m-typeObjectClass: ABSTRACT\n" + "m-must: attr1\n" + "m-must: attr2\n" + "m-may: attr3\n" + "m-may: attr4\n\n"; assertEquals( expected, transform( "testOCNoName" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCAbstract() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCAbstract, ou=\n" + " schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-typeObjectClass: ABSTRACT\n\n"; assertEquals( expected, transform( "testOCAbstract" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCAuxiliary() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCAuxiliary, ou\n" + " =schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-typeObjectClass: AUXILIARY\n\n"; assertEquals( expected, transform( "testOCAuxiliary" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCDesc() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCDesc, ou=sche\n" + " ma\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-description: An objectClass\n\n"; assertEquals( expected, transform( "testOCDesc" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCMayOne() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMayOne, ou=sc\n" + " hema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-may: attr1\n\n"; assertEquals( expected, transform( "testOCMayOne" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCMay2() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMay2, ou=sche\n" + " ma\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-may: attr1\n" + "m-may: attr2\n\n"; assertEquals( expected, transform( "testOCMay2" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCMayMany() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMayMany, ou=s\n" + " chema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-may: attr1\n" + "m-may: attr2\n" + "m-may: attr3\n\n"; assertEquals( expected, transform( "testOCMayMany" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testcharToBytesThree() { assertEquals( "0xE0 0xA0 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0800 ) ) ); assertEquals( "0xE0 0xBF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0FFF ) ) ); assertEquals( "0xE1 0x80 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x1000 ) ) ); assertEquals( "0xEF 0xBF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0xFFFF ) ) ); }
public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput ); }
@Test public void testConvertOCMustOne() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMustOne, ou=s\n" + " chema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-must: attr1\n\n"; assertEquals( expected, transform( "testOCMustOne" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
@Test public void testConvertOCMust2() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMust2, ou=sch\n" + " ema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-must: attr1\n" + "m-must: attr2\n\n"; assertEquals( expected, transform( "testOCMust2" ) ); }
public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }
SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); }