Package org.openbravo.erpCommon.obps

Examples of org.openbravo.erpCommon.obps.ActivationKey


    // Role
    OBContext.enableAsAdminContext();
    RoleComboData[] datarole = null;
    try {
      ActivationKey ak = new ActivationKey();
      LicenseRestriction limitation = ak.checkOPSLimitations(vars.getDBSession());
      if (limitation == LicenseRestriction.OPS_INSTANCE_NOT_ACTIVE
          || limitation == LicenseRestriction.NUMBER_OF_CONCURRENT_USERS_REACHED
          || limitation == LicenseRestriction.MODULE_EXPIRED) {
        // allow only system login
        datarole = RoleComboData.selectSystem(this, vars.getUser());
View Full Code Here


    if (log4j.isDebugEnabled())
      log4j.debug("Output: dataSheet");

    boolean adminMode = OBContext.getOBContext().setInAdministratorMode(true);
    try {
      ActivationKey ak = new ActivationKey();
      response.setContentType("text/html; charset=UTF-8");
      PrintWriter out = response.getWriter();
      String discard[] = { "", "" };
      AboutData[] data = AboutData.selectTranslators(this);
      AboutData ver = AboutData.select(this);
      XmlDocument xmlDocument = null;
      if (data.length == 0) {
        discard[0] = "discard";
        data = AboutData.set();
      }
      String licenseInfo = "";
      if (ActivationKey.isActiveInstance()) {
        licenseInfo = Utility.messageBD(this, "OPSLicensedTo", vars.getLanguage()) + " "
            + ak.getProperty("customer");
      } else {
        licenseInfo = Utility.messageBD(this, "OPSCommunityEdition", vars.getLanguage());

        discard[1] = "paramOPSInfo";
      }
      xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_forms/About", discard)
          .createXmlDocument();

      String version = ver.version.substring(0, ver.version.lastIndexOf(".")) + " "
          + ver.versionLabel;

      xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
      xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
      xmlDocument.setParameter("theme", vars.getTheme());
      xmlDocument.setParameter("paramLicensedTo", licenseInfo);
      xmlDocument.setData("structure1", data);
      xmlDocument.setParameter("ver", version);
      xmlDocument.setParameter("versionId", ver.versionId);
      xmlDocument.setParameter("versionNo", ver.version);

      if (ActivationKey.isActiveInstance()) {
        xmlDocument.setParameter("paraOPSPurpose", ak.getPurpose(vars.getLanguage()));
        xmlDocument.setParameter("paraOPSType", ak.getLicenseExplanation(this, vars.getLanguage()));
      }

      out.println(xmlDocument.print());
      out.close();
    } finally {
View Full Code Here

    try {
      URL url = new URL(strUrl);
      HttpURLConnection conn = null;

      if (strUrl.startsWith("https://")) {
        ActivationKey ak = new ActivationKey();
        String instanceKey = "obinstance=" + URLEncoder.encode(ak.getPublicKey(), "utf-8");
        conn = HttpsUtils.sendHttpsRequest(url, instanceKey, "localhost-1", "changeit");
      } else {
        conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("Keep-Alive", "300");
        conn.setRequestProperty("Connection", "keep-alive");
View Full Code Here

    out.close();
  }

  private boolean checkCommercialModules(ImportModule im, HttpServletResponse response,
      VariablesSecureApp vars) throws IOException {
    ActivationKey ak = new ActivationKey();
    boolean OBPSActiveInstance = ActivationKey.isActiveInstance();
    ArrayList<Module> notAllowedMods = new ArrayList<Module>();

    String notSubscribed = "";
    String expired = "";
    String notActiveYet = "";

    for (Module instMod : im.getModulesToInstall()) {
      if (instMod.getIsCommercial()) {
        if (!OBPSActiveInstance
            || ak.isModuleSubscribed(instMod.getModuleID()) == CommercialModuleStatus.NO_SUBSCRIBED) {
          if (notSubscribed.length() > 0) {
            notSubscribed += ", ";
          }
          notSubscribed += instMod.getName();
        } else if (ak.isModuleSubscribed(instMod.getModuleID()) == CommercialModuleStatus.EXPIRED) {
          if (expired.length() > 0) {
            expired += ", ";
          }
          expired += instMod.getName();
        } else if (ak.isModuleSubscribed(instMod.getModuleID()) == CommercialModuleStatus.NO_ACTIVE_YET) {
          if (notActiveYet.length() > 0) {
            notActiveYet += ", ";
          }
          notActiveYet += instMod.getName();
        }
      }
    }

    for (Module updMod : im.getModulesToUpdate()) {
      if (updMod.getIsCommercial()) {
        if (!OBPSActiveInstance
            || ak.isModuleSubscribed(updMod.getModuleID()) == CommercialModuleStatus.NO_SUBSCRIBED) {
          if (notSubscribed.length() > 0) {
            notSubscribed += ", ";
          }
          notSubscribed += updMod.getName();

        } else if (ak.isModuleSubscribed(updMod.getModuleID()) == CommercialModuleStatus.EXPIRED) {
          if (expired.length() > 0) {
            expired += ", ";
          }
          expired += updMod.getName();
        } else if (ak.isModuleSubscribed(updMod.getModuleID()) == CommercialModuleStatus.NO_ACTIVE_YET) {
          if (notActiveYet.length() > 0) {
            notActiveYet += ", ";
          }
          notActiveYet += updMod.getName();
        }
View Full Code Here

  }

  private void printPageNotActive(HttpServletResponse response, VariablesSecureApp vars)
      throws IOException, ServletException {

    ActivationKey activationKey = new ActivationKey();
    response.setContentType("text/html; charset=UTF-8");
    String discard[] = { "", "" };
    if (activationKey.isOPSInstance()) {
      if (activationKey.hasExpired()) {
        // Renew
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      } else {
        // Refresh
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      }
    } else {
      // Activate
      discard[0] = "OPSRefresh";
      discard[1] = "OPSRenew";
    }

    final PrintWriter out = response.getWriter();
    final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
        "org/openbravo/erpCommon/ad_forms/InstanceManagementActivateOnline", discard)
        .createXmlDocument();
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
    // Interface parameters
    final ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "InstanceManagement", false, "",
        "", "", false, "ad_forms", strReplaceWith, false, true);
    toolbar.prepareSimpleToolBarTemplate();
    xmlDocument.setParameter("toolbar", toolbar.toString());

    try {
      final WindowTabs tabs = new WindowTabs(this, vars,
          "org.openbravo.erpCommon.ad_forms.InstanceManagement");
      xmlDocument.setParameter("theme", vars.getTheme());
      final NavigationBar nav = new NavigationBar(this, vars.getLanguage(),
          "InstanceManagement.html", classInfo.id, classInfo.type, strReplaceWith, tabs
              .breadcrumb());
      xmlDocument.setParameter("navigationBar", nav.toString());
      final LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "InstanceManagement.html",
          strReplaceWith);
      xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
    } catch (final Exception ex) {
      throw new ServletException(ex);
    }

    // Message
    {
      final OBError myMessage = vars.getMessage("InstanceManagement");
      vars.removeMessage("InstanceManagement");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }

    // Purpose combo
    try {
      ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "InstancePurpose", "",
          Utility.getContext(this, vars, "#AccessibleOrgTree", "InstanceManagement"), Utility
              .getContext(this, vars, "#User_Client", "InstanceManagement"), 0);
      Utility.fillSQLParameters(this, vars, null, comboTableData, "InstanceManagement",
          activationKey.isOPSInstance() ? activationKey.getProperty("purpose") : null);
      xmlDocument.setData("reportPurpose", "liststructure", comboTableData.select(false));
      comboTableData = null;
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new ServletException(ex);
    }

    if (activationKey.hasActivationKey()) {
      xmlDocument.setParameter("publicKey", activationKey.getPublicKey());
    }

    if (activationKey.isOPSInstance()) {
      xmlDocument.setParameter("paramSelPurpose", activationKey.getProperty("purpose"));
      xmlDocument.setParameter("instanceNo", activationKey.getProperty("instanceno"));
    }

    out.println(xmlDocument.print());
    out.close();
  }
View Full Code Here

      ServletException {

    VariablesSecureApp vars = new VariablesSecureApp(request);

    if (vars.commandIn("DEFAULT")) {
      ActivationKey activationKey = new ActivationKey();
      printPageActive(response, vars, activationKey);
    } else if (vars.commandIn("SHOW_ACTIVATE")) {
      printPageNotActive(response, vars);
    } else if (vars.commandIn("ACTIVATE")) {
      activateRemote(vars);
View Full Code Here

  }

  private void printPageActivateLocal(HttpServletResponse response, VariablesSecureApp vars)
      throws IOException {

    ActivationKey ak = new ActivationKey();
    String discard[] = { "", "" };

    if (ak.isOPSInstance()) {
      if (ak.hasExpired()) {
        // Renew
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      } else {
        // Refresh
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      }
    } else {
      // Activate
      discard[0] = "OPSRefresh";
      discard[1] = "OPSRenew";
    }

    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
        "org/openbravo/erpCommon/ad_forms/InstanceManagementActivateLocal", discard)
        .createXmlDocument();
    response.setContentType("text/html; charset=UTF-8");
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
    xmlDocument.setParameter("theme", vars.getTheme());
    if (ak.hasActivationKey()) {
      xmlDocument.setParameter("publicKey", ak.getPublicKey());
    }
    final PrintWriter out = response.getWriter();
    out.println(xmlDocument.print());
    out.close();
View Full Code Here

  private void checkLicenseAndGo(HttpServletResponse res, VariablesSecureApp vars,
      String strUserAuth) throws IOException {
    OBContext.enableAsAdminContext();
    try {
      ActivationKey ak = new ActivationKey();
      boolean hasSystem = false;

      try {
        hasSystem = SeguridadData.hasSystemRole(this, strUserAuth);
      } catch (Exception ignore) {
        log4j.error(ignore);
      }
      String msgType, action;
      if (hasSystem) {
        msgType = "Warning";
        action = "../security/Menu.html";
      } else {
        msgType = "Error";
        action = "../security/Login_FS.html";
      }

      switch (ak.checkOPSLimitations(vars.getDBSession())) {
      case NUMBER_OF_CONCURRENT_USERS_REACHED:
        String msg = Utility.messageBD(myPool, "NUMBER_OF_CONCURRENT_USERS_REACHED", vars
            .getLanguage());
        String title = Utility.messageBD(myPool, "NUMBER_OF_CONCURRENT_USERS_REACHED_TITLE", vars
            .getLanguage());
        goToRetry(res, vars, msg, title, msgType, action);
        break;
      case NUMBER_OF_SOFT_USERS_REACHED:
        msg = Utility.messageBD(myPool, "NUMBER_OF_SOFT_USERS_REACHED", vars.getLanguage());
        title = Utility.messageBD(myPool, "NUMBER_OF_SOFT_USERS_REACHED_TITLE", vars.getLanguage());
        action = "../security/Menu.html";
        msgType = "Warning";
        goToRetry(res, vars, msg, title, msgType, action);
        break;
      case OPS_INSTANCE_NOT_ACTIVE:
        msg = Utility.messageBD(myPool, "OPS_INSTANCE_NOT_ACTIVE", vars.getLanguage());
        title = Utility.messageBD(myPool, "OPS_INSTANCE_NOT_ACTIVE_TITLE", vars.getLanguage());
        goToRetry(res, vars, msg, title, msgType, action);
        break;
      case MODULE_EXPIRED:
        msg = Utility.messageBD(myPool, "OPS_MODULE_EXPIRED", vars.getLanguage());
        title = Utility.messageBD(myPool, "OPS_MODULE_EXPIRED_TITLE", vars.getLanguage());
        StringBuffer expiredMoudules = new StringBuffer();
        for (Module module : ak.getExpiredInstalledModules()) {
          expiredMoudules.append("<br/>").append(module.getName());
        }
        msg += expiredMoudules.toString();
        goToRetry(res, vars, msg, title, msgType, action);
        break;
View Full Code Here

      ServletException {

    VariablesSecureApp vars = new VariablesSecureApp(request);

    if (vars.commandIn("DEFAULT")) {
      ActivationKey activationKey = new ActivationKey();
      printPageActive(response, vars, activationKey);
    }   else if (vars.commandIn("SHOW_ACTIVATE_LOCAL")) { 
      printPageActivateLocal(response, vars);
    } else if (vars.commandIn("INSTALLFILE")) {    
      printPageInstallFile(request,response, vars);
View Full Code Here

  }

  private void printPageActivateLocal(HttpServletResponse response, VariablesSecureApp vars)
      throws IOException {

    ActivationKey ak = new ActivationKey();
    String discard[] = { "", "" };

    if (ak.isOPSInstance()) {
      if (ak.hasExpired()) {
        // Renew
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      } else {
        // Refresh
        discard[0] = "OPSActivate";
        discard[1] = "OPSRefresh";
      }
    } else {
      // Activate
      discard[0] = "OPSRefresh";
      discard[1] = "OPSRenew";
    }

    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
        "vehicle/management/system/ad_forms/LicenseManagementActivateLocal", discard)
        .createXmlDocument();
    response.setContentType("text/html; charset=UTF-8");
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
    xmlDocument.setParameter("theme", vars.getTheme());
    if (ak.hasActivationKey()) {
      xmlDocument.setParameter("publicKey", ak.getPublicKey());
    }
    final PrintWriter out = response.getWriter();
    out.println(xmlDocument.print());
    out.close();
View Full Code Here

TOP

Related Classes of org.openbravo.erpCommon.obps.ActivationKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.