Class FileValidationHandler
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The default file validation filename.private static final String
The path to the file containing the challenge value.private FileClient
The file validation client.private final boolean
The flag to check if the file validation request should be made over HTTPS.private final RandomValueValidator
The random value validator used to confirm that the file text contains the expected random value.private final RequestTokenValidator
The request token validator used to confirm that the file text contains a valid request token. -
Constructor Summary
ConstructorsConstructorDescriptionFileValidationHandler
(DcvContext dcvContext) Constructs a new FileValidationHandler with the specified configuration. -
Method Summary
Modifier and TypeMethodDescriptiongetErrorsFromFileClientResponse
(FileClientResponse fileClientResponse) Checks if the file client response is valid.getFileUrls
(FileValidationRequest fileValidationRequest) Retrieves the list of file URLs for the file-based domain control validation (DCV) request.private ChallengeValidationResponse
getValidChallengeResponse
(FileValidationRequest fileValidationRequest, String fileContent) Validates the presence of the random value or a valid request token in the provided file content.validate
(FileValidationRequest validationRequest) Validates the file-based domain control validation (DCV) request.
-
Field Details
-
fileClient
The file validation client. -
randomValueValidator
The random value validator used to confirm that the file text contains the expected random value. -
requestTokenValidator
The request token validator used to confirm that the file text contains a valid request token. -
FILE_PATH
The path to the file containing the challenge value.- See Also:
-
defaultFileValidationFilename
The default file validation filename. -
fileValidationCheckHttps
private final boolean fileValidationCheckHttpsThe flag to check if the file validation request should be made over HTTPS.
-
-
Constructor Details
-
FileValidationHandler
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
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 requestfileContent
- 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
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
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
-