use DN in dsreplication
ConnectionWrapper and EnableReplicationUserData now use DN.
Utils.getAdministratorDN() now returns a DN.
| | |
| | | * The UID to be used to generate the DN. |
| | | * @return The DN of the administrator for the given UID. |
| | | */ |
| | | public static String getAdministratorDN(String uid) { |
| | | return RDN.valueOf("cn=" + uid) + ",cn=Administrators, cn=admin data"; |
| | | public static DN getAdministratorDN(String uid) { |
| | | return DN.valueOf(RDN.valueOf("cn=" + uid) + ",cn=Administrators, cn=admin data"); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws NamingException |
| | | * If an error occurs |
| | | */ |
| | | public ConnectionWrapper(String ldapUrl, Type connectionType, String bindDn, String bindPwd, int connectTimeout, |
| | | public ConnectionWrapper(String ldapUrl, Type connectionType, DN bindDn, String bindPwd, int connectTimeout, |
| | | TrustManager trustManager) throws NamingException |
| | | { |
| | | this(toHostPort(ldapUrl), connectionType, bindDn, bindPwd, connectTimeout, trustManager, null); |
| | |
| | | * @throws NamingException |
| | | * If an error occurs |
| | | */ |
| | | public ConnectionWrapper(HostPort hostPort, Type connectionType, String bindDn, String bindPwd, int connectTimeout, |
| | | public ConnectionWrapper(HostPort hostPort, Type connectionType, DN bindDn, String bindPwd, int connectTimeout, |
| | | TrustManager trustManager) throws NamingException |
| | | { |
| | | this(hostPort, connectionType, bindDn, bindPwd, connectTimeout, trustManager, null); |
| | |
| | | */ |
| | | public ConnectionWrapper(ConnectionWrapper other) throws NamingException |
| | | { |
| | | this(other.hostPort, other.connectionType, other.bindDn.toString(), other.bindPwd, other.connectTimeout, |
| | | this(other.hostPort, other.connectionType, other.bindDn, other.bindPwd, other.connectTimeout, |
| | | other.trustManager, other.keyManager); |
| | | } |
| | | |
| | |
| | | * @throws NamingException |
| | | * If an error occurs |
| | | */ |
| | | public ConnectionWrapper(HostPort hostPort, PreferredConnection.Type connectionType, String bindDn, String bindPwd, |
| | | public ConnectionWrapper(HostPort hostPort, PreferredConnection.Type connectionType, DN bindDn, String bindPwd, |
| | | int connectTimeout, TrustManager trustManager, KeyManager keyManager) throws NamingException |
| | | { |
| | | this.hostPort = hostPort; |
| | | this.connectionType = connectionType; |
| | | this.bindDn = DN.valueOf(bindDn); |
| | | this.bindDn = bindDn; |
| | | this.bindPwd = bindPwd; |
| | | this.connectTimeout = connectTimeout; |
| | | this.trustManager = trustManager; |
| | |
| | | connection = buildConnection(); |
| | | } |
| | | |
| | | private static Options toOptions(Type connectionType, String bindDn, String bindPwd, long connectTimeout, |
| | | private static Options toOptions(Type connectionType, DN bindDn, String bindPwd, long connectTimeout, |
| | | TrustManager trustManager, KeyManager keyManager) throws NamingException |
| | | { |
| | | final boolean isStartTls = START_TLS.equals(connectionType); |
| | |
| | | .set(SSL_USE_STARTTLS, isStartTls); |
| | | } |
| | | SimpleBindRequest request = bindDn != null && bindPwd != null |
| | | ? newSimpleBindRequest(bindDn, bindPwd.toCharArray()) |
| | | ? newSimpleBindRequest(bindDn.toString(), bindPwd.toCharArray()) |
| | | : newSimpleBindRequest(); // anonymous bind |
| | | options.set(AUTHN_BIND_REQUEST, request); |
| | | return options; |
| | |
| | | { |
| | | lastLdapUrl = connection.getLDAPURL(); |
| | | ConnectionWrapper conn = |
| | | new ConnectionWrapper(lastLdapUrl, connection.getType(), dn.toString(), pwd, timeout, trustManager); |
| | | new ConnectionWrapper(lastLdapUrl, connection.getType(), dn, pwd, timeout, trustManager); |
| | | if (conn.getLdapContext() != null) |
| | | { |
| | | return conn; |
| | |
| | | { |
| | | final HostPort hostPort = new HostPort(ldapUrl.getHost(), ldapUrl.getPort()); |
| | | final Type connectiontype = isSecureLDAPUrl(ldapUrl) ? LDAPS : LDAP; |
| | | return new ConnectionWrapper(hostPort, connectiontype, ar.dn.toString(), ar.password, |
| | | return new ConnectionWrapper(hostPort, connectiontype, ar.dn, ar.password, |
| | | getConnectTimeout(), getTrustManager(), getKeyManager()); |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.ConfigurationFramework; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | |
| | | private String ldapsURL; |
| | | private String adminConnectorURL; |
| | | private String localAdminConnectorURL; |
| | | private String lastWorkingBindDN; |
| | | private DN lastWorkingBindDN; |
| | | private String lastWorkingBindPwd; |
| | | private String lastRemoteHostName; |
| | | private String lastRemoteAdministrationURL; |
| | |
| | | this.connWrapper = connWrapper; |
| | | if (connWrapper != null) |
| | | { |
| | | lastWorkingBindDN = connWrapper.getBindDn().toString(); |
| | | lastWorkingBindDN = connWrapper.getBindDn(); |
| | | lastWorkingBindPwd = connWrapper.getBindPassword(); |
| | | lastRemoteHostName = connWrapper.getHostPort().getHost(); |
| | | lastRemoteAdministrationURL = connWrapper.getLdapUrl(); |
| | |
| | | { |
| | | if (getInfo().getUserDataDirContext() == null) |
| | | { |
| | | ConnectionWrapper connUserData = |
| | | createUserDataDirContext(conn.getBindDn().toString(), conn.getBindPassword()); |
| | | ConnectionWrapper connUserData = createUserDataDirContext(conn.getBindDn(), conn.getBindPassword()); |
| | | getInfo().setUserDataDirContext(connUserData); |
| | | } |
| | | final NamingException[] fNe = { null }; |
| | |
| | | * @throws ConfigReadException |
| | | * if an error occurs reading the configuration. |
| | | */ |
| | | private ConnectionWrapper createUserDataDirContext(final String bindDN, final String bindPassword) |
| | | private ConnectionWrapper createUserDataDirContext(final DN bindDN, final String bindPassword) |
| | | throws NamingException, IOException, ConfigReadException |
| | | { |
| | | createdUserDataConn = null; |
| | |
| | | * @param bindPassword |
| | | * the bind password. |
| | | */ |
| | | private void handleCertificateException(UserDataCertificateException ce, String bindDN, String bindPassword) |
| | | private void handleCertificateException(UserDataCertificateException ce, DN bindDN, String bindPassword) |
| | | throws NamingException, IOException, ConfigReadException |
| | | { |
| | | CertificateDialog dlg = new CertificateDialog(null, ce); |
| | |
| | | ConnectionWrapper conn = null; |
| | | try |
| | | { |
| | | DN bindDn = DN.valueOf(dn.getText()); |
| | | String bindPwd = String.valueOf(pwd.getPassword()); |
| | | if (isLocal) |
| | | { |
| | | usedUrl = info.getAdminConnectorURL(); |
| | | conn = Utilities.getAdminDirContext(info, dn.getText(), String.valueOf(pwd.getPassword())); |
| | | conn = Utilities.getAdminDirContext(info, bindDn, bindPwd); |
| | | } |
| | | else |
| | | { |
| | | HostPort hostPort = new HostPort(hostName.getText().trim(), Integer.valueOf(port.getText().trim())); |
| | | usedUrl = ConnectionUtils.getLDAPUrl(hostPort, true); |
| | | conn = new ConnectionWrapper(hostPort, LDAPS, dn.getText(), String.valueOf(pwd.getPassword()), |
| | | conn = new ConnectionWrapper(hostPort, LDAPS, bindDn, bindPwd, |
| | | info.getConnectTimeout(), info.getTrustManager()); |
| | | checkVersion(conn); |
| | | } |
| | |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.datamodel.ConfigReadException; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.util.BackgroundTask; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | |
| | | ConnectionWrapper conn = null; |
| | | try |
| | | { |
| | | usedUrl = getInfo().getAdminConnectorURL(); |
| | | conn = Utilities.getAdminDirContext(getInfo(), dn.getText(), String.valueOf(pwd.getPassword())); |
| | | ControlPanelInfo info = getInfo(); |
| | | usedUrl = info.getAdminConnectorURL(); |
| | | conn = Utilities.getAdminDirContext(info, DN.valueOf(dn.getText()), String.valueOf(pwd.getPassword())); |
| | | |
| | | if (getInfo().getConnection() != null) |
| | | { |
| | | try |
| | | { |
| | | getInfo().getConnection().close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | if (getInfo().getUserDataDirContext() != null) |
| | | { |
| | | try |
| | | { |
| | | getInfo().getUserDataDirContext().close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | org.forgerock.util.Utils.closeSilently(info.getConnection(), info.getUserDataDirContext()); |
| | | try |
| | | { |
| | | Thread.sleep(500); |
| | |
| | | INFO_CTRL_PANEL_READING_CONFIGURATION_SUMMARY.get()); |
| | | } |
| | | }); |
| | | getInfo().setConnection(conn); |
| | | getInfo().setUserDataDirContext(null); |
| | | getInfo().regenerateDescriptor(); |
| | | info.setConnection(conn); |
| | | info.setUserDataDirContext(null); |
| | | info.regenerateDescriptor(); |
| | | return conn; |
| | | } catch (Throwable t) |
| | | { |
| | |
| | | * or the provided credentials do not have enough rights. |
| | | * @throws ConfigReadException if there is an error reading the configuration. |
| | | */ |
| | | public static ConnectionWrapper getAdminDirContext(ControlPanelInfo controlInfo, String bindDN, String pwd) |
| | | public static ConnectionWrapper getAdminDirContext(ControlPanelInfo controlInfo, DN bindDN, String pwd) |
| | | throws NamingException, IOException, ConfigReadException |
| | | { |
| | | return createConnection(controlInfo.getAdminConnectorURL(), LDAPS, bindDN, pwd, controlInfo); |
| | |
| | | * @throws ConfigReadException if there is an error reading the configuration. |
| | | */ |
| | | public static ConnectionWrapper getUserDataDirContext(ControlPanelInfo controlInfo, |
| | | String bindDN, String pwd) throws NamingException, IOException, ConfigReadException |
| | | DN bindDN, String pwd) throws NamingException, IOException, ConfigReadException |
| | | { |
| | | if (controlInfo.connectUsingStartTLS()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private static ConnectionWrapper createConnection(String usedUrl, Type connectionType, String bindDN, String bindPwd, |
| | | private static ConnectionWrapper createConnection(String usedUrl, Type connectionType, DN bindDN, String bindPwd, |
| | | ControlPanelInfo controlInfo) throws NamingException, IOException, ConfigReadException |
| | | { |
| | | if (usedUrl == null) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | 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.TopologyCache; |
| | |
| | | int port = 389; |
| | | String adminUid = userData.getAdminUID(); |
| | | String pwd = userData.getAdminPwd(); |
| | | String dn = ADSContext.getAdministratorDN(adminUid).toString(); |
| | | DN dn = ADSContext.getAdministratorDN(adminUid); |
| | | |
| | | info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN); |
| | | String adminConnectorUrl = info.getAdminConnectorURL(); |
| | |
| | | |
| | | 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.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | |
| | | info.regenerateDescriptor(); |
| | | ConfigFromFile conf = new ConfigFromFile(); |
| | | conf.readConfiguration(); |
| | | String dn = ADSContext.getAdministratorDN(tfUid.getText()).toString(); |
| | | DN dn = ADSContext.getAdministratorDN(tfUid.getText()); |
| | | String pwd = tfPwd.getText(); |
| | | info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN); |
| | | usedUrl = info.getAdminConnectorURL(); |
| | |
| | | private ConnectionWrapper createConnection(AuthenticationData auth) throws NamingException |
| | | { |
| | | String ldapUrl = auth.getLdapUrl(); |
| | | String dn = auth.getDn(); |
| | | DN dn = DN.valueOf(auth.getDn()); |
| | | String pwd = auth.getPwd(); |
| | | |
| | | if (auth.useSecureConnection()) |
| | |
| | | |
| | | DataReplicationOptions.Type type = (DataReplicationOptions.Type) qs.getFieldValue(FieldName.REPLICATION_OPTIONS); |
| | | String host = qs.getFieldStringValue(FieldName.REMOTE_SERVER_HOST); |
| | | String dn = qs.getFieldStringValue(FieldName.REMOTE_SERVER_DN); |
| | | String dnStr = qs.getFieldStringValue(FieldName.REMOTE_SERVER_DN); |
| | | DN dn = dnStr != null ? DN.valueOf(dnStr) : null; |
| | | String pwd = qs.getFieldStringValue(FieldName.REMOTE_SERVER_PWD); |
| | | |
| | | if (type != DataReplicationOptions.Type.STANDALONE) |
| | |
| | | port = Integer.parseInt(sPort); |
| | | // Try to connect |
| | | boolean[] globalAdmin = { hasGlobalAdministrators }; |
| | | String[] effectiveDn = { dn }; |
| | | DN[] effectiveDn = { dn }; |
| | | try |
| | | { |
| | | updateUserDataWithADS(host, port, dn, pwd, qs, errorMsgs, globalAdmin, effectiveDn); |
| | |
| | | { |
| | | AuthenticationData auth = new AuthenticationData(); |
| | | auth.setHostPort(new HostPort("".equals(host) ? null : host, port != null ? port : 0)); |
| | | auth.setDn(dn); |
| | | auth.setDn(dn.toString()); |
| | | auth.setPwd(pwd); |
| | | auth.setUseSecureConnection(true); |
| | | |
| | |
| | | return replicationPort; |
| | | } |
| | | |
| | | private void checkRemoteHostPortDnAndPwd(String host, String sPort, String dn, String pwd, QuickSetup qs, |
| | | private void checkRemoteHostPortDnAndPwd(String host, String sPort, DN dn, String pwd, QuickSetup qs, |
| | | List<LocalizableMessage> errorMsgs) |
| | | { |
| | | // Check host |
| | |
| | | } |
| | | |
| | | // Check dn |
| | | if (dn == null || dn.length() == 0) |
| | | if (dn == null || dn.size() == 0) |
| | | { |
| | | errorMsgs.add(INFO_EMPTY_REMOTE_DN.get()); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true); |
| | |
| | | } |
| | | } |
| | | |
| | | private void updateUserDataWithADS(String host, int port, String dn, String pwd, QuickSetup qs, |
| | | List<LocalizableMessage> errorMsgs, boolean[] hasGlobalAdministrators, String[] effectiveDn) |
| | | private void updateUserDataWithADS(String host, int port, DN dn, String pwd, QuickSetup qs, |
| | | List<LocalizableMessage> errorMsgs, boolean[] hasGlobalAdministrators, DN[] effectiveDn) |
| | | throws UserDataException |
| | | { |
| | | host = getHostNameForLdapUrl(host); |
| | |
| | | } |
| | | } |
| | | |
| | | private ConnectionWrapper newConnectionWrapper(String dn, String pwd, String[] effectiveDn, HostPort hostPort, |
| | | private ConnectionWrapper newConnectionWrapper(DN dn, String pwd, DN[] effectiveDn, HostPort hostPort, |
| | | ApplicationTrustManager trustManager) throws Throwable |
| | | { |
| | | try |
| | |
| | | throw t; |
| | | } |
| | | // Try using a global administrator |
| | | dn = ADSContext.getAdministratorDN(dn).toString(); |
| | | dn = ADSContext.getAdministratorDN(dn.toString()); |
| | | effectiveDn[0] = dn; |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | |
| | | { |
| | | UserData uData = getUserData(); |
| | | HostPort hostPort = new HostPort(uData.getHostName(), uData.getAdminConnectorPort()); |
| | | String dn = uData.getDirectoryManagerDn(); |
| | | DN dn = DN.valueOf(uData.getDirectoryManagerDn()); |
| | | String pwd = uData.getDirectoryManagerPwd(); |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), null); |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.admin.ads.util.PreferredConnection.Type; |
| | | import org.opends.quicksetup.Application; |
| | |
| | | { |
| | | timeout = application.getUserData().getConnectTimeout(); |
| | | } |
| | | try (ConnectionWrapper conn = new ConnectionWrapper(ldapUrl, Type.LDAPS, userDn, userPw, timeout, null)) |
| | | try (ConnectionWrapper conn = |
| | | new ConnectionWrapper(ldapUrl, Type.LDAPS, DN.valueOf(userDn), userPw, timeout, null)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * This class is used to store the information provided by the user to |
| | | * disable replication. It is required because when we are in interactive |
| | |
| | | */ |
| | | public class DisableReplicationUserData extends MonoServerReplicationUserData |
| | | { |
| | | private String bindDn; |
| | | private DN bindDn; |
| | | private String bindPwd; |
| | | private boolean disableReplicationServer; |
| | | private boolean disableAll; |
| | |
| | | * @return the bind DN to be used to connect to the server if no Administrator |
| | | * has been defined. |
| | | */ |
| | | public String getBindDn() |
| | | public DN getBindDn() |
| | | { |
| | | return bindDn; |
| | | } |
| | |
| | | * has been defined. |
| | | * @param bindDn the bind DN to be used. |
| | | */ |
| | | public void setBindDn(String bindDn) |
| | | public void setBindDn(DN bindDn) |
| | | { |
| | | this.bindDn = bindDn; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.HostPort; |
| | | |
| | | /** |
| | |
| | | static final class EnableReplicationServerData |
| | | { |
| | | private HostPort hostPort = new HostPort(null, 0); |
| | | private String bindDn; |
| | | private DN bindDn; |
| | | private String pwd; |
| | | private int replicationPort; |
| | | private boolean secureReplication; |
| | |
| | | * |
| | | * @return the dn to be used to bind to this server |
| | | */ |
| | | String getBindDn() |
| | | DN getBindDn() |
| | | { |
| | | return bindDn; |
| | | } |
| | |
| | | * @param bindDn |
| | | * the dn to be used to bind to this server |
| | | */ |
| | | void setBindDn(String bindDn) |
| | | void setBindDn(DN bindDn) |
| | | { |
| | | this.bindDn = bindDn; |
| | | } |
| | |
| | | private ConnectionWrapper newConnectionWrapper( |
| | | LDAPConnectionConsoleInteraction ci, Type connType, int connectTimeout) throws NamingException |
| | | { |
| | | return new ConnectionWrapper(getHostPort(ci), connType, ci.getBindDN(), ci.getBindPassword(), |
| | | return new ConnectionWrapper(getHostPort(ci), connType, DN.valueOf(ci.getBindDN()), ci.getBindPassword(), |
| | | connectTimeout, ci.getTrustManager(), ci.getKeyManager()); |
| | | } |
| | | |
| | |
| | | return createAdministrativeConnection(uData, getAdministratorDN(uData.getAdminUid())); |
| | | } |
| | | |
| | | private ConnectionWrapper createAdministrativeConnection(MonoServerReplicationUserData uData, final String bindDn) |
| | | private ConnectionWrapper createAdministrativeConnection(MonoServerReplicationUserData uData, final DN bindDn) |
| | | { |
| | | try |
| | | { |
| | |
| | | private void setConnectionDetails(EnableReplicationServerData serverData, LDAPConnectionConsoleInteraction serverCI) |
| | | { |
| | | serverData.setHostPort(getHostPort2(serverCI)); |
| | | serverData.setBindDn(serverCI.getBindDN()); |
| | | serverData.setBindDn(DN.valueOf(serverCI.getBindDN())); |
| | | serverData.setPwd(serverCI.getBindPassword()); |
| | | } |
| | | |
| | |
| | | final String adminUid = sourceServerCI.getProvidedAdminUID(); |
| | | uData.setHostPort(getHostPort2(sourceServerCI)); |
| | | uData.setAdminUid(adminUid); |
| | | uData.setBindDn(sourceServerCI.getProvidedBindDN()); |
| | | uData.setBindDn(DN.valueOf(sourceServerCI.getProvidedBindDN())); |
| | | uData.setAdminPwd(sourceServerCI.getBindPassword()); |
| | | |
| | | if (adminUid != null) |
| | |
| | | { |
| | | initialize(uData); |
| | | |
| | | final String adminDN = getAdministratorDN(uData.getAdminUid()); |
| | | final DN adminDN = getAdministratorDN(uData.getAdminUid()); |
| | | final String adminPwd = uData.getAdminPwd(); |
| | | setConnectionDetails(uData.getServer1(), argParser.server1, adminDN, adminPwd); |
| | | setConnectionDetails(uData.getServer2(), argParser.server2, adminDN, adminPwd); |
| | |
| | | } |
| | | |
| | | private void setConnectionDetails( |
| | | EnableReplicationServerData server, ServerArgs args, String adminDN, String adminPwd) |
| | | EnableReplicationServerData server, ServerArgs args, DN adminDN, String adminPwd) |
| | | { |
| | | server.setHostPort(new HostPort( |
| | | getValueOrDefault(args.hostNameArg), getValueOrDefault(args.portArg))); |
| | |
| | | } |
| | | else |
| | | { |
| | | server.setBindDn(getValueOrDefault(args.bindDnArg)); |
| | | server.setBindDn(DN.valueOf(getValueOrDefault(args.bindDnArg))); |
| | | server.setPwd(pwd); |
| | | } |
| | | } |
| | | |
| | | private boolean canConnectWithCredentials(EnableReplicationServerData server, String adminDN, String adminPwd) |
| | | private boolean canConnectWithCredentials(EnableReplicationServerData server, DN adminDN, String adminPwd) |
| | | { |
| | | try (ConnectionWrapper validCredentials = new ConnectionWrapper( |
| | | server.getHostPort(), connectionType, adminDN, adminPwd, getConnectTimeout(), getTrustManager(sourceServerCI))) |
| | |
| | | { |
| | | uData.setBaseDNs(toDNs(argParser.getBaseDNs())); |
| | | String adminUid = argParser.getAdministratorUID(); |
| | | String bindDn = argParser.getBindDNToDisable(); |
| | | DN bindDn = DN.valueOf(argParser.getBindDNToDisable()); |
| | | if (bindDn == null && adminUid == null) |
| | | { |
| | | adminUid = argParser.getAdministratorUIDOrDefault(); |
| | |
| | | private ReplicationCliReturnCode disableReplication(DisableReplicationUserData uData) |
| | | { |
| | | print(formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get())); |
| | | String bindDn = uData.getAdminUid() != null |
| | | DN bindDn = uData.getAdminUid() != null |
| | | ? getAdministratorDN(uData.getAdminUid()) |
| | | : uData.getBindDn(); |
| | | |
| | |
| | | boolean forceAddBindPwdFile1 = false; |
| | | if (useAdminUID) |
| | | { |
| | | String bindDN1 = server1.getBindDn(); |
| | | DN bindDN1 = server1.getBindDn(); |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN1 != null |
| | | && adminUID != null |
| | | && !areDnsEqual(getAdministratorDN(adminUID), bindDN1)) |
| | | && !getAdministratorDN(adminUID).equals(bindDN1)) |
| | | { |
| | | forceAddBindDN1 = true; |
| | | forceAddBindPwdFile1 = existsArg(firstServerCommandBuilder, OPTION_LONG_BINDPWD_FILE); |
| | |
| | | boolean forceAddBindPwdFile2 = false; |
| | | if (useAdminUID) |
| | | { |
| | | String bindDN2 = server2.getBindDn(); |
| | | DN bindDN2 = server2.getBindDn(); |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN2 != null |
| | | && adminUID != null |
| | | && !areDnsEqual(getAdministratorDN(adminUID), bindDN2)) |
| | | && !getAdministratorDN(adminUID).equals(bindDN2)) |
| | | { |
| | | forceAddBindDN2 = true; |
| | | forceAddBindPwdFile2 = existsArg(interactionBuilder, OPTION_LONG_BINDPWD_FILE); |
| | |
| | | .defaultValue("cn=Directory Manager") |
| | | .valuePlaceholder(INFO_BINDDN_PLACEHOLDER.get()) |
| | | .buildArgument(); |
| | | bindDN.addValue(uData.getServer1().getBindDn()); |
| | | bindDN.addValue(uData.getServer1().getBindDn().toString()); |
| | | return bindDN; |
| | | } |
| | | |
| | |
| | | .defaultValue("cn=Directory Manager") |
| | | .valuePlaceholder(INFO_BINDDN_PLACEHOLDER.get()) |
| | | .buildArgument(); |
| | | bindDN.addValue(uData.getServer2().getBindDn()); |
| | | bindDN.addValue(uData.getServer2().getBindDn().toString()); |
| | | return bindDN; |
| | | } |
| | | |
| | |
| | | |
| | | if (managementContextOpened) |
| | | { |
| | | try (ConnectionWrapper conn = Utilities.getAdminDirContext(controlInfo, bindDn, bindPwd)) |
| | | try (ConnectionWrapper conn = Utilities.getAdminDirContext(controlInfo, DN.valueOf(bindDn), bindPwd)) |
| | | { |
| | | controlInfo.setConnection(conn); |
| | | controlInfo.regenerateDescriptor(); |
| | |
| | | |
| | | import javax.net.ssl.KeyManager; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.admin.ads.util.ApplicationKeyManager; |
| | |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.SelectableCertificateKeyManager; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.CommandBuilder; |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | | import com.forgerock.opendj.cli.Menu; |
| | | import com.forgerock.opendj.cli.MenuBuilder; |
| | | import com.forgerock.opendj.cli.MenuResult; |
| | |
| | | } |
| | | else if (providedAdminUID != null) |
| | | { |
| | | return getAdministratorDN(providedAdminUID); |
| | | return getAdministratorDN(providedAdminUID).toString(); |
| | | } |
| | | else if (bindDN != null) |
| | | { |
| | |
| | | } |
| | | else if (adminUID != null) |
| | | { |
| | | return getAdministratorDN(adminUID); |
| | | return getAdministratorDN(adminUID).toString(); |
| | | } |
| | | |
| | | return null; |
| | |
| | | } |
| | | else if (isAdminUidArgVisible()) |
| | | { |
| | | return getAdministratorDN(state.adminUID); |
| | | return getAdministratorDN(state.adminUID).toString(); |
| | | } |
| | | else |
| | | { |