Search in sources :

Example 46 with BooleanArgument

use of com.unboundid.util.args.BooleanArgument in project ldapsdk by pingidentity.

the class ManageCertificates method doChangeKeystorePassword.

/**
 * Performs the necessary processing for the change-keystore-password
 * subcommand.
 *
 * @return  A result code that indicates whether the processing completed
 *          successfully.
 */
@NotNull()
private ResultCode doChangeKeystorePassword() {
    // Get the values of a number of configured arguments.
    final String keystoreType;
    final File keystorePath = getKeystorePath();
    try {
        keystoreType = inferKeystoreType(keystorePath);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    final char[] currentKeystorePassword;
    try {
        currentKeystorePassword = getKeystorePassword(keystorePath, "current");
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    final char[] newKeystorePassword;
    try {
        newKeystorePassword = getKeystorePassword(keystorePath, "new");
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    // Get the keystore.
    final KeyStore keystore;
    try {
        keystore = getKeystore(keystoreType, keystorePath, currentKeystorePassword);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    // Generate the keytool arguments to use to change the keystore password.
    final BooleanArgument displayKeytoolCommandArgument = subCommandParser.getBooleanArgument("display-keytool-command");
    if ((displayKeytoolCommandArgument != null) && displayKeytoolCommandArgument.isPresent()) {
        final ArrayList<String> keytoolArguments = new ArrayList<>(30);
        keytoolArguments.add("-storepasswd");
        keytoolArguments.add("-keystore");
        keytoolArguments.add(keystorePath.getAbsolutePath());
        keytoolArguments.add("-storetype");
        keytoolArguments.add(keystoreType);
        keytoolArguments.add("-storepass");
        keytoolArguments.add("*****REDACTED*****");
        keytoolArguments.add("-new");
        keytoolArguments.add("*****REDACTED*****");
        displayKeytoolCommand(keytoolArguments);
    }
    // Rewrite the keystore with the new password.
    try {
        writeKeystore(keystore, keystorePath, newKeystorePassword);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    wrapOut(0, WRAP_COLUMN, INFO_MANAGE_CERTS_CHANGE_KS_PW_SUCCESSFUL.get(keystorePath.getAbsolutePath()));
    return ResultCode.SUCCESS;
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) BooleanArgument(com.unboundid.util.args.BooleanArgument) ArrayList(java.util.ArrayList) ASN1BitString(com.unboundid.asn1.ASN1BitString) File(java.io.File) KeyStore(java.security.KeyStore) NotNull(com.unboundid.util.NotNull)

Example 47 with BooleanArgument

use of com.unboundid.util.args.BooleanArgument in project ldapsdk by pingidentity.

the class ManageCertificates method doExportCertificate.

/**
 * Performs the necessary processing for the export-certificate subcommand.
 *
 * @return  A result code that indicates whether the processing completed
 *          successfully.
 */
@NotNull()
private ResultCode doExportCertificate() {
    // Get the values of a number of configured arguments.
    final StringArgument aliasArgument = subCommandParser.getStringArgument("alias");
    final String alias = aliasArgument.getValue();
    final BooleanArgument exportChainArgument = subCommandParser.getBooleanArgument("export-certificate-chain");
    final boolean exportChain = ((exportChainArgument != null) && exportChainArgument.isPresent());
    final BooleanArgument separateFilePerCertificateArgument = subCommandParser.getBooleanArgument("separate-file-per-certificate");
    final boolean separateFilePerCertificate = ((separateFilePerCertificateArgument != null) && separateFilePerCertificateArgument.isPresent());
    boolean exportPEM = true;
    final StringArgument outputFormatArgument = subCommandParser.getStringArgument("output-format");
    if ((outputFormatArgument != null) && outputFormatArgument.isPresent()) {
        final String format = outputFormatArgument.getValue().toLowerCase();
        if (format.equals("der") || format.equals("binary") || format.equals("bin")) {
            exportPEM = false;
        }
    }
    File outputFile = null;
    final FileArgument outputFileArgument = subCommandParser.getFileArgument("output-file");
    if ((outputFileArgument != null) && outputFileArgument.isPresent()) {
        outputFile = outputFileArgument.getValue();
    }
    if ((outputFile == null) && (!exportPEM)) {
        wrapErr(0, WRAP_COLUMN, ERR_MANAGE_CERTS_EXPORT_CERT_NO_FILE_WITH_DER.get());
        return ResultCode.PARAM_ERROR;
    }
    final String keystoreType;
    final File keystorePath = getKeystorePath();
    try {
        keystoreType = inferKeystoreType(keystorePath);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    final char[] keystorePassword;
    try {
        keystorePassword = getKeystorePassword(keystorePath);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    final BooleanArgument displayKeytoolCommandArgument = subCommandParser.getBooleanArgument("display-keytool-command");
    if ((displayKeytoolCommandArgument != null) && displayKeytoolCommandArgument.isPresent()) {
        final ArrayList<String> keytoolArgs = new ArrayList<>(10);
        keytoolArgs.add("-list");
        keytoolArgs.add("-keystore");
        keytoolArgs.add(keystorePath.getAbsolutePath());
        keytoolArgs.add("-storetype");
        keytoolArgs.add(keystoreType);
        if (keystorePassword != null) {
            keytoolArgs.add("-storepass");
            keytoolArgs.add("*****REDACTED*****");
        }
        keytoolArgs.add("-alias");
        keytoolArgs.add(alias);
        if (exportPEM) {
            keytoolArgs.add("-rfc");
        }
        if (outputFile != null) {
            keytoolArgs.add("-file");
            keytoolArgs.add(outputFile.getAbsolutePath());
        }
        displayKeytoolCommand(keytoolArgs);
    }
    // Get the keystore.
    final KeyStore keystore;
    try {
        keystore = getKeystore(keystoreType, keystorePath, keystorePassword);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        wrapErr(0, WRAP_COLUMN, le.getMessage());
        return le.getResultCode();
    }
    // Get the certificates to export.  If the --export-certificate-chain
    // argument was provided, this can be multiple certificates.  Otherwise, it
    // there will only be one.
    DN missingIssuerDN = null;
    final X509Certificate[] certificatesToExport;
    if (exportChain) {
        try {
            final AtomicReference<DN> missingIssuerRef = new AtomicReference<>();
            certificatesToExport = getCertificateChain(alias, keystore, missingIssuerRef);
            missingIssuerDN = missingIssuerRef.get();
        } catch (final LDAPException le) {
            Debug.debugException(le);
            wrapErr(0, WRAP_COLUMN, le.getMessage());
            return le.getResultCode();
        }
    } else {
        try {
            final Certificate cert = keystore.getCertificate(alias);
            if (cert == null) {
                certificatesToExport = new X509Certificate[0];
            } else {
                certificatesToExport = new X509Certificate[] { new X509Certificate(cert.getEncoded()) };
            }
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, ERR_MANAGE_CERTS_EXPORT_CERT_ERROR_GETTING_CERT.get(alias, keystorePath.getAbsolutePath()));
            e.printStackTrace(getErr());
            return ResultCode.LOCAL_ERROR;
        }
    }
    if (certificatesToExport.length == 0) {
        wrapErr(0, WRAP_COLUMN, ERR_MANAGE_CERTS_EXPORT_CERT_NO_CERT_WITH_ALIAS.get(alias, keystorePath.getAbsolutePath()));
        return ResultCode.PARAM_ERROR;
    }
    // Get a PrintStream to use for the output.
    int fileCounter = 1;
    String filename = null;
    PrintStream printStream;
    if (outputFile == null) {
        printStream = getOut();
    } else {
        try {
            if ((certificatesToExport.length > 1) && separateFilePerCertificate) {
                filename = outputFile.getAbsolutePath() + '.' + fileCounter;
            } else {
                filename = outputFile.getAbsolutePath();
            }
            printStream = new PrintStream(filename);
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, ERR_MANAGE_CERTS_EXPORT_CERT_ERROR_OPENING_OUTPUT.get(outputFile.getAbsolutePath()));
            e.printStackTrace(getErr());
            return ResultCode.LOCAL_ERROR;
        }
    }
    try {
        for (final X509Certificate certificate : certificatesToExport) {
            try {
                if (separateFilePerCertificate && (certificatesToExport.length > 1)) {
                    if (fileCounter > 1) {
                        printStream.close();
                        filename = outputFile.getAbsolutePath() + '.' + fileCounter;
                        printStream = new PrintStream(filename);
                    }
                    fileCounter++;
                }
                if (exportPEM) {
                    writePEMCertificate(printStream, certificate.getX509CertificateBytes());
                } else {
                    printStream.write(certificate.getX509CertificateBytes());
                }
            } catch (final Exception e) {
                Debug.debugException(e);
                wrapErr(0, WRAP_COLUMN, ERR_MANAGE_CERTS_EXPORT_CERT_ERROR_WRITING_CERT.get(alias, certificate.getSubjectDN()));
                e.printStackTrace(getErr());
                return ResultCode.LOCAL_ERROR;
            }
            if (outputFile != null) {
                out();
                wrapOut(0, WRAP_COLUMN, INFO_MANAGE_CERTS_EXPORT_CERT_EXPORT_SUCCESSFUL.get(filename));
                printCertificate(certificate, "", false);
            }
        }
    } finally {
        printStream.flush();
        if (outputFile != null) {
            printStream.close();
        }
    }
    if (missingIssuerDN != null) {
        err();
        wrapErr(0, WRAP_COLUMN, WARN_MANAGE_CERTS_EXPORT_CERT_MISSING_CERT_IN_CHAIN.get(missingIssuerDN, keystorePath.getAbsolutePath()));
        return ResultCode.NO_SUCH_OBJECT;
    }
    return ResultCode.SUCCESS;
}
Also used : PrintStream(java.io.PrintStream) BooleanArgument(com.unboundid.util.args.BooleanArgument) ArrayList(java.util.ArrayList) DN(com.unboundid.ldap.sdk.DN) AtomicReference(java.util.concurrent.atomic.AtomicReference) ASN1BitString(com.unboundid.asn1.ASN1BitString) FileArgument(com.unboundid.util.args.FileArgument) KeyStore(java.security.KeyStore) ArgumentException(com.unboundid.util.args.ArgumentException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) LDAPException(com.unboundid.ldap.sdk.LDAPException) IOException(java.io.IOException) StringArgument(com.unboundid.util.args.StringArgument) LDAPException(com.unboundid.ldap.sdk.LDAPException) File(java.io.File) Certificate(java.security.cert.Certificate) NotNull(com.unboundid.util.NotNull)

Example 48 with BooleanArgument

use of com.unboundid.util.args.BooleanArgument in project ldapsdk by pingidentity.

the class InMemoryDirectoryServerTool method addToolArguments.

/**
 * {@inheritDoc}
 */
@Override()
public void addToolArguments(@NotNull final ArgumentParser parser) throws ArgumentException {
    portArgument = new IntegerArgument('p', "port", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PORT.get(), INFO_MEM_DS_TOOL_ARG_DESC_PORT.get(), 0, 65_535);
    portArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    parser.addArgument(portArgument);
    useSSLArgument = new BooleanArgument('Z', "useSSL", INFO_MEM_DS_TOOL_ARG_DESC_USE_SSL.get());
    useSSLArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    useSSLArgument.addLongIdentifier("use-ssl", true);
    parser.addArgument(useSSLArgument);
    useStartTLSArgument = new BooleanArgument('q', "useStartTLS", INFO_MEM_DS_TOOL_ARG_DESC_USE_START_TLS.get());
    useStartTLSArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    useStartTLSArgument.addLongIdentifier("use-starttls", true);
    useStartTLSArgument.addLongIdentifier("use-start-tls", true);
    parser.addArgument(useStartTLSArgument);
    keyStorePathArgument = new FileArgument('K', "keyStorePath", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_KEY_STORE_PATH.get(), true, true, true, false);
    keyStorePathArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    keyStorePathArgument.addLongIdentifier("key-store-path", true);
    parser.addArgument(keyStorePathArgument);
    keyStorePasswordArgument = new StringArgument('W', "keyStorePassword", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PASSWORD.get(), INFO_MEM_DS_TOOL_ARG_DESC_KEY_STORE_PW.get());
    keyStorePasswordArgument.setSensitive(true);
    keyStorePasswordArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    keyStorePasswordArgument.addLongIdentifier("keyStorePIN", true);
    keyStorePasswordArgument.addLongIdentifier("key-store-password", true);
    keyStorePasswordArgument.addLongIdentifier("key-store-pin", true);
    parser.addArgument(keyStorePasswordArgument);
    keyStoreTypeArgument = new StringArgument(null, "keyStoreType", false, 1, "{type}", INFO_MEM_DS_TOOL_ARG_DESC_KEY_STORE_TYPE.get(), CryptoHelper.KEY_STORE_TYPE_JKS);
    keyStoreTypeArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    keyStoreTypeArgument.addLongIdentifier("keyStoreFormat", true);
    keyStoreTypeArgument.addLongIdentifier("key-store-type", true);
    keyStoreTypeArgument.addLongIdentifier("key-store-format", true);
    parser.addArgument(keyStoreTypeArgument);
    generateSelfSignedCertificateArgument = new BooleanArgument(null, "generateSelfSignedCertificate", 1, INFO_MEM_DS_TOOL_ARG_DESC_SELF_SIGNED_CERT.get());
    generateSelfSignedCertificateArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    generateSelfSignedCertificateArgument.addLongIdentifier("useSelfSignedCertificate", true);
    generateSelfSignedCertificateArgument.addLongIdentifier("selfSignedCertificate", true);
    generateSelfSignedCertificateArgument.addLongIdentifier("generate-self-signed-certificate", true);
    generateSelfSignedCertificateArgument.addLongIdentifier("use-self-signed-certificate", true);
    generateSelfSignedCertificateArgument.addLongIdentifier("self-signed-certificate", true);
    parser.addArgument(generateSelfSignedCertificateArgument);
    trustStorePathArgument = new FileArgument('P', "trustStorePath", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_TRUST_STORE_PATH.get(), true, true, true, false);
    trustStorePathArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    trustStorePathArgument.addLongIdentifier("trust-store-path", true);
    parser.addArgument(trustStorePathArgument);
    trustStorePasswordArgument = new StringArgument('T', "trustStorePassword", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PASSWORD.get(), INFO_MEM_DS_TOOL_ARG_DESC_TRUST_STORE_PW.get());
    trustStorePasswordArgument.setSensitive(true);
    trustStorePasswordArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    trustStorePasswordArgument.addLongIdentifier("trustStorePIN", true);
    trustStorePasswordArgument.addLongIdentifier("trust-store-password", true);
    trustStorePasswordArgument.addLongIdentifier("trust-store-pin", true);
    parser.addArgument(trustStorePasswordArgument);
    trustStoreTypeArgument = new StringArgument(null, "trustStoreType", false, 1, "{type}", INFO_MEM_DS_TOOL_ARG_DESC_TRUST_STORE_TYPE.get(), CryptoHelper.KEY_STORE_TYPE_JKS);
    trustStoreTypeArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    trustStoreTypeArgument.addLongIdentifier("trustStoreFormat", true);
    trustStoreTypeArgument.addLongIdentifier("trust-store-type", true);
    trustStoreTypeArgument.addLongIdentifier("trust-store-format", true);
    parser.addArgument(trustStoreTypeArgument);
    sslClientAuthPolicy = new StringArgument(null, "sslClientAuthPolicy", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_SSL_CLIENT_AUTH_POLICY.get(), INFO_MEM_DS_TOOL_ARG_DESC_SSL_CLIENT_AUTH_POLICY.get(), StaticUtils.setOf(SSL_CLIENT_AUTH_POLICY_PROHIBITED, SSL_CLIENT_AUTH_POLICY_OPTIONAL, SSL_CLIENT_AUTH_POLICY_REQUIRED), SSL_CLIENT_AUTH_POLICY_PROHIBITED);
    sslClientAuthPolicy.addLongIdentifier("ssl-client-auth-policy", true);
    sslClientAuthPolicy.addLongIdentifier("sslClientAuthenticationPolicy", true);
    sslClientAuthPolicy.addLongIdentifier("ssl-client-authentication-policy", true);
    sslClientAuthPolicy.addLongIdentifier("sslClientCertificatePolicy", true);
    sslClientAuthPolicy.addLongIdentifier("ssl-client-certificate-policy", true);
    sslClientAuthPolicy.addLongIdentifier("sslClientCertPolicy", true);
    sslClientAuthPolicy.addLongIdentifier("ssl-client-cert-policy", true);
    sslClientAuthPolicy.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    parser.addArgument(sslClientAuthPolicy);
    maxConcurrentConnectionsArgument = new IntegerArgument(null, "maxConcurrentConnections", false, 1, null, INFO_MEM_DS_TOOL_ARG_DESC_MAX_CONNECTIONS.get(), 1, Integer.MAX_VALUE, Integer.MAX_VALUE);
    maxConcurrentConnectionsArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    maxConcurrentConnectionsArgument.addLongIdentifier("maximumConcurrentConnections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("maxConnections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("maximumConnections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("max-concurrent-connections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("maximum-concurrent-connections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("max-connections", true);
    maxConcurrentConnectionsArgument.addLongIdentifier("maximum-connections", true);
    parser.addArgument(maxConcurrentConnectionsArgument);
    dontStartArgument = new BooleanArgument(null, "dontStart", INFO_MEM_DS_TOOL_ARG_DESC_DONT_START.get());
    dontStartArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_CONNECTIVITY.get());
    dontStartArgument.setHidden(true);
    dontStartArgument.addLongIdentifier("doNotStart", true);
    dontStartArgument.addLongIdentifier("dont-start", true);
    dontStartArgument.addLongIdentifier("do-not-start", true);
    parser.addArgument(dontStartArgument);
    baseDNArgument = new DNArgument('b', "baseDN", true, 0, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_BASE_DN.get(), INFO_MEM_DS_TOOL_ARG_DESC_BASE_DN.get());
    baseDNArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    baseDNArgument.addLongIdentifier("base-dn", true);
    parser.addArgument(baseDNArgument);
    ldifFileArgument = new FileArgument('l', "ldifFile", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_LDIF_FILE.get(), true, true, true, false);
    ldifFileArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    ldifFileArgument.addLongIdentifier("ldif-file", true);
    parser.addArgument(ldifFileArgument);
    additionalBindDNArgument = new DNArgument('D', "additionalBindDN", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_BIND_DN.get(), INFO_MEM_DS_TOOL_ARG_DESC_ADDITIONAL_BIND_DN.get());
    additionalBindDNArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    additionalBindDNArgument.addLongIdentifier("additional-bind-dn", true);
    parser.addArgument(additionalBindDNArgument);
    additionalBindPasswordArgument = new StringArgument('w', "additionalBindPassword", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PASSWORD.get(), INFO_MEM_DS_TOOL_ARG_DESC_ADDITIONAL_BIND_PW.get());
    additionalBindPasswordArgument.setSensitive(true);
    additionalBindPasswordArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    additionalBindPasswordArgument.addLongIdentifier("additional-bind-password", true);
    parser.addArgument(additionalBindPasswordArgument);
    useDefaultSchemaArgument = new BooleanArgument('s', "useDefaultSchema", INFO_MEM_DS_TOOL_ARG_DESC_USE_DEFAULT_SCHEMA.get());
    useDefaultSchemaArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    useDefaultSchemaArgument.addLongIdentifier("use-default-schema", true);
    parser.addArgument(useDefaultSchemaArgument);
    useSchemaFileArgument = new FileArgument('S', "useSchemaFile", false, 0, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_USE_SCHEMA_FILE.get(), true, true, false, false);
    useSchemaFileArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    useSchemaFileArgument.addLongIdentifier("use-schema-file", true);
    parser.addArgument(useSchemaFileArgument);
    doNotValidateSchemaDefinitionsArgument = new BooleanArgument(null, "doNotValidateSchemaDefinitions", 1, INFO_MEM_DS_TOOL_ARG_DESC_DO_NOT_VALIDATE_SCHEMA.get(useSchemaFileArgument.getIdentifierString()));
    doNotValidateSchemaDefinitionsArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    doNotValidateSchemaDefinitionsArgument.addLongIdentifier("do-not-validate-schema-definitions", true);
    parser.addArgument(doNotValidateSchemaDefinitionsArgument);
    doNotGenerateOperationalAttributesArgument = new BooleanArgument(null, "doNotGenerateOperationalAttributes", 1, INFO_MEM_DS_TOOL_ARG_DESC_DO_NOT_GENERATE_OP_ATTRS.get());
    doNotGenerateOperationalAttributesArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    doNotGenerateOperationalAttributesArgument.addLongIdentifier("do-not-generate-operational-attributes");
    parser.addArgument(doNotGenerateOperationalAttributesArgument);
    equalityIndexArgument = new StringArgument('I', "equalityIndex", false, 0, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_ATTR.get(), INFO_MEM_DS_TOOL_ARG_DESC_EQ_INDEX.get());
    equalityIndexArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    equalityIndexArgument.addLongIdentifier("equality-index", true);
    parser.addArgument(equalityIndexArgument);
    maxChangeLogEntriesArgument = new IntegerArgument('c', "maxChangeLogEntries", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_COUNT.get(), INFO_MEM_DS_TOOL_ARG_DESC_MAX_CHANGELOG_ENTRIES.get(), 0, Integer.MAX_VALUE, 0);
    maxChangeLogEntriesArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    maxChangeLogEntriesArgument.addLongIdentifier("max-changelog-entries", true);
    maxChangeLogEntriesArgument.addLongIdentifier("max-change-log-entries", true);
    parser.addArgument(maxChangeLogEntriesArgument);
    sizeLimitArgument = new IntegerArgument(null, "sizeLimit", false, 1, null, INFO_MEM_DS_TOOL_ARG_DESC_SIZE_LIMIT.get(), 1, Integer.MAX_VALUE, Integer.MAX_VALUE);
    sizeLimitArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    sizeLimitArgument.addLongIdentifier("searchSizeLimit", true);
    sizeLimitArgument.addLongIdentifier("size-limit", true);
    sizeLimitArgument.addLongIdentifier("search-size-limit", true);
    parser.addArgument(sizeLimitArgument);
    passwordAttributeArgument = new StringArgument(null, "passwordAttribute", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_ATTR.get(), INFO_MEM_DS_TOOL_ARG_DESC_PASSWORD_ATTRIBUTE.get(), "userPassword");
    passwordAttributeArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    passwordAttributeArgument.addLongIdentifier("passwordAttributeType", true);
    passwordAttributeArgument.addLongIdentifier("password-attribute", true);
    passwordAttributeArgument.addLongIdentifier("password-attribute-type", true);
    parser.addArgument(passwordAttributeArgument);
    final Set<String> allowedSchemes = StaticUtils.setOf("md5", "smd5", "sha", "ssha", "sha256", "ssha256", "sha384", "ssha384", "sha512", "ssha512", "clear", "base64", "hex");
    defaultPasswordEncodingArgument = new StringArgument(null, "defaultPasswordEncoding", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_SCHEME.get(), INFO_MEM_DS_TOOL_ARG_DESC_DEFAULT_PASSWORD_ENCODING.get(), allowedSchemes);
    defaultPasswordEncodingArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    defaultPasswordEncodingArgument.addLongIdentifier("defaultPasswordEncodingScheme", true);
    defaultPasswordEncodingArgument.addLongIdentifier("defaultPasswordStorageScheme", true);
    defaultPasswordEncodingArgument.addLongIdentifier("defaultPasswordScheme", true);
    defaultPasswordEncodingArgument.addLongIdentifier("default-password-encoding", true);
    defaultPasswordEncodingArgument.addLongIdentifier("default-password-encoding-scheme", true);
    defaultPasswordEncodingArgument.addLongIdentifier("default-password-storage-scheme", true);
    defaultPasswordEncodingArgument.addLongIdentifier("default-password-scheme", true);
    parser.addArgument(defaultPasswordEncodingArgument);
    final Set<String> allowedOperationTypeAllowedValues = StaticUtils.setOf("add", "bind", "compare", "delete", "extended", "modify", "modify-dn", "search");
    allowedOperationTypeArgument = new StringArgument(null, "allowedOperationType", false, 0, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_TYPE.get(), INFO_MEM_DS_TOOL_ARG_DESC_ALLOWED_OP_TYPE.get(), allowedOperationTypeAllowedValues);
    allowedOperationTypeArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    allowedOperationTypeArgument.addLongIdentifier("allowed-operation-type", true);
    parser.addArgument(allowedOperationTypeArgument);
    final Set<String> authRequiredTypeAllowedValues = StaticUtils.setOf("add", "compare", "delete", "extended", "modify", "modify-dn", "search");
    authenticationRequiredOperationTypeArgument = new StringArgument(null, "authenticationRequiredOperationType", false, 0, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_TYPE.get(), INFO_MEM_DS_TOOL_ARG_DESC_AUTH_REQUIRED_OP_TYPE.get(), authRequiredTypeAllowedValues);
    authenticationRequiredOperationTypeArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    authenticationRequiredOperationTypeArgument.addLongIdentifier("requiredAuthenticationOperationType", true);
    authenticationRequiredOperationTypeArgument.addLongIdentifier("requireAuthenticationOperationType", true);
    authenticationRequiredOperationTypeArgument.addLongIdentifier("authentication-required-operation-type", true);
    authenticationRequiredOperationTypeArgument.addLongIdentifier("required-authentication-operation-type", true);
    authenticationRequiredOperationTypeArgument.addLongIdentifier("require-authentication-operation-type", true);
    parser.addArgument(authenticationRequiredOperationTypeArgument);
    vendorNameArgument = new StringArgument(null, "vendorName", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_VALUE.get(), INFO_MEM_DS_TOOL_ARG_DESC_VENDOR_NAME.get());
    vendorNameArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    vendorNameArgument.addLongIdentifier("vendor-name", true);
    parser.addArgument(vendorNameArgument);
    vendorVersionArgument = new StringArgument(null, "vendorVersion", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_VALUE.get(), INFO_MEM_DS_TOOL_ARG_DESC_VENDOR_VERSION.get());
    vendorVersionArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_DATA.get());
    vendorVersionArgument.addLongIdentifier("vendor-version", true);
    parser.addArgument(vendorVersionArgument);
    accessLogToStandardOutArgument = new BooleanArgument('A', "accessLogToStandardOut", INFO_MEM_DS_TOOL_ARG_DESC_ACCESS_LOG_TO_STDOUT.get());
    accessLogToStandardOutArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    accessLogToStandardOutArgument.addLongIdentifier("access-log-to-standard-out", true);
    parser.addArgument(accessLogToStandardOutArgument);
    accessLogFileArgument = new FileArgument('a', "accessLogFile", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_ACCESS_LOG_FILE.get(), false, true, true, false);
    accessLogFileArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    accessLogFileArgument.addLongIdentifier("access-log-format", true);
    parser.addArgument(accessLogFileArgument);
    jsonAccessLogToStandardOutArgument = new BooleanArgument(null, "jsonAccessLogToStandardOut", INFO_MEM_DS_TOOL_ARG_DESC_JSON_ACCESS_LOG_TO_STDOUT.get());
    jsonAccessLogToStandardOutArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    jsonAccessLogToStandardOutArgument.addLongIdentifier("json-access-log-to-standard-out", true);
    parser.addArgument(jsonAccessLogToStandardOutArgument);
    jsonAccessLogFileArgument = new FileArgument(null, "jsonAccessLogFile", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_JSON_ACCESS_LOG_FILE.get(), false, true, true, false);
    jsonAccessLogFileArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    jsonAccessLogFileArgument.addLongIdentifier("json-access-log-format", true);
    parser.addArgument(jsonAccessLogFileArgument);
    ldapDebugLogToStandardOutArgument = new BooleanArgument(null, "ldapDebugLogToStandardOut", INFO_MEM_DS_TOOL_ARG_DESC_LDAP_DEBUG_LOG_TO_STDOUT.get());
    ldapDebugLogToStandardOutArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    ldapDebugLogToStandardOutArgument.addLongIdentifier("ldap-debug-log-to-standard-out", true);
    parser.addArgument(ldapDebugLogToStandardOutArgument);
    ldapDebugLogFileArgument = new FileArgument('d', "ldapDebugLogFile", false, 1, INFO_MEM_DS_TOOL_ARG_PLACEHOLDER_PATH.get(), INFO_MEM_DS_TOOL_ARG_DESC_LDAP_DEBUG_LOG_FILE.get(), false, true, true, false);
    ldapDebugLogFileArgument.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    ldapDebugLogFileArgument.addLongIdentifier("ldap-debug-log-file", true);
    parser.addArgument(ldapDebugLogFileArgument);
    codeLogFile = new FileArgument('C', "codeLogFile", false, 1, "{path}", INFO_MEM_DS_TOOL_ARG_DESC_CODE_LOG_FILE.get(), false, true, true, false);
    codeLogFile.setArgumentGroupName(INFO_MEM_DS_TOOL_GROUP_LOGGING.get());
    codeLogFile.addLongIdentifier("code-log-file", true);
    parser.addArgument(codeLogFile);
    parser.addExclusiveArgumentSet(useDefaultSchemaArgument, useSchemaFileArgument);
    parser.addDependentArgumentSet(doNotValidateSchemaDefinitionsArgument, useSchemaFileArgument);
    parser.addExclusiveArgumentSet(useSSLArgument, useStartTLSArgument);
    parser.addExclusiveArgumentSet(keyStorePathArgument, generateSelfSignedCertificateArgument);
    parser.addExclusiveArgumentSet(accessLogToStandardOutArgument, accessLogFileArgument);
    parser.addExclusiveArgumentSet(jsonAccessLogToStandardOutArgument, jsonAccessLogFileArgument);
    parser.addExclusiveArgumentSet(ldapDebugLogToStandardOutArgument, ldapDebugLogFileArgument);
    parser.addDependentArgumentSet(additionalBindDNArgument, additionalBindPasswordArgument);
    parser.addDependentArgumentSet(additionalBindPasswordArgument, additionalBindDNArgument);
    parser.addDependentArgumentSet(useSSLArgument, keyStorePathArgument, generateSelfSignedCertificateArgument);
    parser.addDependentArgumentSet(keyStorePathArgument, keyStorePasswordArgument);
    parser.addDependentArgumentSet(keyStorePasswordArgument, keyStorePathArgument);
    parser.addDependentArgumentSet(keyStoreTypeArgument, keyStorePathArgument);
    parser.addDependentArgumentSet(useStartTLSArgument, keyStorePathArgument, generateSelfSignedCertificateArgument);
    parser.addDependentArgumentSet(keyStorePathArgument, useSSLArgument, useStartTLSArgument);
    parser.addDependentArgumentSet(generateSelfSignedCertificateArgument, useSSLArgument, useStartTLSArgument);
    parser.addDependentArgumentSet(trustStorePathArgument, useSSLArgument, useStartTLSArgument);
    parser.addDependentArgumentSet(trustStorePasswordArgument, trustStorePathArgument);
    parser.addDependentArgumentSet(trustStoreTypeArgument, trustStorePathArgument);
}
Also used : DNArgument(com.unboundid.util.args.DNArgument) IntegerArgument(com.unboundid.util.args.IntegerArgument) BooleanArgument(com.unboundid.util.args.BooleanArgument) FileArgument(com.unboundid.util.args.FileArgument) StringArgument(com.unboundid.util.args.StringArgument)

Example 49 with BooleanArgument

use of com.unboundid.util.args.BooleanArgument in project ldapsdk by pingidentity.

the class TestLDAPSDKPerformance method addToolArguments.

/**
 * Adds the command-line arguments supported for use with this tool to the
 * provided argument parser.  The tool may need to retain references to the
 * arguments (and/or the argument parser, if trailing arguments are allowed)
 * to it in order to obtain their values for use in later processing.
 *
 * @param  parser  The argument parser to which the arguments are to be added.
 *
 * @throws  ArgumentException  If a problem occurs while adding any of the
 *                             tool-specific arguments to the provided
 *                             argument parser.
 */
@Override()
public void addToolArguments(@NotNull final ArgumentParser parser) throws ArgumentException {
    toolArg = new StringArgument(null, "tool", true, 1, "{searchrate|modrate|authrate|search-and-mod-rate}", "The tool to invoke against the LDAP listener.  It may be one of " + "searchrate, modrate, authrate, or search-and-mod-rate.  If " + "this is not provided, then the searchrate tool will be invoked.", StaticUtils.setOf(TOOL_NAME_SEARCHRATE, TOOL_NAME_MODRATE, TOOL_NAME_AUTHRATE, TOOL_NAME_SEARCH_AND_MOD_RATE), TOOL_NAME_SEARCHRATE);
    toolArg.addLongIdentifier("toolName", true);
    toolArg.addLongIdentifier("tool-name", true);
    parser.addArgument(toolArg);
    numThreadsArg = new IntegerArgument('t', "numThreads", true, 1, "{num}", "The number of concurrent threads (each using its own connection) " + "to use to process requests.  If this is not provided, then a " + "single thread will be used.", 1, Integer.MAX_VALUE, 1);
    numThreadsArg.addLongIdentifier("num-threads", true);
    numThreadsArg.addLongIdentifier("threads", true);
    parser.addArgument(numThreadsArg);
    entriesPerSearchArg = new IntegerArgument(null, "entriesPerSearch", true, 1, "{num}", "The number of entries to return in response to each search " + "request.  If this is provided, the value must be between 0 " + "and 100.  If it is not provided, then a single entry will be " + "returned.", 0, 100, 1);
    entriesPerSearchArg.addLongIdentifier("entries-per-search", true);
    entriesPerSearchArg.addLongIdentifier("numEntries", true);
    entriesPerSearchArg.addLongIdentifier("num-entries", true);
    entriesPerSearchArg.addLongIdentifier("entries", true);
    parser.addArgument(entriesPerSearchArg);
    bindOnlyArg = new BooleanArgument(null, "bindOnly", 1, "Indicates that the authrate tool should only issue bind requests.  " + "If this is not provided, the authrate tool will perform both " + "search and bind operations.  This argument will only be used " + "in conjunction with the authrate tool.");
    bindOnlyArg.addLongIdentifier("bind-only", true);
    parser.addArgument(bindOnlyArg);
    resultCodeArg = new IntegerArgument(null, "resultCode", true, 1, "{intValue}", "The integer value for the result code to return in response to " + "each request.  If this is not provided, then a result code of " + "0 (success) will be returned.", 0, Integer.MAX_VALUE, ResultCode.SUCCESS_INT_VALUE);
    resultCodeArg.addLongIdentifier("result-code", true);
    parser.addArgument(resultCodeArg);
    diagnosticMessageArg = new StringArgument(null, "diagnosticMessage", false, 1, "{message}", "The diagnostic message to return in response to each request.  If " + "this is not provided, then no diagnostic message will be " + "returned.");
    diagnosticMessageArg.addLongIdentifier("diagnostic-message", true);
    diagnosticMessageArg.addLongIdentifier("errorMessage", true);
    diagnosticMessageArg.addLongIdentifier("error-message", true);
    diagnosticMessageArg.addLongIdentifier("message", true);
    parser.addArgument(diagnosticMessageArg);
    useSSLArg = new BooleanArgument('Z', "useSSL", 1, "Encrypt communication with SSL.  If this argument is not provided, " + "then the communication will not be encrypted.");
    useSSLArg.addLongIdentifier("use-ssl", true);
    useSSLArg.addLongIdentifier("ssl", true);
    useSSLArg.addLongIdentifier("useTLS", true);
    useSSLArg.addLongIdentifier("use-tls", true);
    useSSLArg.addLongIdentifier("tls", true);
    parser.addArgument(useSSLArg);
    numIntervalsArg = new IntegerArgument('I', "numIntervals", false, 1, "{num}", "The number of intervals to use when running the performance " + "measurement tool.  If this argument is provided in " + "conjunction with the --warmUpIntervals argument, then the " + "warm-up intervals will not be included in this count, and the " + "total number of intervals run will be the sum of the two " + "values.  If this argument is not provided, then the tool will " + "run until it is interrupted (e.g., by pressing Ctrl+C or by " + "killing the underlying Java process).", 0, Integer.MAX_VALUE);
    numIntervalsArg.addLongIdentifier("num-intervals", true);
    numIntervalsArg.addLongIdentifier("intervals", true);
    parser.addArgument(numIntervalsArg);
    intervalDurationSecondsArg = new IntegerArgument('i', "intervalDurationSeconds", true, 1, "{num}", "The length of time in seconds to use for each tool interval (that " + "is, the length of time between each line of output giving " + "statistical information for operations processed in that " + "interval).  If this is not provided, then a default interval " + "duration of five seconds will be used.", 1, Integer.MAX_VALUE, 5);
    intervalDurationSecondsArg.addLongIdentifier("interval-duration-seconds", true);
    intervalDurationSecondsArg.addLongIdentifier("intervalDuration", true);
    intervalDurationSecondsArg.addLongIdentifier("interval-duration", true);
    parser.addArgument(intervalDurationSecondsArg);
    warmUpIntervalsArg = new IntegerArgument(null, "warmUpIntervals", true, 1, "{num}", "The number of intervals to run before starting to actually " + "collect statistics to include in the final result.  This can " + "give the JVM and JIT a chance to identify and optimize " + "hotspots in the code for the best and most stable " + "performance.  If this is not provided, then no warm-up " + "intervals will be used and the tool will start collecting " + "statistics right away.", 0, Integer.MAX_VALUE, 0);
    warmUpIntervalsArg.addLongIdentifier("warm-up-intervals", true);
    warmUpIntervalsArg.addLongIdentifier("warmup-intervals", true);
    warmUpIntervalsArg.addLongIdentifier("warmUp", true);
    warmUpIntervalsArg.addLongIdentifier("warm-up", true);
    parser.addArgument(warmUpIntervalsArg);
}
Also used : IntegerArgument(com.unboundid.util.args.IntegerArgument) BooleanArgument(com.unboundid.util.args.BooleanArgument) StringArgument(com.unboundid.util.args.StringArgument)

Example 50 with BooleanArgument

use of com.unboundid.util.args.BooleanArgument in project ldapsdk by pingidentity.

the class Base64Tool method doDecode.

/**
 * Performs the necessary work for base64 decoding.
 *
 * @param  p  The argument parser for the decode subcommand.
 *
 * @return  A result code that indicates whether the processing completed
 *          successfully.
 */
@NotNull()
private ResultCode doDecode(@NotNull final ArgumentParser p) {
    // Get the data to decode.  We'll always ignore the following:
    // - Line breaks
    // - Blank lines
    // - Lines that start with an octothorpe (#)
    // 
    // Unless the --url argument was provided, then we'll also ignore lines that
    // start with a dash (like those used as start and end markers in a
    // PEM-encoded certificate).  Since dashes are part of the base64url
    // alphabet, we can't ignore dashes if the --url argument was provided.
    final ByteStringBuffer encodedDataBuffer = new ByteStringBuffer();
    final BooleanArgument urlArg = p.getBooleanArgument(ARG_NAME_URL);
    final StringArgument dataArg = p.getStringArgument(ARG_NAME_DATA);
    if ((dataArg != null) && dataArg.isPresent()) {
        encodedDataBuffer.append(dataArg.getValue());
    } else {
        try {
            final BufferedReader reader;
            final FileArgument inputFileArg = p.getFileArgument(ARG_NAME_INPUT_FILE);
            if ((inputFileArg != null) && inputFileArg.isPresent()) {
                reader = new BufferedReader(new FileReader(inputFileArg.getValue()));
            } else {
                reader = new BufferedReader(new InputStreamReader(in));
            }
            while (true) {
                final String line = reader.readLine();
                if (line == null) {
                    break;
                }
                if ((line.length() == 0) || line.startsWith("#")) {
                    continue;
                }
                if (line.startsWith("-") && ((urlArg == null) || (!urlArg.isPresent()))) {
                    continue;
                }
                encodedDataBuffer.append(line);
            }
            reader.close();
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, "An error occurred while attempting to read the data to decode:  ", StaticUtils.getExceptionMessage(e));
            return ResultCode.LOCAL_ERROR;
        }
    }
    // Base64-decode the data.
    final ByteStringBuffer rawDataBuffer = new ByteStringBuffer(encodedDataBuffer.length());
    if ((urlArg != null) && urlArg.isPresent()) {
        try {
            rawDataBuffer.append(Base64.urlDecode(encodedDataBuffer.toString()));
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, "An error occurred while attempting to base64url-decode the " + "provided data:  " + StaticUtils.getExceptionMessage(e));
            return ResultCode.LOCAL_ERROR;
        }
    } else {
        try {
            rawDataBuffer.append(Base64.decode(encodedDataBuffer.toString()));
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, "An error occurred while attempting to base64-decode the " + "provided data:  " + StaticUtils.getExceptionMessage(e));
            return ResultCode.LOCAL_ERROR;
        }
    }
    // If we should add a newline, then do that now.
    final BooleanArgument addEOLArg = p.getBooleanArgument(ARG_NAME_ADD_TRAILING_LINE_BREAK);
    if ((addEOLArg != null) && addEOLArg.isPresent()) {
        rawDataBuffer.append(StaticUtils.EOL_BYTES);
    }
    // Write the decoded data.
    final FileArgument outputFileArg = p.getFileArgument(ARG_NAME_OUTPUT_FILE);
    if ((outputFileArg != null) && outputFileArg.isPresent()) {
        try {
            final FileOutputStream outputStream = new FileOutputStream(outputFileArg.getValue(), false);
            rawDataBuffer.write(outputStream);
            outputStream.flush();
            outputStream.close();
        } catch (final Exception e) {
            Debug.debugException(e);
            wrapErr(0, WRAP_COLUMN, "An error occurred while attempting to write the base64-decoded " + "data to output file ", outputFileArg.getValue().getAbsolutePath(), ":  ", StaticUtils.getExceptionMessage(e));
            err("Base64-decoded data:");
            err(encodedDataBuffer.toString());
            return ResultCode.LOCAL_ERROR;
        }
    } else {
        final byte[] rawDataArray = rawDataBuffer.toByteArray();
        getOut().write(rawDataArray, 0, rawDataArray.length);
        getOut().flush();
    }
    return ResultCode.SUCCESS;
}
Also used : InputStreamReader(java.io.InputStreamReader) FileOutputStream(java.io.FileOutputStream) BooleanArgument(com.unboundid.util.args.BooleanArgument) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) FileArgument(com.unboundid.util.args.FileArgument) ByteStringBuffer(com.unboundid.util.ByteStringBuffer) ArgumentException(com.unboundid.util.args.ArgumentException) StringArgument(com.unboundid.util.args.StringArgument) NotNull(com.unboundid.util.NotNull)

Aggregations

BooleanArgument (com.unboundid.util.args.BooleanArgument)65 StringArgument (com.unboundid.util.args.StringArgument)53 FileArgument (com.unboundid.util.args.FileArgument)51 IntegerArgument (com.unboundid.util.args.IntegerArgument)35 DNArgument (com.unboundid.util.args.DNArgument)25 LDAPException (com.unboundid.ldap.sdk.LDAPException)19 File (java.io.File)19 ArgumentException (com.unboundid.util.args.ArgumentException)18 ASN1BitString (com.unboundid.asn1.ASN1BitString)16 NotNull (com.unboundid.util.NotNull)16 FilterArgument (com.unboundid.util.args.FilterArgument)14 ControlArgument (com.unboundid.util.args.ControlArgument)13 IOException (java.io.IOException)13 UnrecoverableKeyException (java.security.UnrecoverableKeyException)12 ArrayList (java.util.ArrayList)12 KeyStore (java.security.KeyStore)10 ScopeArgument (com.unboundid.util.args.ScopeArgument)9 Certificate (java.security.cert.Certificate)8 ArgumentParser (com.unboundid.util.args.ArgumentParser)7 DN (com.unboundid.ldap.sdk.DN)6