@Override public Entry translate(Entry original, long firstLineNumber) throws LDIFException { Entry entry = original; logger.info("Processing dn {}, line number {}", entry.getDN(), firstLineNumber); entry = translateDN.translate(entry, firstLineNumber); // Test, remove cn attribute from entry if (entry.getAttribute("cn") != null) { entry.removeAttribute("cn"); } // Create group modify from memberOf attribute if (entry.getAttribute("memberOf") != null) { createGroupModify(entry.getDN(), entry.getAttribute("memberOf")); entry.removeAttribute("memberOf"); } String pwd = '"' + getStaticPassword() + '"'; byte[] unicodePwd = null; try { unicodePwd = pwd.getBytes("UTF-16LE"); } catch (UnsupportedEncodingException e) { throw new AssertionError("Should not occur", e); } entry.setAttribute("unicodePwd", unicodePwd); return entry; }
private void createGroupModify(String dn, Attribute attribute) { String[] values = attribute.getValues(); for (String value : values) { value = translateDN.replaceDN(value); Modification mod = new Modification(ModificationType.ADD, "member", dn); LDIFModifyChangeRecord modLdif = new LDIFModifyChangeRecord(value, mod); postProcessingRecords.add(modLdif); } }