UserUtil { public static String toUserName(String remoteName) { return toUserName("", remoteName); }  static UserManager createUserManagerPostgressImpl(
            AppConfiguration config, DataSource source, DaoFactory daos); static UserManager getDefaultManger(); static void setDefaultManger(UserManager manger); static File createUserHome(String userName, String userHomePath, File allUsersHome); static void createUserSubfolders(File userHome); static void validateUsername(String userName); static String toUserName(String remoteName); static String toUserName(String remotePrefix, String remoteName); static String toHex(byte[] bytes); static void initDefaultAdmin(); static Collection<String> toGroupPid(Collection<Group> groups); static String toGroupPid(Group group); static String toGroupPid(String groupObjectId); static boolean isValidGroupPid(String pid); static String toUserPid(UserProfile user); static final String DEFAULT_ADMIN_USER; }
@Test public void testToUserName() { assertEquals("ka_0_1_2-3_", UserUtil.toUserName("Kač0%1\"2-3.")); assertEquals("u" + String.valueOf("###".hashCode()), UserUtil.toUserName("###")); assertEquals("a", UserUtil.toUserName("$a")); assertEquals("a", UserUtil.toUserName("$***a")); assertEquals("prefix_a", UserUtil.toUserName("prefix", "$a")); assertEquals("prefix_a_b", UserUtil.toUserName("prefix", "$***a+*b")); char[] chars = new char[100]; Arrays.fill(chars, 'A'); String result = UserUtil.toUserName(String.valueOf(chars)); assertTrue(result, UserUtil.isValidUserName(result)); }