Skip to content

Commit 5ecfc30

Browse files
committed
Fix Wren:DS directory detection.
1 parent 8e5fa14 commit 5ecfc30

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

openam-cli/openam-cli-impl/src/main/java/com/sun/identity/cli/schema/ImportServiceConfiguration.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class ImportServiceConfiguration extends AuthenticatedCommand {
8686
* @param rc Request Context.
8787
* @throws CLIException if the request cannot serviced.
8888
*/
89-
public void handleRequest(RequestContext rc)
89+
public void handleRequest(RequestContext rc)
9090
throws CLIException {
9191
super.handleRequest(rc);
9292

@@ -98,7 +98,7 @@ public void handleRequest(RequestContext rc)
9898
//There is no encryptSecret file
9999
}
100100
validateEncryptSecret(xmlFile, encryptSecret);
101-
101+
102102
// disable notification
103103
SystemProperties.initializeProperties(
104104
Constants.SMS_ENABLE_DB_NOTIFICATION, "true");
@@ -112,25 +112,26 @@ public void handleRequest(RequestContext rc)
112112
IOutput outputWriter = getOutputWriter();
113113
try (Connection ldConnection = getLDAPConnection()) {
114114
InitializeSystem initSys = CommandManager.initSys;
115-
115+
116116
SSOToken ssoToken = initSys.getSSOToken(getAdminPassword());
117117

118118
DirectoryServerVendor.Vendor vendor = DirectoryServerVendor.getInstance().query(ldConnection);
119-
if (!vendor.name.equals(DirectoryServerVendor.OPENDJ)
119+
if (!vendor.name.equals(DirectoryServerVendor.WRENDS)
120+
&& !vendor.name.equals(DirectoryServerVendor.OPENDJ)
120121
&& !vendor.name.equals(DirectoryServerVendor.OPENDS)
121122
&& !vendor.name.equals(DirectoryServerVendor.ODSEE)
122123
) {
123124
throw new CLIException(getResourceString(
124125
"import-service-configuration-unknown-ds"),
125126
ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
126127
}
127-
128+
128129
if (vendor.name.equals(DirectoryServerVendor.ODSEE)) {
129130
loadLDIF(vendor, ldConnection);
130131
}
131132

132133
String ouServices = "ou=services," + initSys.getRootSuffix();
133-
134+
134135
if (this.isOuServicesExists(ssoToken, ouServices)) {
135136
System.out.print(getResourceString(
136137
"import-service-configuration-prompt-delete") + " ");
@@ -171,15 +172,15 @@ public void handleRequest(RequestContext rc)
171172
"exception-LDAP-login-failed"), ExitCodes.LDAP_LOGIN_FAILED);
172173
}
173174
}
174-
175+
175176
private String getEncKey(String xmlFile)
176177
throws IOException {
177178
String encKey = null;
178179
BufferedReader reader = null;
179-
180+
180181
try {
181182
reader = new BufferedReader(new FileReader(xmlFile));
182-
183+
183184
String line = reader.readLine();
184185
String prefix = "<Value>" + Constants.ENC_PWD_PROPERTY + "=";
185186
while ((line != null) && (encKey == null)) {
@@ -206,17 +207,17 @@ private String getEncKey(String xmlFile)
206207
}
207208
return encKey;
208209
}
209-
210+
210211
private boolean isOuServicesExists(SSOToken ssoToken, String ouServices)
211212
throws SMSException, SSOException {
212213
CachedSubEntries smsEntry = CachedSubEntries.getInstance(
213214
ssoToken, ouServices);
214215
Set children = smsEntry.getSubEntries(ssoToken, "*");
215216
return (children != null) && !children.isEmpty();
216217
}
217-
218+
218219
private void deleteOuServicesDescendents(
219-
SSOToken ssoToken,
220+
SSOToken ssoToken,
220221
String ouServices
221222
) throws SSOException, SMSException {
222223
CachedSubEntries smsEntry = CachedSubEntries.getInstance(
@@ -251,8 +252,8 @@ private void deleteOuServicesDescendents(
251252
}
252253

253254
private void importData(
254-
String xmlFile,
255-
String encryptSecret,
255+
String xmlFile,
256+
String encryptSecret,
256257
SSOToken ssoToken
257258
) throws CLIException, SSOException, SMSException, IOException {
258259
// set the correct password encryption key.
@@ -263,21 +264,21 @@ private void importData(
263264
encKey);
264265
Crypt.reinitialize();
265266
}
266-
IOutput outputWriter = getOutputWriter();
267+
IOutput outputWriter = getOutputWriter();
267268
FileInputStream fis = null;
268269

269270
try {
270271
AMEncryption encryptObj = new JCEEncryption();
271272
((ConfigurableKey)encryptObj).setPassword(encryptSecret);
272-
273+
273274
ServiceManager ssm = new ServiceManager(ssoToken);
274275
fis = new FileInputStream(xmlFile);
275276
ssm.registerServices(fis, encryptObj);
276-
277+
277278
InitializeSystem initSys = CommandManager.initSys;
278279
String instanceName = initSys.getInstanceName();
279280
String serverConfigXML = initSys.getServerConfigXML();
280-
ServerConfiguration.setServerConfigXML(ssoToken, instanceName,
281+
ServerConfiguration.setServerConfigXML(ssoToken, instanceName,
281282
serverConfigXML);
282283
outputWriter.printlnMessage(getResourceString(
283284
"import-service-configuration-succeeded"));
@@ -306,7 +307,7 @@ private Connection getLDAPConnection() throws CLIException {
306307
if (isVerbose()) {
307308
outputWriter.printlnMessage(getResourceString("import-service-configuration-connecting-to-ds"));
308309
}
309-
310+
310311
try {
311312
Connection conn;
312313
DSConfigMgr dsCfg = DSConfigMgr.getDSConfigMgr();
@@ -317,7 +318,7 @@ private Connection getLDAPConnection() throws CLIException {
317318
throw new CLIException(getResourceString("import-service-configuration-not-connect-to-ds"),
318319
ExitCodes.REQUEST_CANNOT_BE_PROCESSED, null);
319320
}
320-
321+
321322
if (isVerbose()) {
322323
outputWriter.printlnMessage(getResourceString("import-service-configuration-connected-to-ds"));
323324
}

openam-core/src/main/java/com/sun/identity/sm/DirectoryServerVendor.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,40 @@
4040
import org.forgerock.opendj.ldif.ConnectionEntryReader;
4141

4242
/**
43-
* This singleton attempts to query vendor information of a Directory Server.
43+
* This singleton attempts to query vendor information of a Directory Server.
4444
*/
4545
public class DirectoryServerVendor {
46-
public static String OPENDS = "opends";
46+
47+
public static String OPENDS = "opends";
4748
public static String OPENDJ = "opendj";
49+
public static String WRENDS = "wrends";
4850
public static String ODSEE = "odsee";
4951

52+
private static String VENDOR_WRENDS = "Wren:DS ";
5053
private static String VENDOR_OPENDJ = "OpenDJ ";
5154
private static String VENDOR_OPENDS = "OpenDS Directory Server ";
5255
private static String VENDOR_SUNDS_5 = "Sun-ONE-Directory/";
5356
private static String VENDOR_SUNDS_6 = "Sun-Java(tm)-System-Directory/";
5457
private static String VENDOR_SUNDS_7 = "Sun-Directory-Server/";
5558
private static String VENDOR_ODSEE_11 = "Oracle Directory Server Enterprise Edition";
5659
private static DirectoryServerVendor instance = new DirectoryServerVendor();
57-
60+
5861
private String[] attrs = {
5962
"vendorversion", "rootDomainNamingContext", "forestFunctionality"};
6063
private Vendor unknownVendor = new Vendor("unknown", "unknown");
61-
64+
6265
private DirectoryServerVendor () {
6366
}
64-
67+
6568
/**
6669
* Returns an instance of this class.
67-
*
70+
*
6871
* @return an instance of this class.
6972
*/
7073
public static DirectoryServerVendor getInstance() {
7174
return instance;
7275
}
73-
76+
7477
/**
7578
* Returns the vendor of Directory Server.
7679
* @param conn LDAP connection to the server.
@@ -106,7 +109,10 @@ public Vendor query(Connection conn) throws LdapException, SearchResultReference
106109
Vendor vendor = unknownVendor;
107110

108111
if (result != null) {
109-
if (result.startsWith(VENDOR_OPENDJ)) {
112+
if (result.startsWith(VENDOR_WRENDS)) {
113+
String version = result.substring(VENDOR_WRENDS.length());
114+
vendor = new Vendor(WRENDS, version);
115+
} else if (result.startsWith(VENDOR_OPENDJ)) {
110116
String version = result.substring(VENDOR_OPENDJ.length());
111117
vendor = new Vendor(OPENDJ, version);
112118
} else if (result.startsWith(VENDOR_OPENDS)) {
@@ -129,17 +135,17 @@ public Vendor query(Connection conn) throws LdapException, SearchResultReference
129135

130136
return vendor;
131137
}
132-
138+
133139
public class Vendor {
134-
140+
135141
public String name;
136142
public String version;
137-
143+
138144
public Vendor(String name, String version) {
139145
this.name = name;
140146
this.version = version;
141147
}
142-
148+
143149
public String toString() {
144150
return name + " " + version;
145151
}

0 commit comments

Comments
 (0)