Exemplo 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();
  }
Exemplo n.º 2
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);
  }