Package org.codice.ddf.commands.catalog
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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected org.codice.ddf.security.Securityprotected org.apache.karaf.shell.api.console.Sessionprotected StringFields inherited from class org.codice.ddf.commands.catalog.CommandSupport
console, ERROR_COLOR, MS_PER_SECOND -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.codice.ddf.commands.catalog.CommandSupport
calculateRecordsPerSecond, printColor, printErrorMessage, printHeaderMessage, printProgressAndFlush, printSuccessMessage
-
Field Details
-
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
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
Executes the command using the user name provided using the--useroption and prompts for a password. If no user name was provided, tries to run the command using the currentSubject, 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(), ornullif the command failed
-