Exemplo n.º 1
0
  public static boolean hasFullLicence() {
    if (featman == null) {
      // Debug.out("featman null");
      Set<String> featuresInstalled = UtilitiesImpl.getFeaturesInstalled();
      return featuresInstalled.contains("dvdburn");
    }

    boolean full = false;
    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      int state = fd.getLicence().getState();
      if (state == Licence.LS_CANCELLED || state == Licence.LS_REVOKED) {
        continue;
      }
      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      if (lValidUntil != null && lValidUntil.longValue() >= now) {
        full = true;
        break;
      }
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);
      if (lValidOfflineUntil != null && lValidOfflineUntil.longValue() >= now) {
        full = true;
        break;
      }
    }

    return full;
  }
Exemplo n.º 2
0
  public static licenceDetails getFullFeatureDetails() {
    if (featman == null) {
      Debug.out("featman null");
      return null;
    }

    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      if (lValidUntil != null && lValidUntil.longValue() >= now) {
        return new licenceDetails(
            lValidUntil.longValue(), fd.getLicence().getKey(), fd.getLicence().getState());
      }
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);
      if (lValidOfflineUntil != null && lValidOfflineUntil.longValue() >= now) {
        return new licenceDetails(
            lValidOfflineUntil.longValue(), fd.getLicence().getKey(), fd.getLicence().getState());
      }
    }

    Licence bestLicence = null;
    Licence[] licences = featman.getLicences();
    for (Licence licence : licences) {
      FeatureDetails[] details = licence.getFeatures();
      boolean isTrial = false;
      for (FeatureDetails fd : details) {
        Object property = fd.getProperty(FeatureDetails.PR_IS_TRIAL);
        if ((property instanceof Number) && ((Number) property).intValue() == 1) {
          isTrial = true;
          break;
        }
      }
      if (isTrial) {
        continue;
      }
      int state = licence.getState();
      if (state == Licence.LS_AUTHENTICATED) {
        bestLicence = licence;
        break;
      } else {
        bestLicence = licence;
      }
    }

    if (bestLicence != null) {
      return new licenceDetails(0, bestLicence.getKey(), bestLicence.getState());
    }

    return null;
  }
Exemplo n.º 3
0
 public static long getExpiresOn(TOTorrent torrent) {
   Map mapContent = getContentMap(torrent);
   Long l = (Long) mapContent.get(TOR_AZ_PROP_EXPIRESON);
   if (l == null) {
     return 0;
   }
   return l.longValue();
 }
Exemplo n.º 4
0
 public static long getMetaDataRefreshOn(TOTorrent torrent) {
   Map mapContent = getTempContentMap(torrent);
   Long l = (Long) mapContent.get(TOR_AZ_PROP_METADATA_REFRESHON);
   if (l == null) {
     return 0;
   }
   return l.longValue();
 }
Exemplo n.º 5
0
 private static long getRemainingUses(FeatureDetails fd) {
   if (fd == null) {
     return 0;
   }
   Long lRemainingUses = (Long) fd.getProperty(FeatureDetails.PR_TRIAL_USES_REMAINING);
   long remainingUses = lRemainingUses == null ? -1 : lRemainingUses.longValue();
   return remainingUses;
 }
Exemplo n.º 6
0
 public static boolean isTrial(FeatureDetails fd) {
   Long lIsTrial = (Long) fd.getProperty(FeatureDetails.PR_IS_TRIAL);
   return lIsTrial == null ? false : lIsTrial.longValue() != 0;
 }
Exemplo n.º 7
0
  public static licenceDetails getFullFeatureDetails() {
    if (featman == null) {
      Debug.out("featman null");
      return null;
    }

    TreeMap<Long, Object[]> mapOrder = new TreeMap<Long, Object[]>(Collections.reverseOrder());
    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      Licence licence = fd.getLicence();
      int state = licence.getState();
      if (state == Licence.LS_ACTIVATION_DENIED) {
        mapOrder.put(-1L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_CANCELLED) {
        mapOrder.put(-2L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_INVALID_KEY) {
        mapOrder.put(-3L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_REVOKED) {
        mapOrder.put(-4L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_PENDING_AUTHENTICATION) {
        mapOrder.put(-6L, new Object[] {licence, Long.valueOf(0)});
        continue;
      }

      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);

      if (lValidUntil == null && lValidOfflineUntil == null) {
        continue;
      }

      long minValidUntil = -1;
      long maxValidUntil = -1;
      if (lValidUntil != null) {
        minValidUntil = maxValidUntil = lValidUntil.longValue();
        if (minValidUntil < now) {
          mapOrder.put(minValidUntil, new Object[] {licence, Long.valueOf(minValidUntil)});
          continue;
        }
      }
      if (lValidOfflineUntil != null) {
        long validOfflineUntil = lValidOfflineUntil.longValue();
        if (validOfflineUntil < now) {
          mapOrder.put(validOfflineUntil, new Object[] {licence, Long.valueOf(maxValidUntil)});
          continue;
        }
        if (maxValidUntil == -1 || validOfflineUntil > maxValidUntil) {
          maxValidUntil = validOfflineUntil;
        }
      }

      mapOrder.put(maxValidUntil, new Object[] {licence, minValidUntil});
    }

    if (mapOrder.size() == 0) {
      return null;
    }

    Long firstKey = mapOrder.firstKey();
    Object[] objects = mapOrder.get(firstKey);
    Licence licence = (Licence) objects[0];
    return new licenceDetails(firstKey.longValue(), ((Long) objects[1]).longValue(), licence);
  }
 public long getLongParameter(String parameter, long defaultValue) {
   Long tempValue = getLongParameterRaw(parameter);
   return tempValue != null ? tempValue.longValue() : defaultValue;
 }
  protected void preProcessReply(Map reply, final boolean v6) {
    NetworkAdmin admin = NetworkAdmin.getSingleton();

    try {
      byte[] address = (byte[]) reply.get("source_ip_address");

      InetAddress my_ip = InetAddress.getByName(new String(address));

      NetworkAdminASN old_asn = admin.getCurrentASN();

      NetworkAdminASN new_asn = admin.lookupCurrentASN(my_ip);

      if (!new_asn.sameAs(old_asn)) {

        // kick off a secondary version check to communicate the new information

        if (!secondary_check_done) {

          secondary_check_done = true;

          new AEThread("Secondary version check", true) {
            public void runSupport() {
              getVersionCheckInfoSupport(REASON_SECONDARY_CHECK, false, true, v6);
            }
          }.start();
        }
      }
    } catch (Throwable e) {

      Debug.printStackTrace(e);
    }

    Long as_advice = (Long) reply.get("as_advice");

    if (as_advice != null) {

      NetworkAdminASN current_asn = admin.getCurrentASN();

      String asn = current_asn.getASName();

      if (asn != null) {

        long advice = as_advice.longValue();

        if (advice != 0) {

          // require crypto

          String done_asn = COConfigurationManager.getStringParameter("ASN Advice Followed", "");

          if (!done_asn.equals(asn)) {

            COConfigurationManager.setParameter("ASN Advice Followed", asn);

            boolean change = advice == 1 || advice == 2;
            boolean alert = advice == 1 || advice == 3;

            if (!COConfigurationManager.getBooleanParameter(
                "network.transport.encrypted.require")) {

              if (change) {

                COConfigurationManager.setParameter("network.transport.encrypted.require", true);
              }

              if (alert) {

                String msg = MessageText.getString("crypto.alert.as.warning", new String[] {asn});

                Logger.log(new LogAlert(false, LogAlert.AT_WARNING, msg));
              }
            }
          }
        }
      }
    }

    // set ui.toolbar.uiswitcher based on instructions from tracker
    // Really shouldn't be in VersionCheck client, but instead have some
    // listener and have the code elsewhere.  Simply calling
    // getVersionCheckInfo from "code elsewhere" (to get the cached result)
    // caused a deadlock at startup.
    Long lEnabledUISwitcher = (Long) reply.get("ui.toolbar.uiswitcher");
    if (lEnabledUISwitcher != null) {
      COConfigurationManager.setBooleanDefault(
          "ui.toolbar.uiswitcher", lEnabledUISwitcher.longValue() == 1);
    }
  }