| | |
| | | import javax.net.ssl.KeyManager; |
| | | import javax.net.ssl.TrustManager; |
| | | import java.util.LinkedHashSet; |
| | | import javax.net.ssl.SSLException; |
| | | import javax.net.ssl.SSLHandshakeException; |
| | | |
| | | |
| | | /** |
| | |
| | | // The connection parameters command builder. |
| | | private CommandBuilder contextCommandBuilder; |
| | | |
| | | // This CLI is always using the administration connector with SSL |
| | | private boolean alwaysSSL = false; |
| | | |
| | | /** |
| | | * Creates a new LDAP management context factory. |
| | | * |
| | | * @param alwaysSSL If true, always use the SSL connection type. In this case, |
| | | * the arguments useSSL and startTLS are not present. |
| | | */ |
| | | public LDAPManagementContextFactory() { |
| | | // No implementation required. |
| | | public LDAPManagementContextFactory(boolean alwaysSSL) { |
| | | this.alwaysSSL = alwaysSSL; |
| | | } |
| | | |
| | | /** |
| | |
| | | continue ; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | } |
| | | if (e.getRootCause() != null) { |
| | | if (e.getRootCause().getCause() != null) { |
| | | if (((e.getRootCause().getCause() |
| | | instanceof OpendsCertificateException)) || |
| | | (e.getRootCause() instanceof SSLHandshakeException)) { |
| | | Message message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get( |
| | | hostName, String.valueOf(portNumber)); |
| | | throw new ClientException( |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | if (e.getRootCause() instanceof SSLException) { |
| | | Message message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | hostName, String.valueOf(portNumber)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | Message message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, String.valueOf(portNumber)); |
| | | hostName, String.valueOf(portNumber)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void registerGlobalArguments(SubCommandArgumentParser parser) |
| | | throws ArgumentException { |
| | | // Create the global arguments. |
| | | secureArgsList = new SecureConnectionCliArgs(); |
| | | secureArgsList = new SecureConnectionCliArgs(alwaysSSL); |
| | | LinkedHashSet<Argument> args = secureArgsList.createGlobalArguments(); |
| | | |
| | | |