private boolean pingLDAP(StringBuilder sb) { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); if (url != null && url.startsWith(LDAPS_URL)) { env.put(LDAP_SOCKET_FACTORY, DEFAULT_SSL_LDAP_SOCKET_FACTORY); } try { new InitialContext(env); appendNL(sb,lsm.getString("ldap.ok", url)); return true; } catch (AuthenticationNotSupportedException anse) { //CR 6944776 //If the server throws this error, it is up //and is configured with Anonymous bind disabled. //Ignore this error while configuring ldap for admin appendNL(sb,lsm.getString("ldap.ok", url)); return true; } catch(Exception e) { appendNL(sb,lsm.getString("ldap.na", url, e.getClass().getName(), e.getMessage())); logger.info(StringUtils.getStackTrace(e)); return false; } }
private void configure(StringBuilder sb) throws TransactionFailure, PropertyVetoException { Server s = ConfigBeansUtilities.getServerNamed(ADMIN_SERVER); String ac = s.getConfigRef(); Config asc = null; //admin server config, that needs the configuration for (Config cfg : allConfigs.getConfig()) { if (cfg.getName().equals(ac)) { asc = cfg; break; } } //following things should happen transactionally - TODO replace SingleConfigCode by ConfigCode ... //createBackupRealm(sb, getAdminRealm(asc.getSecurityService()), getNewRealmName(asc.getSecurityService())); deleteRealm(asc.getSecurityService(), sb); createRealm(asc.getSecurityService(), sb); configureAdminService(asc.getAdminService()); //configure(asc.getSecurityService(), asc.getAdminService(), sb); }