/** Since Openbravo 3.0MP9 only {@link #sendEmail()} is used for the full email sending cycle */ @Deprecated public static Session newMailSession( ConnectionProvider connectionProvider, String clientId, String adOrgId) throws PocException, ServletException { PocConfigurationData configurations[]; try { configurations = PocConfigurationData.getSmtpDetails(connectionProvider, clientId, adOrgId); } catch (ServletException exception) { throw new PocException(exception); } PocConfigurationData configuration = null; if (configurations.length > 0) { configuration = configurations[0]; if (log4j.isDebugEnabled()) { log4j.debug("Crm configuration, smtp server: " + configuration.smtpserver); log4j.debug("Crm configuration, smtp server auth: " + configuration.issmtpauthorization); log4j.debug("Crm configuration, smtp server account: " + configuration.smtpserveraccount); log4j.debug("Crm configuration, smtp server password: "******"Crm configuration, smtp server connection security: " + configuration.smtpconnectionsecurity); log4j.debug("Crm configuration, smtp server port: " + configuration.smtpport); } } else { throw new ServletException("No Poc configuration found for this client."); } Properties props = new Properties(); if (log4j.isDebugEnabled()) { props.put("mail.debug", "true"); } props.put("mail.transport.protocol", "smtp"); props.put("mail.host", configuration.smtpserver); props.put("mail.smtp.auth", (configuration.issmtpauthorization.equals("Y") ? "true" : "false")); props.put("mail.smtp.mail.sender", "*****@*****.**"); props.put("mail.smtp.port", configuration.smtpport); if (configuration.smtpconnectionsecurity.equals("STARTTLS")) { props.put("mail.smtp.starttls.enable", "true"); } else if (configuration.smtpconnectionsecurity.equals("SSL")) { props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); props.put("mail.smtp.socketFactory.port", configuration.smtpport); } ClientAuthenticator authenticator = null; if (configuration.smtpserveraccount != null) { authenticator = new ClientAuthenticator( configuration.smtpserveraccount, FormatUtilities.encryptDecrypt(configuration.smtpserverpassword, false)); } return Session.getInstance(props, authenticator); }
/** Generates the HTML code for the input used to display the reference in the filter popup */ public void generateFilterHtml( StringBuffer strHtml, VariablesSecureApp vars, BuscadorData field, String strTab, String strWindow, ArrayList<String> vecScript, Vector<Object> vecKeys) throws IOException, ServletException { if ((Integer.valueOf(field.fieldlength).intValue() > UIReferenceUtility.MAX_TEXTBOX_LENGTH)) { // Memo replace with reference 1-2-3 cells doing < MAX_TEXTBOX_LENGTH/4 /2 > /2 strHtml.append("<td>"); strHtml.append( "<textarea class=\"dojoValidateValid TextArea_TwoCells_width TextArea_Medium_height\" "); strHtml .append("name=\"inpParam") .append(FormatUtilities.replace(field.columnname)) .append("\" "); strHtml.append("cols=\"50\" rows=\"3\" "); strHtml.append(">"); strHtml.append(field.value); strHtml.append("</textarea>\n"); strHtml.append("</td>"); } else { strHtml.append("<td class=\"TextBox_ContentCell\">"); strHtml.append("<input type=\"text\" class=\"dojoValidateValid TextBox_OneCell_width\" "); strHtml .append("name=\"inpParam") .append(FormatUtilities.replace(field.columnname)) .append("\" "); strHtml.append("maxlength=\"").append(field.fieldlength).append("\" "); strHtml.append("value=\"").append(field.value).append("\" "); strHtml.append(">"); strHtml.append("</td>"); } }
/** * Generates the body for the accept (aceptar) script called from filter pop-up when OK button is * clicked. */ public void generateFilterAcceptScript( BuscadorData field, StringBuffer params, StringBuffer paramsData) { paramsData .append("paramsData[count++] = new Array(\"inpParam") .append(FormatUtilities.replace(field.columnname)) .append("\" , "); params.append(", \"inpParam").append(FormatUtilities.replace(field.columnname)).append("\","); params.append(" escape("); paramsData .append("frm.inpParam") .append(FormatUtilities.replace(field.columnname)) .append(".value);\n"); params .append("frm.inpParam") .append(FormatUtilities.replace(field.columnname)) .append(".value"); if (addSecondaryFilter) { paramsData .append("paramsData[count++] = new Array(\"inpParam") .append(FormatUtilities.replace(field.columnname)) .append("_f\", "); paramsData .append("frm.inpParam") .append(FormatUtilities.replace(field.columnname)) .append("_f.value);\n"); params .append("), \"inpParam") .append(FormatUtilities.replace(field.columnname)) .append("_f\","); params.append(" escape("); params .append("frm.inpParam") .append(FormatUtilities.replace(field.columnname)) .append("_f.value"); } params.append(")"); }
/** * Checks the Internet availability and sets the proxy in case it is needed. * * @deprecated Proxy settings should not be passed as parameter, but obtained from system * information. Use instead {@link HttpsUtils#isInternetAvailable()} * @param proxyHost * @param proxyPort */ public static boolean isInternetAvailable(String proxyHost, int proxyPort) { OBContext.setAdminMode(); try { final SystemInformation sys = OBDal.getInstance().get(SystemInformation.class, "0"); if (sys.isProxyRequired() || (proxyHost != null && !proxyHost.isEmpty())) { // Proxy is required for connection. String host; int port; if (proxyHost == null || proxyHost.isEmpty()) { // to maintain backwards compatibility, set host in case it is provided as parameter (it // shouldn't be) host = sys.getProxyServer(); port = sys.getProxyPort().intValue(); } else { host = proxyHost; port = proxyPort; } System.getProperties().put("proxySet", "true"); System.getProperties().put("http.proxyHost", host); System.getProperties().put("https.proxyHost", host); System.getProperties().put("http.proxyPort", String.valueOf(port)); System.getProperties().put("https.proxyPort", String.valueOf(port)); System.setProperty("java.net.useSystemProxies", "true"); if (sys.isRequiresProxyAuthentication()) { final String user = sys.getProxyUser(); String pass = ""; try { pass = FormatUtilities.encryptDecrypt(sys.getProxyPassword(), false); } catch (ServletException e) { log4j.error("Error setting proxy authenticator", e); } final String password = pass; // Used for standard http and https connections Authenticator.setDefault( new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password.toCharArray()); } }); // Used for SOAP webservices System.getProperties().setProperty("http.proxyUser", user); System.getProperties().setProperty("http.proxyPassword", password); } } else { System.getProperties().put("proxySet", false); System.getProperties().remove("http.proxyHost"); System.getProperties().remove("http.proxyPort"); System.getProperties().remove("https.proxyHost"); System.getProperties().remove("https.proxyPort"); System.getProperties().remove("http.proxyUser"); System.getProperties().remove("http.proxyPassword"); System.setProperty("java.net.useSystemProxies", "false"); } } finally { OBContext.restorePreviousMode(); } try { // Double check. URL url = new URL("https://butler.openbravo.com"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(3000); conn.connect(); if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { return false; } } catch (Exception e) { log4j.info("Unable to reach butler.openbravo.com"); return false; } return true; }