| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.admin.ads.util.ApplicationKeyManager; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | |
| | | private boolean useSSL; |
| | | private boolean useStartTLS; |
| | | private String hostName; |
| | | private String bindDN; |
| | | private String providedBindDN; |
| | | private DN bindDN; |
| | | private DN providedBindDN; |
| | | private String adminUID; |
| | | private String providedAdminUID; |
| | | private String bindPassword; |
| | |
| | | return INFO_LDAPAUTH_PASSWORD_PROMPT.get(adminUID); |
| | | } |
| | | |
| | | protected String getAdminOrBindDN() |
| | | protected DN getAdminOrBindDN() |
| | | { |
| | | if (providedBindDN != null) |
| | | { |
| | |
| | | } |
| | | else if (providedAdminUID != null) |
| | | { |
| | | return getAdministratorDN(providedAdminUID).toString(); |
| | | return getAdministratorDN(providedAdminUID); |
| | | } |
| | | else if (bindDN != null) |
| | | { |
| | |
| | | } |
| | | else if (adminUID != null) |
| | | { |
| | | return getAdministratorDN(adminUID).toString(); |
| | | return getAdministratorDN(adminUID); |
| | | } |
| | | |
| | | return null; |
| | |
| | | } |
| | | else |
| | | { |
| | | addArgToCommandBuilder(copySecureArgsList.getBindDnArg(), getBindDN()); |
| | | addArgToCommandBuilder(copySecureArgsList.getBindDnArg(), getBindDN().toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | final Argument bindDn = secureArgsList.getBindDnArg(); |
| | | |
| | | state.providedAdminUID = (isAdminUidArgVisible() && adminUid.isPresent()) ? adminUid.getValue() : null; |
| | | state.providedBindDN = ((useAdminOrBindDn || !isAdminUidArgVisible()) && bindDn.isPresent()) ? bindDn.getValue() |
| | | : null; |
| | | boolean useBindDnArg = (useAdminOrBindDn || !isAdminUidArgVisible()) && bindDn.isPresent(); |
| | | state.providedBindDN = useBindDnArg ? DN.valueOf(bindDn.getValue()) : null; |
| | | state.adminUID = !useKeyManager() ? adminUid.getValue() : null; |
| | | state.bindDN = !useKeyManager() ? bindDn.getValue() : null; |
| | | state.bindDN = !useKeyManager() ? DN.valueOf(bindDn.getValue()) : null; |
| | | } |
| | | |
| | | private void resolveCredentialPassword() throws ArgumentException |
| | |
| | | app.println(); |
| | | if (useAdminOrBindDn) |
| | | { |
| | | String def = state.adminUID != null ? state.adminUID : state.bindDN; |
| | | String def = state.adminUID != null ? state.adminUID : state.bindDN.toString(); |
| | | String v = app.readValidatedInput(INFO_LDAP_CONN_GLOBAL_ADMINISTRATOR_OR_BINDDN_PROMPT.get(def), callback); |
| | | if (isDN(v)) |
| | | { |
| | | state.bindDN = v; |
| | | state.providedBindDN = v; |
| | | DN dn = DN.valueOf(v); |
| | | state.bindDN = dn; |
| | | state.providedBindDN = dn; |
| | | state.adminUID = null; |
| | | state.providedAdminUID = null; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | state.bindDN = app.readValidatedInput(INFO_LDAP_CONN_PROMPT_BIND_DN.get(state.bindDN), callback); |
| | | state.bindDN = DN.valueOf(app.readValidatedInput(INFO_LDAP_CONN_PROMPT_BIND_DN.get(state.bindDN), callback)); |
| | | state.providedBindDN = state.bindDN; |
| | | } |
| | | } |
| | |
| | | * |
| | | * @return bind DN for connections |
| | | */ |
| | | public String getBindDN() |
| | | public DN getBindDN() |
| | | { |
| | | if (useAdminOrBindDn) |
| | | { |
| | |
| | | } |
| | | else if (isAdminUidArgVisible()) |
| | | { |
| | | return getAdministratorDN(state.adminUID).toString(); |
| | | return getAdministratorDN(state.adminUID); |
| | | } |
| | | else |
| | | { |
| | |
| | | * the Map containing the file and the password to bind. |
| | | */ |
| | | public void initializeGlobalArguments(String hostName, int port, |
| | | String adminUid, String bindDn, String bindPwd, |
| | | String adminUid, DN bindDn, String bindPwd, |
| | | LinkedHashMap<String, String> pwdFile) |
| | | { |
| | | resetConnectionArguments(); |
| | |
| | | } |
| | | if (bindDn != null) |
| | | { |
| | | secureArgsList.getBindDnArg().addValue(bindDn); |
| | | secureArgsList.getBindDnArg().addValue(bindDn.toString()); |
| | | secureArgsList.getBindDnArg().setPresent(true); |
| | | } |
| | | if (pwdFile != null) |
| | |
| | | * @return the explicitly provided bind DN from the user (interactively or |
| | | * through the argument). |
| | | */ |
| | | public String getProvidedBindDN() |
| | | public DN getProvidedBindDN() |
| | | { |
| | | return state.providedBindDN; |
| | | } |