private static Collection<ExternalComponentConfiguration> getConfigurations(
      Permission permission) {

    Collection<ExternalComponentConfiguration> answer =
        new ArrayList<ExternalComponentConfiguration>();

    java.sql.Connection con = null;

    PreparedStatement pstmt = null;

    try {

      con = DbConnectionManager.getConnection();

      pstmt = con.prepareStatement(LOAD_CONFIGURATIONS);

      pstmt.setString(1, permission.toString());

      ResultSet rs = pstmt.executeQuery();

      ExternalComponentConfiguration configuration;

      while (rs.next()) {

        configuration = new ExternalComponentConfiguration(rs.getString(1));

        configuration.setSecret(rs.getString(2));

        configuration.setPermission(permission);

        answer.add(configuration);
      }

      rs.close();

    } catch (SQLException sqle) {

      Log.error(sqle);

    } finally {

      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
        Log.error(e);
      }

      try {
        if (con != null) con.close();
      } catch (Exception e) {
        Log.error(e);
      }
    }

    return answer;
  }
  /**
   * Returns the configuration for an external component.
   *
   * @param subdomain the subdomain of the external component.
   * @return the configuration for an external component.
   */
  public static ExternalComponentConfiguration getConfiguration(String subdomain) {

    ExternalComponentConfiguration configuration = null;

    java.sql.Connection con = null;

    PreparedStatement pstmt = null;

    try {

      con = DbConnectionManager.getConnection();

      pstmt = con.prepareStatement(LOAD_CONFIGURATION);

      pstmt.setString(1, subdomain);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {

        configuration = new ExternalComponentConfiguration(subdomain);

        configuration.setSecret(rs.getString(1));

        configuration.setPermission(Permission.valueOf(rs.getString(2)));
      }

      rs.close();

    } catch (SQLException sqle) {

      Log.error(sqle);

    } finally {

      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
        Log.error(e);
      }

      try {
        if (con != null) con.close();
      } catch (Exception e) {
        Log.error(e);
      }
    }

    return configuration;
  }