Ejemplo n.º 1
0
  /** Store the keystore to a file. */
  public void store() throws Exception {
    Enumeration elementEnum = _licences.elements();

    if (_file == null) create();

    FileWriter writer = new FileWriter(_file);

    while (elementEnum.hasMoreElements()) {
      LicenceKey l = (LicenceKey) elementEnum.nextElement();
      ActivationKey a = (ActivationKey) _keys.get(l);

      writer.write(l.toString());
      if (a != null) writer.write(a.toString());

      // This should not be null
      if (_publicGroup.equals(new Boolean("true"))) writer.write("1");
      else writer.write("0");

      String strInstallationRef =
          getAdjustInstallationReferenceNumber(_installationReferenceNumber);
      writer.write(strInstallationRef);

      String availableMessages = getAdjustPublicMessages(getAvailablePublicMessages());
      writer.write(availableMessages);

      if (_registeredEmailAddress != null) {
        writer.write(_registeredEmailAddress);
      }
    }

    writer.close();
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    String communityLogo = "PoweredByOpenbravo.png";
    String opsLogo = "PoweredByOpenbravoOPS.png";

    // get instance active status from db
    boolean active = false;
    OBContext.setAdminMode();
    try {
      active = ActivationKey.getInstance().isActive();
      log4j.debug("GetOpsLogo: activated: " + active);
    } finally {
      OBContext.restorePreviousMode();
    }

    String activeLogo;
    if (active) {
      activeLogo = opsLogo;
    } else {
      activeLogo = communityLogo;
    }

    FileUtility f =
        new FileUtility(this.globalParameters.prefix + "web/images", activeLogo, false, true);
    response.setContentType("image/png");
    // mark response as cache-forever
    response.addHeader("Expires", "Sun, 17 Jan 2038 19:14:07 GMT");
    response.addHeader("Cache-Control", "public");

    f.dumpFile(response.getOutputStream());
    response.getOutputStream().flush();
    response.getOutputStream().close();
  }
Ejemplo n.º 3
0
  /**
   * Add/update an activation key tot the store. Throws an InvalidKeyException if null is passed or
   * the key is invalid (not verified)
   */
  public void setActivationKey(LicenceKey lKey, ActivationKey aKey) throws InvalidKeyException {
    if (lKey == null) throw new InvalidKeyException("Licence key cannot be set to null");

    if (aKey == null) throw new InvalidKeyException("Activation key cannot be set to null");

    if (!aKey.verifyChecksum())
      throw new InvalidKeyException("Activation key checksum does not verify");

    setLicenceKey(lKey);
    _keys.put(lKey, aKey);
  }