protected ValidationInfo doValidate()

in PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-hdinsight-base/src/main/java/com/microsoft/intellij/ui/NewCertificateDialog.java [108:151]


    protected ValidationInfo doValidate() {
        if (txtPwd.getPassword().length == 0) {
            return new ValidationInfo(message("newCertDlgPwNul"), txtPwd);
        } else if (txtConfirmPwd.getPassword().length == 0) {
            return new ValidationInfo(message("newCertDlgPwNul"), txtPwd);
        }
        Pattern pattern = Pattern.compile("^\\S+$");
        Matcher match = pattern.matcher(String.valueOf(txtPwd.getPassword()));
        if (!match.find()) {
            return new ValidationInfo(message("newCertDlgPwNtCor"), txtPwd);
        }
        match = pattern.matcher(String.valueOf(txtConfirmPwd.getPassword()));
        if (!match.find()) {
            return new ValidationInfo(message("newCertDlgPwNtCor"), txtPwd);
        }
        if (!Arrays.equals(txtPwd.getPassword(), txtConfirmPwd.getPassword())) {
            return new ValidationInfo(message("newCerDlgPwNtMsg"));
        }
        if (txtCNName.getText().isEmpty()) {
            return new ValidationInfo(message("newCertDlgCNNull"), txtCNName);
        }
        if (txtCertFile.getText().isEmpty()) {
            return new ValidationInfo(message("newCertDlgCerNul"), txtCertFile);
        }
        if (txtPFXFile.getText().isEmpty()) {
            return new ValidationInfo(message("newCertDlgPFXNull"), txtPFXFile);
        }
        String certFilePath = txtCertFile.getText();
        String pfxFilePath = txtPFXFile.getText();
        if (certFilePath.lastIndexOf(File.separator) == -1 || pfxFilePath.lastIndexOf(File.separator) == -1) {
            return new ValidationInfo(message("newCerDlgInvldPth"));
        }
        if ((!certFilePath.endsWith(".cer")) || (!pfxFilePath.endsWith(".pfx"))) {
            return new ValidationInfo(message("newCerDlgInvdFlExt"));
        }
        String certFolder = certFilePath.substring(0, certFilePath.lastIndexOf(File.separator));
        String pfxFolder = pfxFilePath.substring(0, pfxFilePath.lastIndexOf(File.separator));
        File certFile = new File(certFolder);
        File pfxFile = new File(pfxFolder);
        if (!(certFile.exists() && pfxFile.exists())) {
            return new ValidationInfo(message("newCerDlgInvldPth"));
        }
        return null;
    }