public PackageMaterialProperties repositoryConfiguration() {
   PackageMaterialProperties repositoryConfigurationResponse = new PackageMaterialProperties();
   repositoryConfigurationResponse.addPackageMaterialProperty(Constants.REPO_URL, url());
   repositoryConfigurationResponse.addPackageMaterialProperty(Constants.USERNAME, username());
   repositoryConfigurationResponse.addPackageMaterialProperty(Constants.PASSWORD, password());
   return repositoryConfigurationResponse;
 }
  private void validateKeys(
      PackageMaterialProperties configDefinedByPlugin,
      PackageMaterialProperties configProvidedByUser,
      ValidationResultMessage validationResultMessage) {
    List<String> invalidKeys = new ArrayList<String>();

    for (String key : configProvidedByUser.keys()) {
      if (!configDefinedByPlugin.hasKey(key)) {
        invalidKeys.add(key);
      }
    }
    if (!invalidKeys.isEmpty()) {
      validationResultMessage.addError(
          create(
              String.format(
                  "Unsupported key(s) found : %s. Allowed key(s) are : %s",
                  join(invalidKeys), join(configDefinedByPlugin.keys()))));
    }
  }
  public ValidationResultMessage validateRepositoryConfiguration(
      PackageMaterialProperties configurationProvidedByUser) {
    ValidationResultMessage validationResultMessage = new ValidationResultMessage();
    validateKeys(repositoryConfiguration(), configurationProvidedByUser, validationResultMessage);
    PackageMaterialProperty repositoryUrl =
        configurationProvidedByUser.getProperty(Constants.REPO_URL);
    PackageMaterialProperty username = configurationProvidedByUser.getProperty(Constants.USERNAME);
    PackageMaterialProperty password = configurationProvidedByUser.getProperty(Constants.PASSWORD);

    if (repositoryUrl == null) {
      validationResultMessage.addError(
          ValidationError.create(Constants.REPO_URL, "Repository url not specified"));
      return validationResultMessage;
    }
    String usernameValue = username == null ? null : username.value();
    String passwordValue = password == null ? null : password.value();

    new RepoUrl(repositoryUrl.value(), usernameValue, passwordValue)
        .validate(validationResultMessage);

    return validationResultMessage;
  }
 public ValidationResultMessage validatePackageConfiguration(
     PackageMaterialProperties configurationProvidedByUser) {
   ValidationResultMessage validationResultMessage = new ValidationResultMessage();
   validateKeys(packageConfiguration(), configurationProvidedByUser, validationResultMessage);
   PackageMaterialProperty artifactIdConfiguration =
       configurationProvidedByUser.getProperty(Constants.PACKAGE_SPEC);
   if (artifactIdConfiguration == null) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec not specified"));
     return validationResultMessage;
   }
   String packageSpec = artifactIdConfiguration.value();
   if (packageSpec == null) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec is null"));
     return validationResultMessage;
   }
   if (isBlank(packageSpec.trim())) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec is empty"));
     return validationResultMessage;
   }
   return validationResultMessage;
 }
 public PackageMaterialProperties packageConfiguration() {
   PackageMaterialProperties packageConfigurationResponse = new PackageMaterialProperties();
   packageConfigurationResponse.addPackageMaterialProperty(Constants.PACKAGE_SPEC, packageSpec());
   return packageConfigurationResponse;
 }