/* author: Jerrold Siegel Copyright (c) 2002 Jerrold Siegel for the Curators of the University of Missouri All Rights Reserved This software may be used for educational purposes only. It is not intended for sale or commercial use. FURTHER, NO WARRANTIES OF FITNESS, CORRECTNESS, OR SUITABILITY FOR ANY PARTICULAR PURPOSE ARE MADE OR IMPLIED. */ import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.text.*; public class CreditCardServlet extends HttpServlet { static Object syncit=new Object(); static String file_base=null; static String log_base = null ; static String URLHost = null; static String SSLHost = null; static String ssl_base = null; public void init(ServletConfig config) throws ServletException{ java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); file_base=config.getInitParameter("file_base").trim(); log_base=config.getInitParameter("log_base").trim(); URLHost=config.getInitParameter("URLHost").trim(); SSLHost = config.getInitParameter("SSLHost").trim(); ssl_base =config.getInitParameter("ssl_base").trim(); new TimeThread(300000).start(); //five minutes } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { do_violation(req,res); return; } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { String appl_id=req.getParameterValues("appl_id")[0].trim(); if (appl_id.equals("CE")) {new ecCEd(req,res).run() ;return;} /* if (appl_id.equals("AL")) { new ecAlternative(req,res).run() ;return; } */ if (appl_id.equals("UR")) {new ecUR(req,res).run() ;return;} if (appl_id.equals("GA")) { new ecGrad(req,res ).run() ;return; } if (appl_id.equals("UA")) { new ecUGrad(req,res ).run() ;return; } throw new Exception(); } catch ( Exception e) { synchronized(syncit) { try { res.setContentType("text/html"); PrintWriter out = new PrintWriter(res.getOutputStream()); out.println ("

Sorry, there appears to be a problem processing your Credit Card.

"+ "Please contact e-commerce@umsl.edufor further clarification or consider an"+ " alternative form of payment.

"); out.flush (); String ip_address=req.getRemoteAddr().trim(); java.text.DateFormat todays_date=DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,java.text.DateFormat.LONG,new Locale("en","US")); String present_date_time=todays_date.format(new java.util.Date()); OutputStreamWriter fo=new OutputStreamWriter(new FileOutputStream(log_base+"error.log",true)); fo.write("\nPossible Intrusion from: "+ip_address); fo.write("\nAt: "+present_date_time+"\n\n"); fo.close(); String[] args1=new String[4]; args1[0]=ip_address; args1[1]=present_date_time; args1[2]=SSLHost; args1[3]=ssl_base; sslclient.main(args1); } catch (Exception exp) { PrintWriter out = new PrintWriter(res.getOutputStream()); exp.printStackTrace(out);out.flush(); } } //end sync. return; } //endcatch } //end doPost void do_violation(HttpServletRequest req, HttpServletResponse res){ synchronized(syncit) { try { res.setContentType("text/html"); PrintWriter out = new PrintWriter(res.getOutputStream()); out.println ("

Sorry, there appears to be a problem processing your Credit Card.

"+ "Please contact e-commerce@umsl.edufor further clarification or consider an"+ " alternative form of payment.

"); out.flush (); String ip_address=req.getRemoteAddr().trim(); java.text.DateFormat todays_date=DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,java.text.DateFormat.LONG,new Locale("en","US")); String present_date_time=todays_date.format(new java.util.Date()); OutputStreamWriter fo=new OutputStreamWriter(new FileOutputStream(log_base+"error.log",true)); fo.write("\nPossible Intrusion from: "+ip_address); fo.write("\nAt: "+present_date_time+"\n\n"); fo.close(); String[] args1=new String[4]; args1[0]=ip_address; args1[1]=present_date_time; args1[2]=SSLHost; args1[3]=ssl_base; sslclient.main(args1); } catch (Exception exp) { try{PrintWriter out = new PrintWriter(res.getOutputStream()); exp.printStackTrace(out);out.flush(); }catch(Exception exp1){} } //endcatch } //end sync. return; } } //end class