Package org.codelibs.fess.auth.chain
Class CommandChain
java.lang.Object
org.codelibs.fess.auth.chain.CommandChain
- All Implemented Interfaces:
AuthenticationChain
Authentication chain implementation that executes external commands for user operations.
Provides user management through command-line tool execution for password changes and user deletion.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThread that reads input stream data and buffers it for later retrieval.protected static classMonitor thread that handles process timeout and termination. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringCharacter encoding for command output.protected String[]Command array for user deletion operations.protected longCommand execution timeout in milliseconds.protected intMaximum number of output lines to capture.protected String[]Array of target usernames for command execution.protected String[]Command array for user update operations.protected FileWorking directory for command execution. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanchangePassword(String username, String password) Changes the password for the specified user.voiddelete(org.codelibs.fess.opensearch.user.exentity.User user) Deletes a user from the authentication chain.protected intexecuteCommand(String[] commands, String username, String password) Executes an external command with the given parameters.protected booleanisTargetUser(String username) Checks if the given username is a target user for command execution.org.codelibs.fess.opensearch.user.exentity.Userload(org.codelibs.fess.opensearch.user.exentity.User user) Loads user information from the authentication chain.voidsetCommandOutputEncoding(String commandOutputEncoding) Sets the character encoding for command output.voidsetDeleteCommand(String[] deleteCommand) Sets the command array for user deletion operations.voidsetExecutionTimeout(long executionTimeout) Sets the command execution timeout.voidsetMaxOutputLine(int maxOutputLine) Sets the maximum number of output lines to capture.voidsetTargetUsers(String[] targetUsers) Sets the array of target usernames for command execution.voidsetUpdateCommand(String[] updateCommand) Sets the command array for user update operations.voidsetWorkingDirectory(File workingDirectory) Sets the working directory for command execution.voidupdate(org.codelibs.fess.opensearch.user.exentity.User user) Updates an existing user in the authentication chain.
-
Field Details
-
workingDirectory
Working directory for command execution. -
maxOutputLine
protected int maxOutputLineMaximum number of output lines to capture. -
executionTimeout
protected long executionTimeoutCommand execution timeout in milliseconds. -
commandOutputEncoding
Character encoding for command output. -
updateCommand
Command array for user update operations. -
deleteCommand
Command array for user deletion operations. -
targetUsers
Array of target usernames for command execution.
-
-
Constructor Details
-
CommandChain
public CommandChain()Default constructor for CommandChain.
-
-
Method Details
-
update
public void update(org.codelibs.fess.opensearch.user.exentity.User user) Description copied from interface:AuthenticationChainUpdates an existing user in the authentication chain.- Specified by:
updatein interfaceAuthenticationChain- Parameters:
user- The user to update.
-
delete
public void delete(org.codelibs.fess.opensearch.user.exentity.User user) Description copied from interface:AuthenticationChainDeletes a user from the authentication chain.- Specified by:
deletein interfaceAuthenticationChain- Parameters:
user- The user to delete.
-
changePassword
Description copied from interface:AuthenticationChainChanges the password for the specified user.- Specified by:
changePasswordin interfaceAuthenticationChain- Parameters:
username- The username for which to change the password.password- The new password.- Returns:
- True if the password was successfully changed, false otherwise.
-
load
public org.codelibs.fess.opensearch.user.exentity.User load(org.codelibs.fess.opensearch.user.exentity.User user) Description copied from interface:AuthenticationChainLoads user information from the authentication chain.- Specified by:
loadin interfaceAuthenticationChain- Parameters:
user- The user template containing search criteria.- Returns:
- The loaded user, or null if not found.
-
isTargetUser
Checks if the given username is a target user for command execution.- Parameters:
username- The username to check.- Returns:
- True if the user is a target user, false otherwise.
-
executeCommand
Executes an external command with the given parameters.- Parameters:
commands- The command array to execute.username- The username parameter for the command.password- The password parameter for the command.- Returns:
- The exit code of the executed command.
-
setWorkingDirectory
Sets the working directory for command execution.- Parameters:
workingDirectory- The working directory.
-
setMaxOutputLine
public void setMaxOutputLine(int maxOutputLine) Sets the maximum number of output lines to capture.- Parameters:
maxOutputLine- The maximum output line count.
-
setExecutionTimeout
public void setExecutionTimeout(long executionTimeout) Sets the command execution timeout.- Parameters:
executionTimeout- The execution timeout in milliseconds.
-
setCommandOutputEncoding
Sets the character encoding for command output.- Parameters:
commandOutputEncoding- The character encoding.
-
setUpdateCommand
Sets the command array for user update operations.- Parameters:
updateCommand- The update command array.
-
setDeleteCommand
Sets the command array for user deletion operations.- Parameters:
deleteCommand- The delete command array.
-
setTargetUsers
Sets the array of target usernames for command execution.- Parameters:
targetUsers- The target users array.
-