| | |
| | | final class ModelUtils { |
| | | |
| | | static final String OBFUSCATED_VALUE = "******"; |
| | | /*void original() { |
| | | |
| | | ArrayList<String> cmdLine = new ArrayList<String>(); |
| | | String setupFile; |
| | | if (Utils.isWindows()) |
| | | { |
| | | setupFile = Installation.WINDOWS_SETUP_FILE_NAME; |
| | | } |
| | | else |
| | | { |
| | | setupFile = Installation.UNIX_SETUP_FILE_NAME; |
| | | } |
| | | cmdLine.add(getInstallDir(userData) + setupFile); |
| | | cmdLine.add("--cli"); |
| | | |
| | | for (String baseDN : getBaseDNs(userData)) |
| | | { |
| | | cmdLine.add("--baseDN"); |
| | | cmdLine.add(baseDN); |
| | | } |
| | | |
| | | switch (userData.getNewSuffixOptions().getType()) |
| | | { |
| | | case CREATE_BASE_ENTRY: |
| | | cmdLine.add("--addBaseEntry"); |
| | | break; |
| | | case IMPORT_AUTOMATICALLY_GENERATED_DATA: |
| | | cmdLine.add("--sampleData"); |
| | | cmdLine.add(String.valueOf( |
| | | userData.getNewSuffixOptions().getNumberEntries())); |
| | | break; |
| | | case IMPORT_FROM_LDIF_FILE: |
| | | for (String ldifFile : userData.getNewSuffixOptions().getLDIFPaths()) |
| | | { |
| | | cmdLine.add("--ldifFile"); |
| | | cmdLine.add(ldifFile); |
| | | } |
| | | String rejectFile = userData.getNewSuffixOptions().getRejectedFile(); |
| | | if (rejectFile != null) |
| | | { |
| | | cmdLine.add("--rejectFile"); |
| | | cmdLine.add(rejectFile); |
| | | } |
| | | String skipFile = userData.getNewSuffixOptions().getSkippedFile(); |
| | | if (skipFile != null) |
| | | { |
| | | cmdLine.add("--skipFile"); |
| | | cmdLine.add(skipFile); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | cmdLine.add("--ldapPort"); |
| | | cmdLine.add(String.valueOf(userData.getServerPort())); |
| | | cmdLine.add("--adminConnectorPort"); |
| | | cmdLine.add(String.valueOf(userData.getAdminConnectorPort())); |
| | | if (userData.getServerJMXPort() != -1) |
| | | { |
| | | cmdLine.add("--jmxPort"); |
| | | cmdLine.add(String.valueOf(userData.getServerJMXPort())); |
| | | } |
| | | cmdLine.add("--rootUserDN"); |
| | | cmdLine.add(userData.getDirectoryManagerDn()); |
| | | cmdLine.add("--rootUserPassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | |
| | | if (Utils.isWindows() && userData.getEnableWindowsService()) |
| | | { |
| | | cmdLine.add("--enableWindowsService"); |
| | | } |
| | | if (userData.getReplicationOptions().getType() == |
| | | DataReplicationOptions.Type.STANDALONE && |
| | | !userData.getStartServer()) |
| | | { |
| | | cmdLine.add("--doNotStart"); |
| | | } |
| | | |
| | | if (userData.getSecurityOptions().getEnableStartTLS()) |
| | | { |
| | | cmdLine.add("--enableStartTLS"); |
| | | } |
| | | if (userData.getSecurityOptions().getEnableSSL()) |
| | | { |
| | | cmdLine.add("--ldapsPort"); |
| | | cmdLine.add(String.valueOf(userData.getSecurityOptions().getSslPort())); |
| | | } |
| | | switch (userData.getSecurityOptions().getCertificateType()) |
| | | { |
| | | case SELF_SIGNED_CERTIFICATE: |
| | | cmdLine.add("--generateSelfSignedCertificate"); |
| | | cmdLine.add("--hostName"); |
| | | cmdLine.add(userData.getHostName()); |
| | | break; |
| | | case JKS: |
| | | cmdLine.add("--useJavaKeystore"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | break; |
| | | case JCEKS: |
| | | cmdLine.add("--useJCEKS"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | break; |
| | | case PKCS12: |
| | | cmdLine.add("--usePkcs12keyStore"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | break; |
| | | case PKCS11: |
| | | cmdLine.add("--usePkcs11Keystore"); |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | cmdLine.add("--no-prompt"); |
| | | cmdLine.add("--noPropertiesFile"); |
| | | return cmdLine; |
| | | |
| | | }*/ |
| | | |
| | | ArrayList<String> getSetupEquivalentCommandLine(final Model configuration) { |
| | | final ArrayList<String> cmdLines = new ArrayList<String>(); |
| | |
| | | && !configuration.isStartingServerAfterSetup()) { |
| | | cmdLines.add("--doNotStart"); |
| | | } |
| | | // Secure ? |
| | | |
| | | if (configuration.isSecure()) { |
| | | if (settings.isTLSEnabled()) { |
| | | cmdLines.add("--enableStartTLS"); |
| | |
| | | cmdLines.add("--ldapsPort"); |
| | | cmdLines.add(String.valueOf(settings.getSSLPortNumber())); |
| | | } |
| | | // Certificate section. |
| | | final Certificate certificate = settings.getCertificate(); |
| | | |
| | | final Certificate certificate = settings.getCertificate(); |
| | | switch (certificate.getType()) { |
| | | case SELF_SIGNED: |
| | | cmdLines.add("--generateSelfSignedCertificate"); |
| | |
| | | cmdLines.add(settings.getHostName()); |
| | | break; |
| | | case JKS: |
| | | cmdLines.add("--useJavaKeystore"); |
| | | cmdLines.add(certificate.getKeyStoreFile().getAbsolutePath()); |
| | | if (certificate.getKeyStorePin() != null) { |
| | | cmdLines.add("--keyStorePassword"); |
| | | cmdLines.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (!certificate.getCertNickName().isEmpty()) { |
| | | cmdLines.add("--certNickname"); |
| | | cmdLines.add(certificate.getCertNickName()); |
| | | } |
| | | appendKeystoreCliOptionsWithPath(cmdLines, "--useJavaKeystore", certificate); |
| | | break; |
| | | case JCEKS: |
| | | cmdLines.add("--useJCEKS"); |
| | | cmdLines.add(certificate.getKeyStoreFile().getAbsolutePath()); |
| | | if (certificate.getKeyStorePin() != null) { |
| | | cmdLines.add("--keyStorePassword"); |
| | | cmdLines.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (!certificate.getCertNickName().isEmpty()) { |
| | | cmdLines.add("--certNickname"); |
| | | cmdLines.add(certificate.getCertNickName()); |
| | | } |
| | | appendKeystoreCliOptionsWithPath(cmdLines, "--useJCEKS", certificate); |
| | | break; |
| | | case PKCS12: |
| | | cmdLines.add("--usePkcs12keyStore"); |
| | | cmdLines.add(certificate.getKeyStoreFile().getAbsolutePath()); |
| | | if (certificate.getKeyStorePin() != null) { |
| | | cmdLines.add("--keyStorePassword"); |
| | | cmdLines.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (!certificate.getCertNickName().isEmpty()) { |
| | | cmdLines.add("--certNickname"); |
| | | cmdLines.add(certificate.getCertNickName()); |
| | | } |
| | | appendKeystoreCliOptionsWithPath(cmdLines, "--usePkcs12keyStore", certificate); |
| | | break; |
| | | case PKCS11: |
| | | cmdLines.add("--usePkcs11Keystore"); |
| | | if (certificate.getKeyStorePin() != null) { |
| | | cmdLines.add("--keyStorePassword"); |
| | | cmdLines.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (!certificate.getCertNickName().isEmpty()) { |
| | | cmdLines.add("--certNickname"); |
| | | cmdLines.add(certificate.getCertNickName()); |
| | | } |
| | | // do not add a file path because this is a hardware store |
| | | appendKeystoreCliOptions(cmdLines, certificate); |
| | | break; |
| | | } |
| | | } |
| | |
| | | cmdLines.add("--noPropertiesFile"); |
| | | return cmdLines; |
| | | } |
| | | |
| | | private void appendKeystoreCliOptionsWithPath(final ArrayList<String> cmdLines, final String cliOption, |
| | | final Certificate certificate) { |
| | | cmdLines.add(cliOption); |
| | | cmdLines.add(certificate.getKeyStoreFile().getAbsolutePath()); |
| | | appendKeystoreCliOptions(cmdLines, certificate); |
| | | } |
| | | |
| | | private void appendKeystoreCliOptions(final ArrayList<String> cmdLines, final Certificate certificate) { |
| | | if (certificate.getKeyStorePin() != null) { |
| | | cmdLines.add("--keyStorePassword"); |
| | | cmdLines.add(OBFUSCATED_VALUE); |
| | | } |
| | | if (!certificate.getCertNickName().isEmpty()) { |
| | | cmdLines.add("--certNickname"); |
| | | cmdLines.add(certificate.getCertNickName()); |
| | | } |
| | | } |
| | | } |