Class FileValidator
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final StringDefault filename for the file validationprivate final DomainNameUtilsUtility class for domain name operationsprivate static final StringFile location based on the BR specificationsprivate final FileValidationHandlerHandler for File Validationprivate final org.slf4j.event.LevelThe log level used for logging errors related to domain control validation (DCV).private final RandomValueGeneratorUtility class for generating random valuesprivate final RandomValueVerifierUtility class for random value verification -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) DomainValidationEvidencecreateDomainValidationEvidence(FileValidationRequest request, FileValidationResponse response) Create the Domain Validation Evidence from the File Validation Response(package private) StringgetFileUrl(String domainName, String fileName) Generate a URL for the where file will be placed on the serverprepare(FilePreparationRequest preparationRequest) Prepare for file validation.validate(FileValidationRequest validationRequest) Perform File Validationprivate voidverifyFilePreparation(FilePreparationRequest filePreparationRequest) Verify the File Preparation Request(package private) voidverifyFileValidationRequest(FileValidationRequest fileValidationRequest) Performs validation on the values inFileValidationRequest.
-
Field Details
-
randomValueGenerator
Utility class for generating random valuesThis utility class is used to generate random values that are required during the file-based domain validation process.
-
randomValueVerifier
Utility class for random value verificationThis 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
Utility class for domain name operationsThis utility class provides various operations related to domain names, such as validation and manipulation.
-
fileValidationHandler
Handler for File ValidationThis handler is responsible for executing the file-based domain validation process.
-
FILE_LOCATION
File location based on the BR specificationsThis string is combined with the submitted domain name and file location to create the URL where the file will be placed.
- See Also:
-
defaultFilename
Default filename for the file validationIf no filename is specified in the request, the default filename specified in the dcvConfiguration will be used.
-
logLevelForDcvErrors
private final org.slf4j.event.Level logLevelForDcvErrorsThe log level used for logging errors related to domain control validation (DCV).
-
-
Constructor Details
-
FileValidator
Constructor for FileValidatorInitializes 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-FilePreparationRequestobject containing the domain and challenge type- Returns:
FilePreparationResponseobject containing the random value and domain- Throws:
DcvException- if the request is invalid.InputExceptionwhen missing required fields.
-
validate
public DomainValidationEvidence validate(FileValidationRequest validationRequest) throws DcvException Perform File ValidationThis 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
DomainValidationEvidenceobject containing the validation evidence. If the validation fails, it throws aValidationExceptionwith the encountered errors.- Parameters:
validationRequest-FileValidationRequestobject containing the domain, challenge type, random value or request token data, and validation state- Returns:
DomainValidationEvidenceobject containing the domain validation evidence- Throws:
ValidationException- if the File Validation fails.InputException- if the input parameters are invalid. SeeverifyFileValidationRequest(com.digicert.validation.methods.file.validate.FileValidationRequest)DcvException
-
createDomainValidationEvidence
DomainValidationEvidence createDomainValidationEvidence(FileValidationRequest request, FileValidationResponse response) Create the Domain Validation Evidence from the File Validation ResponseThis method creates a
DomainValidationEvidenceobject from the providedFileValidationRequestandFileValidationResponse. 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 Requestresponse- The File Validation Response- Returns:
- The Domain Validation Evidence
-
verifyFileValidationRequest
Performs validation on the values inFileValidationRequest.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 RequestThis method verifies the provided
FilePreparationRequestto 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.InputExceptionwhen missing required fields.IllegalArgumentException
-
getFileUrl
Generate a URL for the where file will be placed on the serverThis method updates the required URL with the appropriate domain name and filename.
- Parameters:
domainName- The domain name for which the file validation is being preparedfileName- The name of the file to be used in the URL- Returns:
- The URL where the file will be placed
-