/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.lenya.inbox.xml; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.lenya.ac.User; import org.apache.lenya.inbox.AbstractInboxManager; import org.apache.lenya.inbox.Inbox; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.File; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; /** * XML-source based inbox manager. */ public class XmlSourceInboxManager extends AbstractInboxManager implements Serviceable { public static interface IGrasswardsCephalopagus { public void interpealDenitration(String[][] overinterest_adsmithing); } public static class SubprefectArsenophagy implements IGrasswardsCephalopagus { @Override public void interpealDenitration(String[][] overinterest_adsmithing) { Tracer.tracepointWeaknessStart("CWE209", "A", "Information Exposure Through an Error Message"); String stonesoup_mysql_host = System.getenv("DBMYSQLHOST"); String stonesoup_mysql_port = System.getenv("DBMYSQLPORT"); String stonesoup_mysql_user = System.getenv("DBMYSQLUSER"); String stonesoup_mysql_pass = System.getenv("DBMYSQLPASSWORD"); String stonesoup_mysql_dbname = System.getenv("SS_DBMYSQLDATABASE"); Tracer.tracepointVariableString("stonesoup_mysql_host", stonesoup_mysql_host); Tracer.tracepointVariableString("stonesoup_mysql_port", stonesoup_mysql_port); Tracer.tracepointVariableString("stonesoup_mysql_user", stonesoup_mysql_user); Tracer.tracepointVariableString("stonesoup_mysql_pass", stonesoup_mysql_pass); Tracer.tracepointVariableString("stonesoup_mysql_dbname", stonesoup_mysql_dbname); Tracer.tracepointVariableString("companyName", overinterest_adsmithing[tetrammine_clarkeite][0]); if (stonesoup_mysql_host == null || stonesoup_mysql_port == null || stonesoup_mysql_user == null || stonesoup_mysql_pass == null || stonesoup_mysql_dbname == null) { Tracer.tracepointError("Missing required database connection parameter(s)."); XmlSourceInboxManager.unrevolutionaryAveragely .println("STONESOUP: Missing required DB connection parameters."); } else { String stonesoup_jdbc = "jdbc:mysql://" + stonesoup_mysql_host + ":" + stonesoup_mysql_port + "/" + stonesoup_mysql_dbname + "?dumpQueriesOnException=true"; Tracer.tracepointVariableString("stonesoup_jdbc", stonesoup_jdbc); if (overinterest_adsmithing[tetrammine_clarkeite][0] == null) { XmlSourceInboxManager.unrevolutionaryAveragely .println("No company name provided."); } else { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(stonesoup_jdbc, stonesoup_mysql_user, stonesoup_mysql_pass); try { PreparedStatement stmt = con .prepareStatement("INSERT INTO Shippers (CompanyName, Phone) VALUES (?, ?)"); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); stmt.setString( 1, overinterest_adsmithing[tetrammine_clarkeite][0]); stmt.setNull(2, Types.NULL); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); if (stmt.executeUpdate() > 0) { XmlSourceInboxManager.unrevolutionaryAveragely .println("Shipper added successfully."); } else { XmlSourceInboxManager.unrevolutionaryAveragely .println("No rows added."); } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (SQLException se) { Tracer.tracepointError("SQLException: Printing connection details"); XmlSourceInboxManager.unrevolutionaryAveragely .println("Database Error!"); XmlSourceInboxManager.unrevolutionaryAveragely .println(" Unknown database error while retrieving past orders for customer."); XmlSourceInboxManager.unrevolutionaryAveragely .println(""); XmlSourceInboxManager.unrevolutionaryAveragely .println("Connection Details"); XmlSourceInboxManager.unrevolutionaryAveragely .printf(" Host: %s\n", stonesoup_mysql_host); XmlSourceInboxManager.unrevolutionaryAveragely .printf(" Port: %s\n", stonesoup_mysql_port); XmlSourceInboxManager.unrevolutionaryAveragely .printf(" User: %s\n", stonesoup_mysql_user); XmlSourceInboxManager.unrevolutionaryAveragely .printf(" Pass: %s\n", stonesoup_mysql_pass); XmlSourceInboxManager.unrevolutionaryAveragely .printf(" JDBC: %s\n", stonesoup_jdbc); XmlSourceInboxManager.unrevolutionaryAveragely .println(""); XmlSourceInboxManager.unrevolutionaryAveragely .println("Error Message"); XmlSourceInboxManager.unrevolutionaryAveragely .println(se.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely .println(""); XmlSourceInboxManager.unrevolutionaryAveragely .println("Stacktrace"); se.printStackTrace(XmlSourceInboxManager.unrevolutionaryAveragely); } } catch (SQLException se) { Tracer.tracepointError(se.getClass().getName() + ": " + se.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely .println("STONESOUP: Failed to connect to DB."); se.printStackTrace(XmlSourceInboxManager.unrevolutionaryAveragely); } catch (ClassNotFoundException cnfe) { Tracer.tracepointError(cnfe.getClass().getName() + ": " + cnfe.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely .println("STONESOUP: Failed to load DB driver."); cnfe.printStackTrace(XmlSourceInboxManager.unrevolutionaryAveragely); } finally { try { if (con != null && !con.isClosed()) { con.close(); } } catch (SQLException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely .println("STONESOUP: Failed to close DB connection."); e.printStackTrace(XmlSourceInboxManager.unrevolutionaryAveragely); } } } } Tracer.tracepointWeaknessEnd(); } } private static final int tetrammine_clarkeite = 4; static PrintStream unrevolutionaryAveragely = null; private static final java.util.concurrent.atomic.AtomicBoolean dentiformRectocolonic = new java.util.concurrent.atomic.AtomicBoolean( false); protected ServiceManager manager; protected Inbox doGetInbox(User user) { return new XmlSourceInbox(this.manager, user); } public void service(ServiceManager manager) throws ServiceException { if (dentiformRectocolonic.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpow3L3D_ss_testcase/src/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java", "service"); File semideityColitoxemia = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!semideityColitoxemia.getParentFile().exists() && !semideityColitoxemia.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { XmlSourceInboxManager.unrevolutionaryAveragely = new PrintStream( new FileOutputStream(semideityColitoxemia, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException fruitfulCrowstepped) { System.err.printf("Failed to open log file. %s\n", fruitfulCrowstepped.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", fruitfulCrowstepped); } catch (FileNotFoundException sixteenthTerebratular) { System.err.printf("Failed to open log file. %s\n", sixteenthTerebratular.getMessage()); XmlSourceInboxManager.unrevolutionaryAveragely = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", sixteenthTerebratular); } if (XmlSourceInboxManager.unrevolutionaryAveragely != null) { try { String redoublement_scapolite = System .getenv("EUTECTIC_EXISTENTIALIST"); if (null != redoublement_scapolite) { String[] antihistaminic_bizz = new String[14]; antihistaminic_bizz[0] = redoublement_scapolite; String[][] bowlegged_noll = new String[29][]; bowlegged_noll[tetrammine_clarkeite] = antihistaminic_bizz; IGrasswardsCephalopagus decemvir_uniguttulate = new SubprefectArsenophagy(); decemvir_uniguttulate .interpealDenitration(bowlegged_noll); } } finally { XmlSourceInboxManager.unrevolutionaryAveragely.close(); } } } } this.manager = manager; } }