Class FileValidator

java.lang.Object
com.digicert.validation.methods.file.FileValidator

public class FileValidator extends Object
FileValidator is a class that provides methods to prepare and validate files for domain validation.

This class implements Validation for DcvMethod.BR_3_2_2_4_18 method. It is responsible for handling the preparation and validation processes required for file-based domain control validation (DCV).

  • Field Details

    • randomValueGenerator

      private final RandomValueGenerator randomValueGenerator
      Utility class for generating random values

      This utility class is used to generate random values that are required during the file-based domain validation process.

    • randomValueVerifier

      private final RandomValueVerifier randomValueVerifier
      Utility class for random value verification

      This utility class is responsible for verifying the random values generated during the preparation phase. It ensures that the random values meet the required entropy levels and have not expired.

    • domainNameUtils

      private final DomainNameUtils domainNameUtils
      Utility class for domain name operations

      This utility class provides various operations related to domain names, such as validation and manipulation.

    • fileValidationHandler

      private final FileValidationHandler fileValidationHandler
      Handler for File Validation

      This handler is responsible for executing the file-based domain validation process.

    • FILE_LOCATION

      private static final String FILE_LOCATION
      File location based on the BR specifications

      This string is combined with the submitted domain name and file location to create the URL where the file will be placed.

      See Also:
    • defaultFilename

      private final String defaultFilename
      Default filename for the file validation

      If no filename is specified in the request, the default filename specified in the dcvConfiguration will be used.

  • Constructor Details

    • FileValidator

      public FileValidator(DcvContext dcvContext)
      Constructor for FileValidator

      Initializes the FileValidator with the necessary dependencies and configurations provided by the DcvContext.

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

    • prepare

      public FilePreparationResponse prepare(FilePreparationRequest preparationRequest) throws DcvException
      Prepare for file validation.

      This method prepares for file domain validation by generating a random value if the challenge type is ChallengeType.RANDOM_VALUE. It verifies the preparation request and constructs a response containing the necessary information for the validation process.

      Parameters:
      preparationRequest - FilePreparationRequest object containing the domain and challenge type
      Returns:
      FilePreparationResponse object containing the random value and domain
      Throws:
      DcvException - if the request is invalid. InputException when missing required fields.
    • validate

      public DomainValidationEvidence validate(FileValidationRequest validationRequest) throws DcvException
      Perform File Validation

      This method performs the file-based domain validation by verifying the provided validation request. It checks the validity of the domain, challenge type, random value or request token data, and validation state. If the validation is successful, it returns a DomainValidationEvidence object containing the validation evidence. If the validation fails, it throws a ValidationException with the encountered errors.

      Parameters:
      validationRequest - FileValidationRequest object containing the domain, challenge type, random value or request token data, and validation state
      Returns:
      DomainValidationEvidence object containing the domain validation evidence
      Throws:
      ValidationException - if the File Validation fails.
      InputException - if the input parameters are invalid. See verifyFileValidationRequest(com.digicert.validation.methods.file.validate.FileValidationRequest)
      DcvException
    • createDomainValidationEvidence

      DomainValidationEvidence createDomainValidationEvidence(FileValidationRequest request, FileValidationResponse response)
      Create the Domain Validation Evidence from the File Validation Response

      This method creates a DomainValidationEvidence object from the provided FileValidationRequest and FileValidationResponse. It extracts the necessary information from the response and constructs the validation evidence, including the domain, DCV method, validation date, file URL, random value, and found token.

      Parameters:
      request - The File Validation Request
      response - The File Validation Response
      Returns:
      The Domain Validation Evidence
    • verifyFileValidationRequest

      void verifyFileValidationRequest(FileValidationRequest fileValidationRequest) throws DcvException
      Performs validation on the values in FileValidationRequest.

      This method validates the values in the provided FileValidationRequest. It checks the domain, validation state, and challenge type, ensuring that all required fields are present and valid. For random values, it verifies the entropy and expiration. For request tokens, it checks the presence of the request token data.

      Parameters:
      fileValidationRequest - The validation verification request
      Throws:
      DcvException - If entropy level is insufficient, the random value has expired, or the request token data is missing.
    • verifyFilePreparation

      private void verifyFilePreparation(FilePreparationRequest filePreparationRequest) throws DcvException, IllegalArgumentException
      Verify the File Preparation Request

      This method verifies the provided FilePreparationRequest to ensure that all required fields are present and valid. It checks the domain name and challenge type, ensuring that the domain name is correctly formatted and does not contain wildcards.

      Parameters:
      filePreparationRequest - The File Preparation Request
      Throws:
      DcvException - if the request is invalid. InputException when missing required fields.
      IllegalArgumentException
    • getFileUrl

      String getFileUrl(String domainName, String fileName)
      Generate a URL for the where file will be placed on the server

      This method updates the required URL with the appropriate domain name and filename.

      Parameters:
      domainName - The domain name for which the file validation is being prepared
      fileName - The name of the file to be used in the URL
      Returns:
      The URL where the file will be placed