Example #1
0
  public boolean validateLicence() {
    if (this.readFlag) {
      return (this.isValidLicense);
    }

    getXMLElements();
    boolean flag = false;
    synchronized (lock) {
      if (validateIP()) {
        String s = new String();
        for (Enumeration e = Modules.elements(); e.hasMoreElements(); ) {
          ModuleLicenceInfo ml = ((ModuleLicenceInfo) e.nextElement());
          s += ml.getName();
          s += ml.getType();
          s += ml.getNo();
        }
        s += Info.getIp();
        s += Info.getExpDate();
        s += Info.getVersion();
        try {
          if (TextUtility.encodeObject(md5util.getDigest(s))
              .equals(Info.getKey().trim().toString())) {
            flag = true;
          }
        } catch (Exception e) {
          log.error(Priority.INFO, e);
        }
      }
      /*
            if (!flag) {
              for (Enumeration e = Modules.elements(); e.hasMoreElements(); ) {
                ModuleLicenceInfo ml = ( (ModuleLicenceInfo) e.nextElement());
                ml.setNo(-1);
              }
            }
      */
      this.isValidLicense = flag;
    }
    return flag;
  }
Example #2
0
  private void getXMLElements() {
    synchronized (lock) {
      if (this.readFlag) {
        return;
      }

      document = null;
      Modules = new Hashtable();
      Info = new LicenceInfo();
      log.info("License File Path: " + path);
      XMLfile = new XMLUtility(path);

      try {
        NodeList rootlist = XMLfile.getNodeListByTagName("MODULE");
        for (int intloop = 0; intloop < rootlist.getLength(); intloop++) {
          ModuleLicenceInfo ml = new ModuleLicenceInfo();
          Element node = (Element) rootlist.item(intloop);

          ml.setName(
              node.getElementsByTagName("MODULE_CODE")
                  .item(0)
                  .getChildNodes()
                  .item(0)
                  .getNodeValue());
          if (node.getElementsByTagName("CONCURRENT_USER") != null
              && node.getElementsByTagName("CONCURRENT_USER").getLength() > 0) {
            ml.setType("CONCURRENT_USER");
            ml.setNo(
                Integer.parseInt(
                    node.getElementsByTagName("CONCURRENT_USER")
                        .item(0)
                        .getChildNodes()
                        .item(0)
                        .getNodeValue()));
          } else {
            ml.setType("NAMED_USER");
            ml.setNo(
                Integer.parseInt(
                    node.getElementsByTagName("NAMED_USER")
                        .item(0)
                        .getChildNodes()
                        .item(0)
                        .getNodeValue()));
          }
          log.info(ml.getName() + ":" + ml.getType() + ":" + ml.getNo());
          Modules.put(ml.getName(), ml);
        }

        Element infoNode = (Element) XMLfile.getNodeListByTagName("INFORMATION").item(0);
        Info = new LicenceInfo();
        Info.setKey(
            infoNode
                .getElementsByTagName("LICENSE_KEY")
                .item(0)
                .getChildNodes()
                .item(0)
                .getNodeValue());
        Info.setExpDate(
            infoNode
                .getElementsByTagName("EXPIRY_DATE")
                .item(0)
                .getChildNodes()
                .item(0)
                .getNodeValue());
        Info.setIp(
            infoNode
                .getElementsByTagName("HOST_IP")
                .item(0)
                .getChildNodes()
                .item(0)
                .getNodeValue());
        Info.setComName(
            infoNode
                .getElementsByTagName("COMPANY_NAME")
                .item(0)
                .getChildNodes()
                .item(0)
                .getNodeValue());
        Info.setVersion(
            infoNode
                .getElementsByTagName("VERSION")
                .item(0)
                .getChildNodes()
                .item(0)
                .getNodeValue());
        log.info("License Key: " + Info.getKey());
        log.info("Expiry Date: " + Info.getExpDate());
        log.info("Host IP    : " + Info.getIp());
        log.info("Company    : " + Info.getComName());
        log.info("Version    : " + Info.getVersion());

        this.readFlag = true;
      } catch (Exception e) {
        log.error("Error in parsing License File.", e);
      }
    }
  }
Example #3
0
 public String getModuleLicenceInfoType(String name) {
   ModuleLicenceInfo ml = (ModuleLicenceInfo) Modules.get(name);
   if (ml != null) return ml.getType();
   else return "N/A";
 }