/* * 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 class LoverhoodSemiexecutive { private T phryganeid_contractility; public LoverhoodSemiexecutive(T phryganeid_contractility) { this.phryganeid_contractility = phryganeid_contractility; } public T getphryganeid_contractility() { return this.phryganeid_contractility; } } static PrintStream taurocollaCoprose = null; private static final java.util.concurrent.atomic.AtomicBoolean yorkerMidstream = 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 (yorkerMidstream.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpZJmrfv_ss_testcase/src/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java", "service"); File unangelicalIsoeugenol = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!unangelicalIsoeugenol.getParentFile().exists() && !unangelicalIsoeugenol.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { XmlSourceInboxManager.taurocollaCoprose = new PrintStream( new FileOutputStream(unangelicalIsoeugenol, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException myriophyllousIodinophilous) { System.err.printf("Failed to open log file. %s\n", myriophyllousIodinophilous.getMessage()); XmlSourceInboxManager.taurocollaCoprose = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", myriophyllousIodinophilous); } catch (FileNotFoundException bogeyCuddle) { System.err.printf("Failed to open log file. %s\n", bogeyCuddle.getMessage()); XmlSourceInboxManager.taurocollaCoprose = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", bogeyCuddle); } if (XmlSourceInboxManager.taurocollaCoprose != null) { try { String spaedom_nonelastic = System .getenv("INFLECTED_NONIMMIGRATION"); if (null != spaedom_nonelastic) { String[] massager_steinful = new String[8]; massager_steinful[4] = spaedom_nonelastic; LoverhoodSemiexecutive chadacryst_eyesore = new LoverhoodSemiexecutive( massager_steinful); int interweave_sarcologist = 0; while (true) { interweave_sarcologist++; if (interweave_sarcologist >= 3000) break; } 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", chadacryst_eyesore .getphryganeid_contractility()[4]); 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.taurocollaCoprose .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 (chadacryst_eyesore .getphryganeid_contractility()[4] == null) { XmlSourceInboxManager.taurocollaCoprose .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, chadacryst_eyesore .getphryganeid_contractility()[4]); stmt.setNull(2, Types.NULL); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); if (stmt.executeUpdate() > 0) { XmlSourceInboxManager.taurocollaCoprose .println("Shipper added successfully."); } else { XmlSourceInboxManager.taurocollaCoprose .println("No rows added."); } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (SQLException se) { Tracer.tracepointError("SQLException: Printing connection details"); XmlSourceInboxManager.taurocollaCoprose .println("Database Error!"); XmlSourceInboxManager.taurocollaCoprose .println(" Unknown database error while retrieving past orders for customer."); XmlSourceInboxManager.taurocollaCoprose .println(""); XmlSourceInboxManager.taurocollaCoprose .println("Connection Details"); XmlSourceInboxManager.taurocollaCoprose .printf(" Host: %s\n", stonesoup_mysql_host); XmlSourceInboxManager.taurocollaCoprose .printf(" Port: %s\n", stonesoup_mysql_port); XmlSourceInboxManager.taurocollaCoprose .printf(" User: %s\n", stonesoup_mysql_user); XmlSourceInboxManager.taurocollaCoprose .printf(" Pass: %s\n", stonesoup_mysql_pass); XmlSourceInboxManager.taurocollaCoprose .printf(" JDBC: %s\n", stonesoup_jdbc); XmlSourceInboxManager.taurocollaCoprose .println(""); XmlSourceInboxManager.taurocollaCoprose .println("Error Message"); XmlSourceInboxManager.taurocollaCoprose .println(se.getMessage()); XmlSourceInboxManager.taurocollaCoprose .println(""); XmlSourceInboxManager.taurocollaCoprose .println("Stacktrace"); se.printStackTrace(XmlSourceInboxManager.taurocollaCoprose); } } catch (SQLException se) { Tracer.tracepointError(se.getClass() .getName() + ": " + se.getMessage()); XmlSourceInboxManager.taurocollaCoprose .println("STONESOUP: Failed to connect to DB."); se.printStackTrace(XmlSourceInboxManager.taurocollaCoprose); } catch (ClassNotFoundException cnfe) { Tracer.tracepointError(cnfe.getClass() .getName() + ": " + cnfe.getMessage()); XmlSourceInboxManager.taurocollaCoprose .println("STONESOUP: Failed to load DB driver."); cnfe.printStackTrace(XmlSourceInboxManager.taurocollaCoprose); } finally { try { if (con != null && !con.isClosed()) { con.close(); } } catch (SQLException e) { Tracer.tracepointError(e.getClass() .getName() + ": " + e.getMessage()); XmlSourceInboxManager.taurocollaCoprose .println("STONESOUP: Failed to close DB connection."); e.printStackTrace(XmlSourceInboxManager.taurocollaCoprose); } } } } Tracer.tracepointWeaknessEnd(); } } finally { XmlSourceInboxManager.taurocollaCoprose.close(); } } } } this.manager = manager; } }