Пример #1
0
    public FormValidation doCheckPrivate_key_file_path(@QueryParameter String value) {
      if (value.length() == 0) {
        return FormValidation.error("Please set a path to private key file");
      }
      File f = new File(value);
      if (!f.exists()) {
        return FormValidation.error("File doesn't exists");
      }
      if (!SSHMarker.IsPrivateKeyFileValid(f)) {
        return FormValidation.error("Private key file is not valid");
      }
      path_to_private_key_file = value;

      return FormValidation.ok();
    }
Пример #2
0
    public FormValidation doCheckPassPhrase(@QueryParameter String value) {

      if (path_to_private_key_file == null) {
        return FormValidation.error("Define path to private key file first");
      }
      File f = new File(path_to_private_key_file);
      if (!f.exists()) {
        return FormValidation.error("No private key file");
      }
      if (!SSHMarker.IsPrivateKeyFileValid(f)) {
        return FormValidation.error("Private key file is not valid");
      }
      if (!SSHMarker.CheckPassPhrase(f, value)) {
        return FormValidation.error("Passphrase is not valid");
      }
      return FormValidation.ok();
    }