Class SubjectCommands

java.lang.Object
org.codice.ddf.commands.catalog.CommandSupport
org.codice.ddf.commands.catalog.SubjectCommands
All Implemented Interfaces:
org.apache.karaf.shell.api.action.Action
Direct Known Subclasses:
CatalogCommands

public abstract class SubjectCommands extends CommandSupport
SubjectCommands provides the ability to change what subject (user) the extending command is run as. If no user is specified and the user has the admin role, the command will execute as the system user otherwise it will fail.
  • Field Details

    • user

      protected String user
    • session

      protected org.apache.karaf.shell.api.console.Session session
    • security

      protected org.codice.ddf.security.Security security
  • Constructor Details

    • SubjectCommands

      public SubjectCommands()
  • Method Details

    • executeWithSubject

      protected abstract Object executeWithSubject() throws Exception
      Executes the command once the user has been properly authorized.
      Returns:
      result of the command execution
      Throws:
      Exception - if the command failed to run
    • execute

      public Object execute()
      Executes the command using the user name provided using the --user option and prompts for a password. If no user name was provided, tries to run the command using the current Subject, or elevates to the system subject is the user has permission to do so.

      An error message will be printed out if the user name/password combination is invalid or if the user doesn't have the permission to run the command.

      Returns:
      value returned by executeWithSubject(), or null if the command failed