From 79456ab528b185983884c14443e0fe64425874da Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 07 Jul 2016 13:03:32 +0000
Subject: [PATCH] Partial OPENDJ-2625 Convert all code that uses JNDI to use the SDK instead
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
index 0bff591..c2cc5e8 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -46,6 +46,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.LocalizableMessageDescriptor;
+import org.forgerock.opendj.ldap.AuthorizationException;
+import org.forgerock.opendj.ldap.ConnectionException;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.RDN;
@@ -465,6 +467,30 @@
}
/**
+ * Returns a message object for the given IOException.
+ *
+ * @param e
+ * The IOException.
+ * @param hostPort
+ * The hostPort representation of the server we were contacting when the IOException occurred.
+ * @return A message object for the given IOException.
+ */
+ public static LocalizableMessage getMessageForException(IOException e, String hostPort) {
+ String arg = e.getLocalizedMessage();
+ if (Utils.isCertificateException(e)) {
+ return INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(hostPort, arg);
+ } else if (e instanceof org.forgerock.opendj.ldap.AuthenticationException) {
+ return INFO_CANNOT_CONNECT_TO_REMOTE_AUTHENTICATION.get(hostPort, arg);
+ } else if (e instanceof AuthorizationException) {
+ return INFO_CANNOT_CONNECT_TO_REMOTE_PERMISSIONS.get(hostPort, arg);
+ } else if (e instanceof ConnectionException) {
+ return ERR_CANNOT_CONNECT_TO_REMOTE_COMMUNICATION.get(hostPort, arg);
+ } else {
+ return INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(hostPort, arg);
+ }
+ }
+
+ /**
* Returns a localized message for a given properties key an throwable.
*
* @param message
--
Gitblit v1.10.0