LdapUserIdNormalizer { @Nullable public String retrieveAndNormalize(@Nullable LdapEntry entry) { if (entry == null) { return null; } final LdapAttribute idAttr = entry.getAttribute(idAttributeName); if (idAttr == null) { return null; } return normalize(idAttr.getStringValue()); } @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 public void shouldRetrieveIdValueAndNormalizeIt() { final String id = "{123}"; final LdapEntry entry = new LdapEntry("uid=user123", new LdapAttribute("uid", id)); final String normalizedId = idNormalizer.retrieveAndNormalize(entry); assertEquals(normalizedId, "123"); assertEquals(entry.getAttribute("uid").getStringValue(), "{123}"); }