private boolean checkCertificate(String line) {
    Matcher certificateErrorMatcher = ERROR_VALIDATING_CERTIFICATE_MESSAGE.matcher(line);
    Matcher certificateInfoMatcher = CERTIFICATE_INFORMATION_MESSAGE.matcher(line);
    Matcher acceptCertificateMatcher = ACCEPT_CERTIFICATE_PROMPT.matcher(line);

    if (certificateErrorMatcher.matches()) {
      serverUrl = certificateErrorMatcher.group(1);
      setCollectingMode(false, true);
    }
    else if (certificateInfoMatcher.matches()) {
      setCollectingMode(true, false);
    }
    else if (acceptCertificateMatcher.matches()) {
      setCollectingMode(false, false);
      handleAcceptCertificatePrompt();
    }
    else if (collectingCertificateError) {
      certificateError.append(line);
    }
    else if (collectingCertificateInfo) {
      certificateInfo.append(line);
    }

    return certificateErrorMatcher.matches() ||
           certificateInfoMatcher.matches() ||
           acceptCertificateMatcher.matches() ||
           collectingCertificateError ||
           collectingCertificateInfo;
  }
private boolean checkCertificate(String line)