LdapUserIdNormalizer { public void normalize(@Nullable LdapEntry entry) { if (entry != null) { final LdapAttribute idAttr = entry.getAttribute(idAttributeName); if (idAttr != null) { final String normalizedId = normalize(idAttr.getStringValue()); idAttr.clear(); idAttr.addStringValue(normalizedId); } } } @Inject  LdapUserIdNormalizer(@Named("ldap.sync.user.attr.id") String idAttributeName); void normalize(@Nullable LdapEntry entry); @Nullable String retrieveAndNormalize(@Nullable LdapEntry entry); @Nullable String normalize(@Nullable String id); String getIdAttributeName();  }
@Test(dataProvider = "identifiersSet") public void shouldNormalizeUserIdentifier(String raw, String normalized) { assertEquals(idNormalizer.normalize(raw), normalized); }
@Test public void shouldModifyLdapEntryByNormalizingIdAttribute() { final String id = "{123}"; final LdapEntry entry = new LdapEntry("uid=user123", new LdapAttribute("uid", id)); idNormalizer.normalize(entry); assertEquals(entry.getAttribute("uid").getStringValue(), "123"); }