| | |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.CoreMessages. |
| | | MSGID_RESULT_CLIENT_SIDE_CONNECT_ERROR; |
| | |
| | | */ |
| | | public class LDAPConnection |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.tools.LDAPConnection"; |
| | | |
| | | // The hostname to connect to. |
| | | private String hostName = null; |
| | |
| | | throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, ce); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", ex); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ex); |
| | | } |
| | | throw new LDAPConnectionException(ex.getMessage(), ex); |
| | | } |
| | | |
| | |
| | | msg = LDAPMessage.decode(asn1Reader.readElement().decodeAsSequence()); |
| | | } catch (Exception ex1) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", ex1); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ex1); |
| | | } |
| | | throw new LDAPConnectionException(ex1.getMessage(), ex1); |
| | | } |
| | | ExtendedResponseProtocolOp res = msg.getExtendedResponseProtocolOp(); |
| | |
| | | throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, ce); |
| | | } catch(Exception ex2) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", ex2); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ex2); |
| | | } |
| | | throw new LDAPConnectionException(ex2.getMessage(), ex2); |
| | | } |
| | | |
| | |
| | | socket.setReuseAddress(true); |
| | | } catch(IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | // It doesn't matter too much if this throws, so ignore it. |
| | | } |
| | | |
| | |
| | | } |
| | | } catch(ClientException ce) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", ce); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ce); |
| | | } |
| | | throw new LDAPConnectionException(ce.getMessage(), ce.getExitCode(), ce); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "connectToHost", ex); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ex); |
| | | } |
| | | throw new LDAPConnectionException(ex.getMessage(), ex); |
| | | } |
| | | |