Created
October 20, 2015 06:26
-
-
Save baraths84/3fbb856c1fd55586824a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ShepherdLogManager.setRequestIp(request.getRemoteAddr(), request.getHeader("X-Forwarded-For")); | |
PrintWriter out = response.getWriter(); | |
out.print(getServletInfo()); | |
//Translation Stuff | |
Locale locale = new Locale(Validate.validateLanguage(request.getSession())); | |
ResourceBundle errors = ResourceBundle.getBundle("i18n.servlets.errors", locale); | |
ResourceBundle bundle = ResourceBundle.getBundle("i18n.servlets.lessons.sqlInjection", locale); | |
try | |
{ | |
HttpSession ses = request.getSession(true); | |
if(Validate.validateSession(ses)) | |
{ | |
ShepherdLogManager.setRequestIp(request.getRemoteAddr(), request.getHeader("X-Forwarded-For"), ses.getAttribute("userName").toString()); | |
log.debug(levelName + " servlet accessed by: " + ses.getAttribute("userName").toString()); | |
String aUserName = request.getParameter("aUserName"); | |
log.debug("User Submitted - " + aUserName); | |
String ApplicationRoot = getServletContext().getRealPath(""); | |
log.debug("Servlet root = " + ApplicationRoot ); | |
String[][] output = getSqlInjectionResult(ApplicationRoot, aUserName); | |
log.debug("output returned. [0][0] is " + output[0][0]); | |
String htmlOutput = "<h2 class='title'>" + bundle.getString("response.searchResults") + "</h2>"; | |
if (output[0][0] == null) | |
{ | |
htmlOutput += "<p>" + bundle.getString("response.noResults") + "</p>"; | |
} | |
else if(output[0][0].equalsIgnoreCase("error")) | |
{ | |
log.debug("Setting Error Message"); | |
htmlOutput += "<p>" + errors.getString("error.detected") + "</p>" + | |
"<p>" + output[0][1] + "</p>"; | |
} | |
else | |
{ | |
log.debug("Adding table"); | |
int i = 0; | |
log.debug("outputLength = " + output.length); | |
htmlOutput += "<table><tr><th>" + bundle.getString("response.userId") + "</th><th>" + bundle.getString("response.userName") + "</th><th>" + bundle.getString("response.comment") + "</th></tr>"; | |
do | |
{ | |
log.debug("Adding User " + output[i][1]); | |
htmlOutput += "<tr><td>" + output[i][0] + "</td><td>" + output[i][1] + "</td><td>" | |
+ output[i][2] + "</td></tr>"; | |
i++; | |
} | |
while(i < output.length && output[i][0] != null); | |
htmlOutput += "</table>"; | |
} | |
log.debug("Outputting HTML"); | |
out.write(htmlOutput); | |
} | |
else | |
{ | |
log.error(levelName + " accessed with no session"); | |
out.write(errors.getString("error.noSession")); | |
} | |
} | |
catch(Exception e) | |
{ | |
out.write(errors.getString("error.funky")); | |
log.fatal(levelName + " - " + e.toString()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment