All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unboundid.util.Launcher Maven / Gradle / Ivy

Go to download

The UnboundID LDAP SDK for Java is a fast, comprehensive, and easy-to-use Java API for communicating with LDAP directory servers and performing related tasks like reading and writing LDIF, encoding and decoding data using base64 and ASN.1 BER, and performing secure communication. This package contains the Commercial Edition of the LDAP SDK, which includes all of the general-purpose functionality contained in the Standard Edition, plus additional functionality specific to UnboundID server products.

The newest version!
/*
 * Copyright 2010-2017 UnboundID Corp.
 * All Rights Reserved.
 */
/*
 * Copyright (C) 2010-2017 UnboundID Corp.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (GPLv2 only)
 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see .
 */
package com.unboundid.util;



import java.io.OutputStream;
import java.io.PrintStream;

import com.unboundid.ldap.listener.InMemoryDirectoryServerTool;
import com.unboundid.ldap.sdk.ResultCode;
import com.unboundid.ldap.sdk.Version;
import com.unboundid.ldap.sdk.examples.AuthRate;
import com.unboundid.ldap.sdk.examples.IdentifyReferencesToMissingEntries;
import com.unboundid.ldap.sdk.examples.IdentifyUniqueAttributeConflicts;
import com.unboundid.ldap.sdk.examples.LDAPCompare;
import com.unboundid.ldap.sdk.examples.LDAPDebugger;
import com.unboundid.ldap.sdk.examples.LDAPModify;
import com.unboundid.ldap.sdk.examples.LDAPSearch;
import com.unboundid.ldap.sdk.examples.ModRate;
import com.unboundid.ldap.sdk.examples.SearchRate;
import com.unboundid.ldap.sdk.examples.SearchAndModRate;
import com.unboundid.ldap.sdk.examples.ValidateLDIF;
import com.unboundid.ldap.sdk.persist.GenerateSchemaFromSource;
import com.unboundid.ldap.sdk.persist.GenerateSourceFromSchema;



/**
 * This class provides an entry point that may be used to launch other tools
 * provided as part of the LDAP SDK.  This is primarily a convenience for
 * someone who just has the jar file and none of the scripts, since you can run
 * "java -jar unboundid-ldapsdk-se.jar {tool-name} {tool-args}"
 * in order to invoke any of the example tools.  Running just
 * "java -jar unboundid-ldapsdk-se.jar" will display version
 * information about the LDAP SDK.
 * 

* The tool names are case-insensitive. Supported tool names include: *
    *
  • authrate -- Launch the {@link AuthRate} tool.
  • *
  • in-memory-directory-server -- Launch the * {@link InMemoryDirectoryServerTool} tool.
  • *
  • generate-schema-from-source -- Launch the * {@link GenerateSchemaFromSource} tool.
  • *
  • generate-source-from-schema -- Launch the * {@link GenerateSourceFromSchema} tool.
  • *
  • identify-references-to-missing-entries -- Launch the * {@link IdentifyReferencesToMissingEntries} tool.
  • *
  • identify-unique-attribute-conflicts -- Launch the * {@link IdentifyUniqueAttributeConflicts} tool.
  • *
  • in-memory-directory-server -- Launch the * {@link InMemoryDirectoryServerTool} tool.
  • *
  • ldapcompare -- Launch the {@link LDAPCompare} tool.
  • *
  • ldapmodify -- Launch the {@link LDAPModify} tool.
  • *
  • ldapsearch -- Launch the {@link LDAPSearch} tool.
  • *
  • ldap-debugger -- Launch the {@link LDAPDebugger} tool.
  • *
  • modrate -- Launch the {@link ModRate} tool.
  • *
  • searchrate -- Launch the {@link SearchRate} tool.
  • *
  • search-and-mod-rate -- Launch the {@link SearchAndModRate} tool.
  • *
  • validate-ldif -- Launch the {@link ValidateLDIF} tool.
  • *
  • version -- Display version information for the LDAP SDK.
  • *
*/ @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) public final class Launcher { /** * Prevent this utility class from being externally instantiated. */ Launcher() { // No implementation required. } /** * Parses the command-line arguments and performs any appropriate processing * for this program. * * @param args The command-line arguments provided to this program. */ public static void main(final String... args) { main(System.out, System.err, args); } /** * Parses the command-line arguments and performs any appropriate processing * for this program. * * @param outStream The output stream to which standard out should be * written. It may be {@code null} if output should be * suppressed. * @param errStream The output stream to which standard error should be * written. It may be {@code null} if error messages * should be suppressed. * @param args The command-line arguments provided to this program. * * @return A result code with information about the status of processing. */ public static ResultCode main(final OutputStream outStream, final OutputStream errStream, final String... args) { if ((args == null) || (args.length == 0) || args[0].equalsIgnoreCase("version")) { if (outStream != null) { final PrintStream out = new PrintStream(outStream); for (final String line : Version.getVersionLines()) { out.println(line); } } return ResultCode.SUCCESS; } final String firstArg = StaticUtils.toLowerCase(args[0]); final String[] remainingArgs = new String[args.length - 1]; System.arraycopy(args, 1, remainingArgs, 0, remainingArgs.length); if (firstArg.equals("authrate")) { return AuthRate.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("identify-references-to-missing-entries")) { return IdentifyReferencesToMissingEntries.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("identify-unique-attribute-conflicts")) { return IdentifyUniqueAttributeConflicts.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("in-memory-directory-server")) { return InMemoryDirectoryServerTool.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("generate-schema-from-source")) { return GenerateSchemaFromSource.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("generate-source-from-schema")) { return GenerateSourceFromSchema.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("ldapcompare")) { return LDAPCompare.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("ldapmodify")) { return LDAPModify.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("ldapsearch")) { return LDAPSearch.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("ldap-debugger")) { return LDAPDebugger.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("modrate")) { return ModRate.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("searchrate")) { return SearchRate.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("search-and-mod-rate")) { return SearchAndModRate.main(remainingArgs, outStream, errStream); } else if (firstArg.equals("validate-ldif")) { return ValidateLDIF.main(remainingArgs, outStream, errStream); } else { if (errStream != null) { final PrintStream err = new PrintStream(errStream); err.println("Unrecognized tool name '" + args[0] + '\''); err.println("Supported tool names include:"); err.println(" authrate"); err.println(" identify-references-to-missing-entries"); err.println(" identify-unique-attribute-conflicts"); err.println(" in-memory-directory-server"); err.println(" generate-schema-from-source"); err.println(" generate-source-from-schema"); err.println(" ldapcompare"); err.println(" ldapmodify"); err.println(" ldapsearch"); err.println(" ldap-debugger"); err.println(" modrate"); err.println(" searchrate"); err.println(" search-and-mod-rate"); err.println(" validate-ldif"); err.println(" version"); } return ResultCode.PARAM_ERROR; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy