@Test public void testPrincipalPrefixIncluded() { String principal = "100.ann-acm"; String result = MapperUtils.buildPrincipalName(principal, "100", "armedia.com"); assertEquals("100.ann-acm@armedia.com", result); }
public static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain) { boolean userDomainIncluded = StringUtils.substringAfterLast(principal, "@").equals(userDomain); if (StringUtils.isNotBlank(userPrefix) && !StringUtils.startsWith(principal, userPrefix)) { principal = String.format("%s.%s", userPrefix, principal); if (userDomainIncluded) { String userIdDomainTruncated = StringUtils.substringBeforeLast(principal, "@"); principal = StringUtils.left(userIdDomainTruncated, 20); principal = String.format("%s@%s", principal, userDomain); } else { principal = StringUtils.left(principal, 20); } } if (StringUtils.isNotBlank(userDomain) && !userDomainIncluded) { principal = String.format("%s@%s", principal, userDomain); } return principal; }
MapperUtils { public static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain) { boolean userDomainIncluded = StringUtils.substringAfterLast(principal, "@").equals(userDomain); if (StringUtils.isNotBlank(userPrefix) && !StringUtils.startsWith(principal, userPrefix)) { principal = String.format("%s.%s", userPrefix, principal); if (userDomainIncluded) { String userIdDomainTruncated = StringUtils.substringBeforeLast(principal, "@"); principal = StringUtils.left(userIdDomainTruncated, 20); principal = String.format("%s@%s", principal, userDomain); } else { principal = StringUtils.left(principal, 20); } } if (StringUtils.isNotBlank(userDomain) && !userDomainIncluded) { principal = String.format("%s@%s", principal, userDomain); } return principal; } }
MapperUtils { public static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain) { boolean userDomainIncluded = StringUtils.substringAfterLast(principal, "@").equals(userDomain); if (StringUtils.isNotBlank(userPrefix) && !StringUtils.startsWith(principal, userPrefix)) { principal = String.format("%s.%s", userPrefix, principal); if (userDomainIncluded) { String userIdDomainTruncated = StringUtils.substringBeforeLast(principal, "@"); principal = StringUtils.left(userIdDomainTruncated, 20); principal = String.format("%s@%s", principal, userDomain); } else { principal = StringUtils.left(principal, 20); } } if (StringUtils.isNotBlank(userDomain) && !userDomainIncluded) { principal = String.format("%s@%s", principal, userDomain); } return principal; }  }
MapperUtils { public static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain) { boolean userDomainIncluded = StringUtils.substringAfterLast(principal, "@").equals(userDomain); if (StringUtils.isNotBlank(userPrefix) && !StringUtils.startsWith(principal, userPrefix)) { principal = String.format("%s.%s", userPrefix, principal); if (userDomainIncluded) { String userIdDomainTruncated = StringUtils.substringBeforeLast(principal, "@"); principal = StringUtils.left(userIdDomainTruncated, 20); principal = String.format("%s@%s", principal, userDomain); } else { principal = StringUtils.left(principal, 20); } } if (StringUtils.isNotBlank(userDomain) && !userDomainIncluded) { principal = String.format("%s@%s", principal, userDomain); } return principal; }  static Function<String, String> getRdnMappingFunction(final String key); static Stream<String> mapAttributes(String[] elements, Function<String, String> mapper); static String getAttribute(DirContextAdapter adapter, String... names); static String stripBaseFromDn(String dn, String base); static String appendToDn(String dn, String... suffixes); static String buildGroupName(String name, String domain); static String buildGroupName(String name, AcmLdapSyncConfig ldapSyncConfig); static String buildUserId(String userId, String domain); static String buildUserId(String userId, AcmLdapSyncConfig ldapSyncConfig); static byte[] encodeUTF16LE(String str); static String generatePassword(int minLength); static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain); }
MapperUtils { public static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain) { boolean userDomainIncluded = StringUtils.substringAfterLast(principal, "@").equals(userDomain); if (StringUtils.isNotBlank(userPrefix) && !StringUtils.startsWith(principal, userPrefix)) { principal = String.format("%s.%s", userPrefix, principal); if (userDomainIncluded) { String userIdDomainTruncated = StringUtils.substringBeforeLast(principal, "@"); principal = StringUtils.left(userIdDomainTruncated, 20); principal = String.format("%s@%s", principal, userDomain); } else { principal = StringUtils.left(principal, 20); } } if (StringUtils.isNotBlank(userDomain) && !userDomainIncluded) { principal = String.format("%s@%s", principal, userDomain); } return principal; }  static Function<String, String> getRdnMappingFunction(final String key); static Stream<String> mapAttributes(String[] elements, Function<String, String> mapper); static String getAttribute(DirContextAdapter adapter, String... names); static String stripBaseFromDn(String dn, String base); static String appendToDn(String dn, String... suffixes); static String buildGroupName(String name, String domain); static String buildGroupName(String name, AcmLdapSyncConfig ldapSyncConfig); static String buildUserId(String userId, String domain); static String buildUserId(String userId, AcmLdapSyncConfig ldapSyncConfig); static byte[] encodeUTF16LE(String str); static String generatePassword(int minLength); static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain); static final Function<DirContextAdapter, LocalDate> convertFileTimeTimestampToDate; static final Function<DirContextAdapter, LocalDate> calculatePasswordExpirationDateByShadowAccount; static final Function<String, BasicAttribute> openLdapPasswordToAttribute; static final Function<String, BasicAttribute> openLdapCurrentPasswordToAttribute; static final Function<String, BasicAttribute> activeDirectoryPasswordToAttribute; }