Partial OPENDJ-2625 Convert all code that uses JNDI to use the SDK instead
Changed bindDn's type from String to DN.
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | |
| | | private final ADSContext adsContext; |
| | | private final ApplicationTrustManager trustManager; |
| | | private final int timeout; |
| | | private final String bindDN; |
| | | private final DN bindDN; |
| | | private final String bindPwd; |
| | | private final Set<ServerDescriptor> servers = new HashSet<>(); |
| | | private final Set<SuffixDescriptor> suffixes = new HashSet<>(); |
| | |
| | | this.adsContext = adsContext; |
| | | this.trustManager = trustManager; |
| | | this.timeout = timeout; |
| | | bindDN = ConnectionUtils.getBindDN(adsContext.getDirContext()); |
| | | bindPwd = ConnectionUtils.getBindPassword(adsContext.getDirContext()); |
| | | ConnectionWrapper conn = adsContext.getConnection(); |
| | | bindDN = conn.getBindDn(); |
| | | bindPwd = conn.getBindPassword(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return new ServerLoader(serverProperties, bindDN, bindPwd, |
| | | trustManager == null ? null : trustManager.createCopy(), |
| | | timeout, |
| | | getPreferredConnections(), getFilter()); |
| | | timeout, getPreferredConnections(), getFilter()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.NoPermissionException; |
| | | import javax.naming.TimeLimitExceededException; |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | |
| | | private ServerDescriptor serverDescriptor; |
| | | private final ApplicationTrustManager trustManager; |
| | | private final int timeout; |
| | | private final String dn; |
| | | private final DN dn; |
| | | private final String pwd; |
| | | private final LinkedHashSet<PreferredConnection> preferredLDAPURLs; |
| | | private final TopologyCacheFilter filter; |
| | |
| | | * to retrieve all the information. |
| | | */ |
| | | public ServerLoader(Map<ServerProperty,Object> serverProperties, |
| | | String dn, String pwd, ApplicationTrustManager trustManager, |
| | | int timeout, |
| | | DN dn, String pwd, ApplicationTrustManager trustManager, int timeout, |
| | | Set<PreferredConnection> preferredLDAPURLs, |
| | | TopologyCacheFilter filter) |
| | | { |
| | |
| | | for (PreferredConnection connection : getLDAPURLsByPreference()) |
| | | { |
| | | lastLdapUrl = connection.getLDAPURL(); |
| | | ConnectionWrapper conn = new ConnectionWrapper(lastLdapUrl, connection.getType(), dn, pwd, timeout, trustManager); |
| | | ConnectionWrapper conn = |
| | | new ConnectionWrapper(lastLdapUrl, connection.getType(), dn.toString(), pwd, timeout, trustManager); |
| | | if (conn.getLdapContext() != null) |
| | | { |
| | | return conn; |
| | |
| | | { |
| | | try |
| | | { |
| | | LdapName theDn = new LdapName(dn); |
| | | LdapName containerDn = |
| | | new LdapName(ADSContext.getAdministratorContainerDN()); |
| | | return theDn.startsWith(containerDn); |
| | | DN containerDn = DN.valueOf(ADSContext.getAdministratorContainerDN()); |
| | | return dn.isSubordinateOrEqualTo(containerDn); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | * issues). We also pass the server descriptor corresponding to the |
| | | * connections to have a proper rendering of the root node. |
| | | * @param server the server descriptor. |
| | | * @param ctxConfiguration the connection to be used to retrieve the data in |
| | | * @param connConfiguration the connection to be used to retrieve the data in |
| | | * the configuration base DNs. |
| | | * @param ctxUserData the connection to be used to retrieve the data in the |
| | | * user base DNs. |
| | |
| | | */ |
| | | public void setConnections( |
| | | ServerDescriptor server, |
| | | ConnectionWrapper ctxConfiguration, |
| | | ConnectionWrapper connConfiguration, |
| | | InitialLdapContext ctxUserData) throws NamingException { |
| | | String rootNodeName; |
| | | if (ctxConfiguration != null) |
| | | if (connConfiguration != null) |
| | | { |
| | | this.connConfig = ctxConfiguration; |
| | | this.ctxConfiguration = connConfig.getLdapContext(); |
| | | this.connConfig = connConfiguration; |
| | | this.ctxUserData = ctxUserData; |
| | | |
| | | this.ctxConfiguration.setRequestControls(getConfigurationRequestControls()); |
| | | connConfig.getLdapContext().setRequestControls(getConfigurationRequestControls()); |
| | | this.ctxUserData.setRequestControls(getRequestControls()); |
| | | rootNodeName = new HostPort(server.getHostname(), connConfig.getHostPort().getPort()).toString(); |
| | | } |
| | |
| | | * @return the connection for accessing the directory configuration. |
| | | */ |
| | | public InitialLdapContext getConfigurationConnection() { |
| | | return ctxConfiguration; |
| | | return connConfig.getLdapContext(); |
| | | } |
| | | |
| | | /** |
| | |
| | | this.followReferrals = followReferrals; |
| | | stopRefresh(); |
| | | removeAllChildNodes(rootNode, true /* Keep suffixes */); |
| | | ctxConfiguration.setRequestControls(getConfigurationRequestControls()); |
| | | connConfig.getLdapContext().setRequestControls(getConfigurationRequestControls()); |
| | | ctxUserData.setRequestControls(getRequestControls()); |
| | | connectionPool.setRequestControls(getRequestControls()); |
| | | startRefresh(null); |
| | |
| | | stopRefresh(); |
| | | removeAllChildNodes(rootNode, true /* Keep suffixes */); |
| | | this.sorted = sorted; |
| | | ctxConfiguration.setRequestControls(getConfigurationRequestControls()); |
| | | connConfig.getLdapContext().setRequestControls(getConfigurationRequestControls()); |
| | | ctxUserData.setRequestControls(getRequestControls()); |
| | | connectionPool.setRequestControls(getRequestControls()); |
| | | startRefresh(null); |
| | |
| | | boolean isConfigurationNode) throws NamingException |
| | | { |
| | | if (node == rootNode) { |
| | | return ctxConfiguration; |
| | | return connConfig.getLdapContext(); |
| | | } |
| | | |
| | | final BasicNode parent = (BasicNode) node.getParent(); |
| | |
| | | { |
| | | return findConnectionForDisplayedEntry(parent, isConfigurationNode); |
| | | } |
| | | return isConfigurationNode ? ctxConfiguration : ctxUserData; |
| | | return isConfigurationNode ? connConfig.getLdapContext() : ctxUserData; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param ctx the connection to be released. |
| | | */ |
| | | void releaseLDAPConnection(InitialLdapContext ctx) { |
| | | if (ctx != this.ctxConfiguration && ctx != this.ctxUserData) |
| | | if (ctx != connConfig.getLdapContext() && ctx != this.ctxUserData) |
| | | { |
| | | // Thus it comes from the connection pool |
| | | connectionPool.releaseConnection(ctx); |
| | |
| | | */ |
| | | LDAPURL findUrlForLocalEntry(BasicNode node) { |
| | | if (node == rootNode) { |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), "", isSSL(ctxConfiguration)); |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), "", isSSL(connConfig.getLdapContext())); |
| | | } |
| | | final BasicNode parent = (BasicNode) node.getParent(); |
| | | if (parent != null) |
| | |
| | | final LDAPURL parentUrl = findUrlForDisplayedEntry(parent); |
| | | return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN()); |
| | | } |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), isSSL(ctxConfiguration)); |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), isSSL(connConfig.getLdapContext())); |
| | | } |
| | | |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | |
| | | { |
| | | try |
| | | { |
| | | InitialLdapContext ctx = getInfo().getConnection().getLdapContext(); |
| | | ConnectionWrapper conn = getInfo().getConnection(); |
| | | InitialLdapContext ctx1 = controller.getConfigurationConnection(); |
| | | boolean setConnection = ctx != ctx1; |
| | | boolean setConnection = conn.getLdapContext() != ctx1; |
| | | updateNumSubordinateHacker(desc); |
| | | if (setConnection) |
| | | { |
| | | if (getInfo().getUserDataDirContext() == null) |
| | | { |
| | | InitialLdapContext ctxUserData = |
| | | createUserDataDirContext(ConnectionUtils.getBindDN(ctx), ConnectionUtils.getBindPassword(ctx)); |
| | | createUserDataDirContext(conn.getBindDn().toString(), conn.getBindPassword()); |
| | | getInfo().setUserDataDirContext(ctxUserData); |
| | | } |
| | | final NamingException[] fNe = { null }; |
| | |
| | | throw ne; |
| | | } |
| | | |
| | | ApplicationTrustManager.Cause cause = getInfo().getTrustManager().getLastRefusedCause(); |
| | | ApplicationTrustManager trustManager = getInfo().getTrustManager(); |
| | | ApplicationTrustManager.Cause cause = trustManager.getLastRefusedCause(); |
| | | |
| | | logger.info(LocalizableMessage.raw("Certificate exception cause: " + cause)); |
| | | UserDataCertificateException.Type excType = null; |
| | |
| | | p = -1; |
| | | } |
| | | final UserDataCertificateException udce = new UserDataCertificateException( |
| | | null, INFO_CERTIFICATE_EXCEPTION.get(h, p), ne, h, p, getInfo().getTrustManager().getLastRefusedChain(), |
| | | getInfo().getTrustManager().getLastRefusedAuthType(), excType); |
| | | null, INFO_CERTIFICATE_EXCEPTION.get(h, p), ne, h, p, trustManager.getLastRefusedChain(), |
| | | trustManager.getLastRefusedAuthType(), excType); |
| | | |
| | | if (SwingUtilities.isEventDispatchThread()) |
| | | { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.ConfigurationFramework; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.client.ReplicationDomainCfgClient; |
| | | import org.forgerock.opendj.server.config.client.ReplicationServerCfgClient; |
| | | import org.forgerock.opendj.server.config.client.ReplicationSynchronizationProviderCfgClient; |
| | |
| | | logger.info(LocalizableMessage.raw("Updating references in: " + server.getHostPort(true))); |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_REMOVING_REFERENCES.get(server.getHostPort(true)))); |
| | | |
| | | String dn = ADSContext.getAdministratorDN(uData.getAdminUID()); |
| | | DN dn = DN.valueOf(ADSContext.getAdministratorDN(uData.getAdminUID())); |
| | | String pwd = uData.getAdminPwd(); |
| | | try (ConnectionWrapper connWrapper = |
| | | getRemoteConnection(server, dn, pwd, getConnectTimeout(), new LinkedHashSet<PreferredConnection>())) |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | | import org.opends.admin.ads.TopologyCacheException; |
| | |
| | | * @return the InitialLdapContext to the remote server. |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | protected ConnectionWrapper getRemoteConnection(ServerDescriptor server, String dn, String pwd, int timeout, |
| | | protected ConnectionWrapper getRemoteConnection(ServerDescriptor server, DN dn, String pwd, int timeout, |
| | | Set<PreferredConnection> cnx) throws ApplicationException |
| | | { |
| | | Map<ADSContext.ServerProperty, Object> adsProperties = |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.client.BackendCfgClient; |
| | | import org.forgerock.opendj.server.config.server.BackendCfg; |
| | | import org.opends.admin.ads.ADSContext; |
| | |
| | | } |
| | | server.setAdsProperties(adsProperties); |
| | | } |
| | | return getRemoteConnection(server, auth.getDn(), auth.getPwd(), getConnectTimeout(), getPreferredConnections()); |
| | | return getRemoteConnection(server, DN.valueOf(auth.getDn()), auth.getPwd(), getConnectTimeout(), |
| | | getPreferredConnections()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | } |
| | | String bindDn = conn.getBindDn().toString(); |
| | | DN bindDn = conn.getBindDn(); |
| | | String pwd = conn.getBindPassword(); |
| | | for (ServerDescriptor s : serversToUpdate) |
| | | { |
| | |
| | | * configuration. |
| | | */ |
| | | private void removeReferencesInServer(ServerDescriptor server, |
| | | String replicationServer, String bindDn, String pwd, |
| | | String replicationServer, DN bindDn, String pwd, |
| | | Collection<String> baseDNs, boolean updateReplicationServers, |
| | | Set<PreferredConnection> cnx) |
| | | throws ReplicationCliException |
| | |
| | | |
| | | private ConnectionWrapper getConnection(TopologyCache cache, ServerDescriptor server) throws NamingException |
| | | { |
| | | String dn = getBindDN(cache.getAdsContext().getDirContext()); |
| | | String pwd = getBindPassword(cache.getAdsContext().getDirContext()); |
| | | ConnectionWrapper conn = cache.getAdsContext().getConnection(); |
| | | DN dn = conn.getBindDn(); |
| | | String pwd = conn.getBindPassword(); |
| | | TopologyCacheFilter filter = new TopologyCacheFilter(); |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.setSearchBaseDNInformation(false); |