Class AbstractAuthenticatedCLI

java.lang.Object
ubic.gemma.cli.util.AbstractCLI
ubic.gemma.cli.util.AbstractAuthenticatedCLI
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.EnvironmentAware, CLI
Direct Known Subclasses:
AbstractAutoSeekingCLI, ArrayDesignAlternativePopulateCli, BibRefUpdaterCli, BlacklistCli, CompleteCli, DatabaseViewGeneratorCLI, ExperimentalDesignViewCli, ExternalDatabaseAdderCli, ExternalDatabaseOverviewCli, ExternalDatabaseUpdaterCli, ExternalFileGeneLoaderCLI, FactorValueMigratorCLI, FactorValueOntologyWriterCli, FindObsoleteTermsCli, FixOntologyTermLabelsCli, GenericGenelistDesignGenerator, GeoGrabberCli, LoadExpressionDataCli, LoadSimpleExpressionDataCli, MultifunctionalityCli, NCBIGene2GOAssociationLoaderCLI, NcbiGeneLoaderCLI, ProtocolAdderCli, ProtocolDeleterCli, ProtocolListCli, PubMedLoaderCli, PubMedSearcher, TaxonLoaderCli, UpdateGene2CsCli, UpdatePubMedCli

public abstract class AbstractAuthenticatedCLI extends AbstractCLI implements org.springframework.beans.factory.InitializingBean, org.springframework.context.EnvironmentAware
Subclass this to create command line interface (CLI) tools that need authentication.

Credentials may be supplied via the environment using the $GEMMA_USERNAME and $GEMMA_PASSWORD variables. A more secure $GEMMA_PASSWORD_CMD variable can be used to specify a command that produces the password. If no environment variables are supplied, they will be prompted if the standard input is attached to a console (i.e tty).

If the test or testdb profile is active, environment variables with the $GEMMA_TESTDB_ prefix will be looked up instead.

Author:
pavlidis
  • Constructor Details

    • AbstractAuthenticatedCLI

      public AbstractAuthenticatedCLI()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware
    • setRequireLogin

      protected void setRequireLogin()
      Indicate that the command requires authentication.
    • setAuthenticateAnonymously

      protected void setAuthenticateAnonymously()
      Indicate that the command should authenticate anonymously, i.e. without requiring a username and password.

      This can be used for commands that are intended to access public data.

    • doWork

      protected final void doWork() throws Exception
      Description copied from class: AbstractCLI
      Command line implementation.

      This is called after AbstractCLI.buildOptions(Options) and AbstractCLI.processOptions(CommandLine). so the implementation can assume that all its arguments have already been initialized and any setup behaviour have been performed.

      Specified by:
      doWork in class AbstractCLI
      Throws:
      Exception - in case of unrecoverable failure, an exception is thrown and will result in a AbstractCLI.FAILURE exit code, otherwise use AbstractCLI.addErrorObject(java.io.Serializable, java.lang.String, java.lang.Throwable) to indicate an error and resume processing
    • doAuthenticatedWork

      protected abstract void doAuthenticatedWork() throws Exception
      Throws:
      Exception