Exemplo n.º 1
0
    public void validateSmtp() {
      Validation.required("setup.smtpServer", smtpServer);

      if (HostNameOrIpAddressCheck.isValidHostName(smtpServer)) {
        if (PropertiesConfigurationValidator.validateIpList(nameservers)) {
          Set<String> ips = Sets.newHashSet(nameservers.split(","));
          if (!DnsUtils.validateHostname(ips, smtpServer)) {
            Validation.addError("setup.smtpServer", "setup.smtpServer.invalidSmtpServer");
          }
        } else if (StringUtils.isNotEmpty(nameservers)) {
          Validation.addError(
              "setup.nameservers", "setup.smtpServer.invalidNameserver", nameservers);
        }
      }

      if (!HostNameOrIpAddressCheck.isValidHostNameOrIp(smtpServer)) {
        Validation.addError("setup.smtpServer", "setup.smtpServer.invalid");
      }
      if (!StringUtils.isNumeric(smtpPort)) {
        Validation.addError("setup.smtpServer", "setup.smtpServer.invalidPort");
      }

      Validation.required("setup.smtpFrom", smtpFrom);
      Validation.email("setup.smtpFrom", smtpFrom);

      if (StringUtils.isNotBlank(smtpAuthType)
          && !StringUtils.equalsIgnoreCase(smtpAuthType, "None")) {
        Validation.required("setup.smtpUsername", smtpUsername);
        Validation.required("setup.smtpPassword", smtpPassword);

        if (PasswordUtil.isNotValid(smtpPassword)) {
          Validation.addError("setup.smtpPassword", "setup.password.notValid");
        }
      }
    }
Exemplo n.º 2
0
    public void validate() {
      if (!PropertiesConfigurationValidator.validateIpList(nameservers)) {
        Validation.addError("setup.nameservers", "configProperties.error.iplist");
      }
      if (!PropertiesConfigurationValidator.validateIpList(ntpservers)) {
        Validation.addError("setup.ntpservers", "configProperties.error.iplist");
      }

      validatePasswords();

      if (StringUtils.isNotBlank(smtpServer)
          || StringUtils.equalsIgnoreCase(connectEmcTransport, "SMTP")) {
        validateSmtp();
      }

      if (!SetupUtils.isOssBuild()) {
        Validation.required("setup.connectEmcTransport", connectEmcTransport);

        if (!StringUtils.equalsIgnoreCase(connectEmcTransport, "None")) {
          Validation.required("setup.connectEmcNotifyEmail", connectEmcNotifyEmail);
          Validation.email("setup.connectEmcNotifyEmail", connectEmcNotifyEmail);
        }
      }
    }