SssdConfigurationGenerator { public String getConfigurationContent(UserMgmtServer userMgmtServer, String[] groups) { load(); String configContent = new String(getTemplateContent(userMgmtServer.getType())); ArrayList<String[]> replacementList = new ArrayList<>(); replacementList.add(new String[]{"LDAP_GROUP_SEARCH_BASE_VALUE", userMgmtServer.getBaseGroupDn()}); replacementList.add(new String[]{"LDAP_USER_SEARCH_BASE_VALUE", userMgmtServer.getBaseUserDn()}); replacementList.add(new String[]{"LDAP_URI_VALUE", userMgmtServer.getPrimaryUrl()}); replacementList.add(new String[]{"LDAP_DEFAULT_BIND_DN_VALUE", userMgmtServer.getUserName()}); replacementList.add(new String[]{"LDAP_DEFAULT_AUTHTOK_VALUE", userMgmtServer.getPassword()}); StringBuilder stringBuilder = new StringBuilder(); if (groups.length > 1) { stringBuilder.append("(|"); for (String group : groups) { stringBuilder.append("(memberOf=cn=").append(group).append(",").append(userMgmtServer.getBaseGroupDn()).append(')'); } stringBuilder.append(')'); } else { stringBuilder.append("memberOf=cn=").append(groups[0]).append(",").append(userMgmtServer.getBaseGroupDn()); } replacementList.add(new String[]{"LDAP_ACCESS_FILTER_VALUE", stringBuilder.toString()}); for (String[] replacement : replacementList) { configContent = StringUtils.replace(configContent, replacement[0], replacement[1]); } return configContent; }  String getConfigurationContent(UserMgmtServer userMgmtServer, String[] groups); Map<String, String> get(UserMgmtServer.Type type); static final String SSSD_CONF_TEMPLATES; }
@Test public void testGenerate1() throws IOException { UserMgmtServer userMgmtServer = TestUserMgmtServerValidService_Ldap.loadTestData("ad-server.json"); String actual = sssdConfigurationGenerator.getConfigurationContent(userMgmtServer, new String[]{"Administrators", "Users"}); System.out.println(actual); Assert.assertEquals(actual, readResource("sssd.conf.ldaps181")); }