From 3ee2cc20c54dbde5e7a9fceace7134a156ee63d3 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 15 Jun 2007 08:06:11 +0000
Subject: [PATCH] Add the following global options in dsservice to handle client truststore
---
opends/src/server/org/opends/server/admin/client/cli/DsServiceCliMain.java | 44 ++++++++++++++++++++++++++++++++------------
1 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliMain.java b/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliMain.java
index a753bdc..d524df2 100644
--- a/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliMain.java
+++ b/opends/src/server/org/opends/server/admin/client/cli/DsServiceCliMain.java
@@ -223,22 +223,42 @@
String pwd = argParser.getBindPassword(dn,out,err) ;
// Try to connect
- String ldapUrl = "ldap://"+host+":"+port;
-
- InitialLdapContext ctx = null;
- ReturnCode returnCode = ReturnCode.SUCCESSFUL ;
- try
+ InitialLdapContext ctx = null;
+ ReturnCode returnCode = ReturnCode.SUCCESSFUL;
+ if (argParser.useSSL())
{
- ctx = ConnectionUtils.createLdapContext(ldapUrl, dn, pwd,
- ConnectionUtils.getDefaultLDAPTimeout(), null);
+ String ldapsUrl = "ldaps://" + host + ":" + port;
+ try
+ {
+ ctx = ConnectionUtils.createLdapsContext(ldapsUrl,
+ dn, pwd, ConnectionUtils.getDefaultLDAPTimeout(), null,
+ argParser.getTrustManager());
+ }
+ catch (NamingException e)
+ {
+ int msgID = MSGID_ADMIN_CANNOT_CONNECT_TO_ADS;
+ String message = getMessage(msgID, host);
+
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ return ReturnCode.CANNOT_CONNECT_TO_ADS.getReturnCode();
+ }
}
- catch (NamingException e)
+ else
{
- int msgID = MSGID_ADMIN_CANNOT_CONNECT_TO_ADS;
- String message = getMessage(msgID, host);
+ String ldapUrl = "ldap://" + host + ":" + port;
+ try
+ {
+ ctx = ConnectionUtils.createLdapContext(ldapUrl, dn, pwd,
+ ConnectionUtils.getDefaultLDAPTimeout(), null);
+ }
+ catch (NamingException e)
+ {
+ int msgID = MSGID_ADMIN_CANNOT_CONNECT_TO_ADS;
+ String message = getMessage(msgID, host);
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return ReturnCode.CANNOT_CONNECT_TO_ADS.getReturnCode();
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ return ReturnCode.CANNOT_CONNECT_TO_ADS.getReturnCode();
+ }
}
ADSContext adsContext = new ADSContext(ctx);
--
Gitblit v1.10.0