diff --git a/openam-cli/openam-cli-impl/src/main/java/com/sun/identity/cli/schema/ImportServiceConfiguration.java b/openam-cli/openam-cli-impl/src/main/java/com/sun/identity/cli/schema/ImportServiceConfiguration.java index 083ed90f20..ebe2ca0453 100644 --- a/openam-cli/openam-cli-impl/src/main/java/com/sun/identity/cli/schema/ImportServiceConfiguration.java +++ b/openam-cli/openam-cli-impl/src/main/java/com/sun/identity/cli/schema/ImportServiceConfiguration.java @@ -86,7 +86,7 @@ public class ImportServiceConfiguration extends AuthenticatedCommand { * @param rc Request Context. * @throws CLIException if the request cannot serviced. */ - public void handleRequest(RequestContext rc) + public void handleRequest(RequestContext rc) throws CLIException { super.handleRequest(rc); @@ -98,7 +98,7 @@ public void handleRequest(RequestContext rc) //There is no encryptSecret file } validateEncryptSecret(xmlFile, encryptSecret); - + // disable notification SystemProperties.initializeProperties( Constants.SMS_ENABLE_DB_NOTIFICATION, "true"); @@ -112,11 +112,12 @@ public void handleRequest(RequestContext rc) IOutput outputWriter = getOutputWriter(); try (Connection ldConnection = getLDAPConnection()) { InitializeSystem initSys = CommandManager.initSys; - + SSOToken ssoToken = initSys.getSSOToken(getAdminPassword()); DirectoryServerVendor.Vendor vendor = DirectoryServerVendor.getInstance().query(ldConnection); - if (!vendor.name.equals(DirectoryServerVendor.OPENDJ) + if (!vendor.name.equals(DirectoryServerVendor.WRENDS) + && !vendor.name.equals(DirectoryServerVendor.OPENDJ) && !vendor.name.equals(DirectoryServerVendor.OPENDS) && !vendor.name.equals(DirectoryServerVendor.ODSEE) ) { @@ -124,13 +125,13 @@ public void handleRequest(RequestContext rc) "import-service-configuration-unknown-ds"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } - + if (vendor.name.equals(DirectoryServerVendor.ODSEE)) { loadLDIF(vendor, ldConnection); } String ouServices = "ou=services," + initSys.getRootSuffix(); - + if (this.isOuServicesExists(ssoToken, ouServices)) { System.out.print(getResourceString( "import-service-configuration-prompt-delete") + " "); @@ -171,15 +172,15 @@ public void handleRequest(RequestContext rc) "exception-LDAP-login-failed"), ExitCodes.LDAP_LOGIN_FAILED); } } - + private String getEncKey(String xmlFile) throws IOException { String encKey = null; BufferedReader reader = null; - + try { reader = new BufferedReader(new FileReader(xmlFile)); - + String line = reader.readLine(); String prefix = "" + Constants.ENC_PWD_PROPERTY + "="; while ((line != null) && (encKey == null)) { @@ -206,7 +207,7 @@ private String getEncKey(String xmlFile) } return encKey; } - + private boolean isOuServicesExists(SSOToken ssoToken, String ouServices) throws SMSException, SSOException { CachedSubEntries smsEntry = CachedSubEntries.getInstance( @@ -214,9 +215,9 @@ private boolean isOuServicesExists(SSOToken ssoToken, String ouServices) Set children = smsEntry.getSubEntries(ssoToken, "*"); return (children != null) && !children.isEmpty(); } - + private void deleteOuServicesDescendents( - SSOToken ssoToken, + SSOToken ssoToken, String ouServices ) throws SSOException, SMSException { CachedSubEntries smsEntry = CachedSubEntries.getInstance( @@ -251,8 +252,8 @@ private void deleteOuServicesDescendents( } private void importData( - String xmlFile, - String encryptSecret, + String xmlFile, + String encryptSecret, SSOToken ssoToken ) throws CLIException, SSOException, SMSException, IOException { // set the correct password encryption key. @@ -263,21 +264,21 @@ private void importData( encKey); Crypt.reinitialize(); } - IOutput outputWriter = getOutputWriter(); + IOutput outputWriter = getOutputWriter(); FileInputStream fis = null; try { AMEncryption encryptObj = new JCEEncryption(); ((ConfigurableKey)encryptObj).setPassword(encryptSecret); - + ServiceManager ssm = new ServiceManager(ssoToken); fis = new FileInputStream(xmlFile); ssm.registerServices(fis, encryptObj); - + InitializeSystem initSys = CommandManager.initSys; String instanceName = initSys.getInstanceName(); String serverConfigXML = initSys.getServerConfigXML(); - ServerConfiguration.setServerConfigXML(ssoToken, instanceName, + ServerConfiguration.setServerConfigXML(ssoToken, instanceName, serverConfigXML); outputWriter.printlnMessage(getResourceString( "import-service-configuration-succeeded")); @@ -306,7 +307,7 @@ private Connection getLDAPConnection() throws CLIException { if (isVerbose()) { outputWriter.printlnMessage(getResourceString("import-service-configuration-connecting-to-ds")); } - + try { Connection conn; DSConfigMgr dsCfg = DSConfigMgr.getDSConfigMgr(); @@ -317,7 +318,7 @@ private Connection getLDAPConnection() throws CLIException { throw new CLIException(getResourceString("import-service-configuration-not-connect-to-ds"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED, null); } - + if (isVerbose()) { outputWriter.printlnMessage(getResourceString("import-service-configuration-connected-to-ds")); } diff --git a/openam-core/src/main/java/com/sun/identity/sm/DirectoryServerVendor.java b/openam-core/src/main/java/com/sun/identity/sm/DirectoryServerVendor.java index 1506011e1d..3f6d6500ca 100644 --- a/openam-core/src/main/java/com/sun/identity/sm/DirectoryServerVendor.java +++ b/openam-core/src/main/java/com/sun/identity/sm/DirectoryServerVendor.java @@ -40,13 +40,16 @@ import org.forgerock.opendj.ldif.ConnectionEntryReader; /** - * This singleton attempts to query vendor information of a Directory Server. + * This singleton attempts to query vendor information of a Directory Server. */ public class DirectoryServerVendor { + public static String OPENDS = "opends"; public static String OPENDJ = "opendj"; + public static String WRENDS = "wrends"; public static String ODSEE = "odsee"; + private static String VENDOR_WRENDS = "Wren:DS "; private static String VENDOR_OPENDJ = "OpenDJ "; private static String VENDOR_OPENDS = "OpenDS Directory Server "; private static String VENDOR_SUNDS_5 = "Sun-ONE-Directory/"; @@ -54,23 +57,23 @@ public class DirectoryServerVendor { private static String VENDOR_SUNDS_7 = "Sun-Directory-Server/"; private static String VENDOR_ODSEE_11 = "Oracle Directory Server Enterprise Edition"; private static DirectoryServerVendor instance = new DirectoryServerVendor(); - + private String[] attrs = { "vendorversion", "rootDomainNamingContext", "forestFunctionality"}; private Vendor unknownVendor = new Vendor("unknown", "unknown"); - + private DirectoryServerVendor () { } - + /** * Returns an instance of this class. - * + * * @return an instance of this class. */ public static DirectoryServerVendor getInstance() { return instance; } - + /** * Returns the vendor of Directory Server. * @param conn LDAP connection to the server. @@ -106,7 +109,10 @@ public Vendor query(Connection conn) throws LdapException, SearchResultReference Vendor vendor = unknownVendor; if (result != null) { - if (result.startsWith(VENDOR_OPENDJ)) { + if (result.startsWith(VENDOR_WRENDS)) { + String version = result.substring(VENDOR_WRENDS.length()); + vendor = new Vendor(WRENDS, version); + } else if (result.startsWith(VENDOR_OPENDJ)) { String version = result.substring(VENDOR_OPENDJ.length()); vendor = new Vendor(OPENDJ, version); } else if (result.startsWith(VENDOR_OPENDS)) { @@ -129,17 +135,17 @@ public Vendor query(Connection conn) throws LdapException, SearchResultReference return vendor; } - + public class Vendor { - + public String name; public String version; - + public Vendor(String name, String version) { this.name = name; this.version = version; } - + public String toString() { return name + " " + version; }