Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a GUI Java program to read a log file (attached) and report user accounts

ID: 3783718 • Letter: C

Question

Create a GUI Java program to read a log file (attached) and report user accounts that have failed logging in 3 or more times in the span of 5 minutes.

For grading:

Teams must meet each week and provide proof of each meeting, whether that meeting is during class time or virtual.

Each student must show the working program to the professor on the due date.

Each team must present their project and explain how it works. Program must compile and run on lab computers.

Each student must complete a peer rating sheet.

owncloud.log

Explanation / Answer

the above is an example of a log record .

so we'll have to parse this entry such that if the user name is same then and it is "unsuccesful"

the time diff doesn't exceed 5 minutes

we'll compare first entry with second , and first with third. if these two hold then second and third would also hold.

we'll parse the string like this -

a b c (the log entry) wouuld be converted to an array of a strings such that tokens[2] will give c

so by indexing now, we can match the usernames and such!

-----------------------------------------------

import java.util.scanner;

public class Log {

public static main void() {

FileInputStream fstream = new FileInputStream("xyz.log");

BufferedReader br = new BufferedReader(new InputStreamReader(fstream));

String strLine;

//reading it line by line

while((strline = br.readLine() != NULL ) {

//now we'll parse the line read

//let us first match the user name

String delims = "[ ]+";

String[] tokens1 = strline.split(delims);

while((strline = br.readLine() != NULL ) {

String[] tokens2 = strline.split(delims);

///match the username using indexing   

if(tokens1[10] == tokens2[10])

{

//now see if both were unsuccesful or not

if(tokens1[7] == "unsuccessful" && tokens2[7] == "unsuccessful")

{

//now we must check that tthe time difference is less than 5 mins

//tokens1[2] will hold time for 1st and tokens2[2] for 2nd entry

SimpleDateFormat format = new SimpleDateFormat("Hh:mm:ss");

Date date1 = format.parse(tokens1[2]);

Date date2 = format.parse(tokens2[3]);

//the difference will come in milisecond so for 5 min we have 300000

if( date2.getTime() - date1.getTime() < 300000)

{

//if this is less than 5 mins let us now check for 1st and 3rd

while((strline = br.readLine() != NULL ) {

delims = "[ ]+";

String[] tokens3 = strline.split(delims);

//rest will be same as 1st and 2nd

if(tokens1[10] == tokens3[10])

{

//now see if both were unsuccesful or not

if(tokens1[7] == "unsuccessful" && tokens3[7] == "unsuccessful")

{

//now we must check that tthe time difference is less than 5 mins

//tokens1[2] will hold time for 1st and tokens3[2] for 3rd entry

SimpleDateFormat format = new SimpleDateFormat("Hh:mm:ss");

Date date1 = format.parse(tokens1[2]);

Date date2 = format.parse(tokens3[2]);

//the difference will come in milisecond so for 5 min we have 300000  

if( date2.getTime() - date1.getTime() < 300000)

{

System.out.println("A user failing to log in 3 times in 5 minutes is " + token1[10]);

break; //break the innermost loop

}

}

}

}

break ; //the second looop

}

}

//outer loop continues to look for other such users

}

-------------------------------------

thank you