예제 #1
0
  public boolean showSetQuality(
      String tvdbid, EnumSet<Show.Quality> initial, EnumSet<Show.Quality> archive)
      throws Exception {
    StringBuilder builder = new StringBuilder("show.setquality");
    builder.append("&tvdbid=");
    builder.append(tvdbid);
    if (initial != null) {
      builder.append("&initial=");
      Iterator<Quality> iter = initial.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }
    if (archive != null) {
      builder.append("&archive=");
      Iterator<Quality> iter = archive.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }

    return this.<Object>commandSuccessful(
        builder.toString(), new TypeToken<JsonResponse<Object>>() {}.getType());
  }
예제 #2
0
  public boolean showAddNew(
      String tvdbid,
      Language language,
      Boolean seasonFolders,
      Status status,
      EnumSet<Show.Quality> initial,
      EnumSet<Quality> archive)
      throws Exception {
    StringBuilder builder = new StringBuilder("show.addnew");
    builder.append("&tvdbid=");
    builder.append(tvdbid);
    if (language != null) {
      builder.append("&lang=");
      builder.append(language.getAbbrev());
    }
    if (seasonFolders != null) {
      // the option isnt called season folders anymore
      if (apiVersion >= 3) {
        builder.append("&flatten_folders=");
      } else {
        builder.append("&season_folder=");
      }
      // if you pass me a boolean you better damn well have checked the version number
      builder.append(seasonFolders ? "1" : "0");
    }
    if (status != null) {
      builder.append("&status=");
      builder.append(status.toJson());
    }
    if (initial != null) {
      builder.append("&initial=");
      Iterator<Quality> iter = initial.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }
    if (archive != null) {
      builder.append("&archive=");
      Iterator<Show.Quality> iter = archive.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }

    return this.<Object>commandSuccessful(
        builder.toString(), new TypeToken<JsonResponse<Object>>() {}.getType());
  }
예제 #3
0
  /*
   * Get the active protocol versions.
   *
   * In TLS 1.1, many weak or vulnerable cipher suites were obsoleted,
   * such as TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT
   * negotiate these cipher suites in TLS 1.1 or later mode.
   *
   * For example, if "TLS_RSA_EXPORT_WITH_RC4_40_MD5" is the
   * only enabled cipher suite, the client cannot request TLS 1.1 or
   * later, even though TLS 1.1 or later is enabled.  We need to create a
   * subset of the enabled protocols, called the active protocols, which
   * contains protocols appropriate to the list of enabled Ciphersuites.
   *
   * Return empty list instead of null if no active protocol versions.
   */
  ProtocolList getActiveProtocols() {
    if (activeProtocols == null) {
      ArrayList<ProtocolVersion> protocols = new ArrayList<>(4);
      for (ProtocolVersion protocol : enabledProtocols.collection()) {
        boolean found = false;
        for (CipherSuite suite : enabledCipherSuites.collection()) {
          if (suite.isAvailable()
              && suite.obsoleted > protocol.v
              && suite.supported <= protocol.v) {
            if (algorithmConstraints.permits(
                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
              protocols.add(protocol);
              found = true;
              break;
            } else if (debug != null && Debug.isOn("verbose")) {
              System.out.println("Ignoring disabled cipher suite: " + suite + " for " + protocol);
            }
          } else if (debug != null && Debug.isOn("verbose")) {
            System.out.println("Ignoring unsupported cipher suite: " + suite + " for " + protocol);
          }
        }
        if (!found && (debug != null) && Debug.isOn("handshake")) {
          System.out.println("No available cipher suite for " + protocol);
        }
      }
      activeProtocols = new ProtocolList(protocols);
    }

    return activeProtocols;
  }
예제 #4
0
  /**
   * Get the active cipher suites.
   *
   * <p>In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, such as
   * TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT negotiate these cipher suites in
   * TLS 1.1 or later mode.
   *
   * <p>Therefore, when the active protocols only include TLS 1.1 or later, the client cannot
   * request to negotiate those obsoleted cipher suites. That is, the obsoleted suites should not be
   * included in the client hello. So we need to create a subset of the enabled cipher suites, the
   * active cipher suites, which does not contain obsoleted cipher suites of the minimum active
   * protocol.
   *
   * <p>Return empty list instead of null if no active cipher suites.
   */
  CipherSuiteList getActiveCipherSuites() {
    if (activeCipherSuites == null) {
      if (activeProtocols == null) {
        activeProtocols = getActiveProtocols();
      }

      ArrayList<CipherSuite> suites = new ArrayList<>();
      if (!(activeProtocols.collection().isEmpty())
          && activeProtocols.min.v != ProtocolVersion.NONE.v) {
        for (CipherSuite suite : enabledCipherSuites.collection()) {
          if (suite.obsoleted > activeProtocols.min.v && suite.supported <= activeProtocols.max.v) {
            if (algorithmConstraints.permits(
                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
              suites.add(suite);
            }
          } else if (debug != null && Debug.isOn("verbose")) {
            if (suite.obsoleted <= activeProtocols.min.v) {
              System.out.println("Ignoring obsoleted cipher suite: " + suite);
            } else {
              System.out.println("Ignoring unsupported cipher suite: " + suite);
            }
          }
        }
      }
      activeCipherSuites = new CipherSuiteList(suites);
    }

    return activeCipherSuites;
  }