Class FileValidationHandler

java.lang.Object
com.digicert.validation.methods.file.validate.FileValidationHandler

public class FileValidationHandler extends Object
Handles the validation of file-based domain control validation (DCV) requests.

This class is responsible for managing the validation process of file-based DCV requests. It interacts with various components such as the file validation client, random value validator, and request token validator to ensure that the validation process is carried out correctly. The class provides methods to set up the necessary clients, validate the requests, and retrieve files from the required URLs.

  • Field Details

    • fileClient

      private FileClient fileClient
      The file validation client.
    • randomValueValidator

      private final RandomValueValidator randomValueValidator
      The random value validator used to confirm that the file text contains the expected random value.
    • requestTokenValidator

      private final RequestTokenValidator requestTokenValidator
      The request token validator used to confirm that the file text contains a valid request token.
    • FILE_PATH

      private static final String FILE_PATH
      The path to the file containing the challenge value.
      See Also:
    • defaultFileValidationFilename

      private final String defaultFileValidationFilename
      The default file validation filename.
    • fileValidationCheckHttps

      private final boolean fileValidationCheckHttps
      The flag to check if the file validation request should be made over HTTPS.
  • Constructor Details

    • FileValidationHandler

      public FileValidationHandler(DcvContext dcvContext)
      Constructs a new FileValidationHandler with the specified configuration.

      This constructor initializes the FileValidationHandler with the necessary dependencies and configuration settings. It retrieves the required clients and validators from the provided DcvContext and sets up the default file validation filename.

      Parameters:
      dcvContext - context where we can find the needed dependencies / configuration
  • Method Details

    • validate

      public FileValidationResponse validate(FileValidationRequest validationRequest)
      Validates the file-based domain control validation (DCV) request.

      This method processes the file-based DCV request by validating the provided file URLs and checking for errors. It uses the file validation client to execute requests and retrieve responses, which are then validated using the random value validator or request token validator. The method constructs a response based on the validation results, indicating whether the validation was successful or not.

      Parameters:
      validationRequest - the file validation request
      Returns:
      the file validation response
    • getValidChallengeResponse

      private ChallengeValidationResponse getValidChallengeResponse(FileValidationRequest fileValidationRequest, String fileContent)
      Validates the presence of the random value or a valid request token in the provided file content.
      Parameters:
      fileValidationRequest - the file validation request
      fileContent - the content of the file where the challenge response should be found
      Returns:
      ChallengeValidationResponse containing a valid challenge response or a set of errors
    • getErrorsFromFileClientResponse

      private Optional<DcvError> getErrorsFromFileClientResponse(FileClientResponse fileClientResponse)
      Checks if the file client response is valid.
      Parameters:
      fileClientResponse - the file validation client response
      Returns:
      empty list if valid, otherwise a list of errors
    • getFileUrls

      public List<String> getFileUrls(FileValidationRequest fileValidationRequest)
      Retrieves the list of file URLs for the file-based domain control validation (DCV) request.

      This method constructs the list of file URLs that will be used in the file-based DCV request. It uses the domain and filename provided in the validation request to create the URLs. If no specific filename is provided, the default file validation filename is used. If the `fileValidationCheckHttps` flag is true it will return a list using both HTTP and HTTPS protocols, otherwise it will return a list that only includes HTTP.

      Parameters:
      fileValidationRequest - the file validation request
      Returns:
      the list of file URLs