Class CommandChain

java.lang.Object
org.codelibs.fess.auth.chain.CommandChain
All Implemented Interfaces:
AuthenticationChain

public class CommandChain extends Object implements 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 Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Thread that reads input stream data and buffers it for later retrieval.
    protected static class 
    Monitor thread that handles process timeout and termination.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    Character encoding for command output.
    protected String[]
    Command array for user deletion operations.
    protected long
    Command execution timeout in milliseconds.
    protected int
    Maximum number of output lines to capture.
    protected String[]
    Array of target usernames for command execution.
    protected String[]
    Command array for user update operations.
    protected File
    Working directory for command execution.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for CommandChain.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    changePassword(String username, String password)
    Changes the password for the specified user.
    void
    delete(org.codelibs.fess.opensearch.user.exentity.User user)
    Deletes a user from the authentication chain.
    protected int
    executeCommand(String[] commands, String username, String password)
    Executes an external command with the given parameters.
    protected boolean
    isTargetUser(String username)
    Checks if the given username is a target user for command execution.
    org.codelibs.fess.opensearch.user.exentity.User
    load(org.codelibs.fess.opensearch.user.exentity.User user)
    Loads user information from the authentication chain.
    void
    setCommandOutputEncoding(String commandOutputEncoding)
    Sets the character encoding for command output.
    void
    setDeleteCommand(String[] deleteCommand)
    Sets the command array for user deletion operations.
    void
    setExecutionTimeout(long executionTimeout)
    Sets the command execution timeout.
    void
    setMaxOutputLine(int maxOutputLine)
    Sets the maximum number of output lines to capture.
    void
    setTargetUsers(String[] targetUsers)
    Sets the array of target usernames for command execution.
    void
    setUpdateCommand(String[] updateCommand)
    Sets the command array for user update operations.
    void
    setWorkingDirectory(File workingDirectory)
    Sets the working directory for command execution.
    void
    update(org.codelibs.fess.opensearch.user.exentity.User user)
    Updates an existing user in the authentication chain.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • workingDirectory

      protected File workingDirectory
      Working directory for command execution.
    • maxOutputLine

      protected int maxOutputLine
      Maximum number of output lines to capture.
    • executionTimeout

      protected long executionTimeout
      Command execution timeout in milliseconds.
    • commandOutputEncoding

      protected String commandOutputEncoding
      Character encoding for command output.
    • updateCommand

      protected String[] updateCommand
      Command array for user update operations.
    • deleteCommand

      protected String[] deleteCommand
      Command array for user deletion operations.
    • targetUsers

      protected String[] 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: AuthenticationChain
      Updates an existing user in the authentication chain.
      Specified by:
      update in interface AuthenticationChain
      Parameters:
      user - The user to update.
    • delete

      public void delete(org.codelibs.fess.opensearch.user.exentity.User user)
      Description copied from interface: AuthenticationChain
      Deletes a user from the authentication chain.
      Specified by:
      delete in interface AuthenticationChain
      Parameters:
      user - The user to delete.
    • changePassword

      public boolean changePassword(String username, String password)
      Description copied from interface: AuthenticationChain
      Changes the password for the specified user.
      Specified by:
      changePassword in interface AuthenticationChain
      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: AuthenticationChain
      Loads user information from the authentication chain.
      Specified by:
      load in interface AuthenticationChain
      Parameters:
      user - The user template containing search criteria.
      Returns:
      The loaded user, or null if not found.
    • isTargetUser

      protected boolean isTargetUser(String username)
      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

      protected int executeCommand(String[] commands, String username, String password)
      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

      public void setWorkingDirectory(File workingDirectory)
      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

      public void setCommandOutputEncoding(String commandOutputEncoding)
      Sets the character encoding for command output.
      Parameters:
      commandOutputEncoding - The character encoding.
    • setUpdateCommand

      public void setUpdateCommand(String[] updateCommand)
      Sets the command array for user update operations.
      Parameters:
      updateCommand - The update command array.
    • setDeleteCommand

      public void setDeleteCommand(String[] deleteCommand)
      Sets the command array for user deletion operations.
      Parameters:
      deleteCommand - The delete command array.
    • setTargetUsers

      public void setTargetUsers(String[] targetUsers)
      Sets the array of target usernames for command execution.
      Parameters:
      targetUsers - The target users array.