Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- • Function main()
- o PRINT welcome prompt
- o WHILE loginAttempts are less than MAX_LOGIN_ATTEMPTS
- • PRINT “Username: “
- • SET usernameEntry equal to user response
- • PRINT “Password: “
- • SET passwordEntry equal to user response
- • SET passwordEncrypted equal to md5Encrypt(passwordEntry)
- • SET authenticated equal to authenticate(usernameEntry, passwordEncrypted)
- • IF authenticated equals true
- • SET loginAttempts equal to 0
- • ELSE
- • INCREMENT loginAttempts
- • ENDIF
- • IF loginAttempts is equal to MAX_LOGIN_ATTEMPTS
- • PRINT “Too many attempts”
- • PRINT “Press Enter to quit”
- • WAIT for enter key
- • END PROGRAM
- • ENDIF
- o ENDWHILE
- • Function md5Encrypt(plaintext)
- o DO magic
- o RETURN encrypted
- • Function authenticate(username, password)
- o OPEN credentials.txt as new File wrapped in a Scanner
- o WHILE credentials file has next line
- • FOR col (one through four)
- • SWITCH col
- • CASE 1
- o SET fileUsername equal to next word
- • CASE 2
- o SET fileMD5 equal to next word
- • CASE 3
- o SET filePassword equal to next word
- • CASE 4
- o SET fileRole equal to next word
- o IF fileUsername equals username AND filePassword equals password
- • CALL accessGranted(username, fileRole)
- o ENDIF
- • ENDSWITCH
- o RETURN false
- • Function accessGranted(username, role)
- o SET roleFile equal to role plus “.txt”
- o OPEN roleFile as File wrapped in a Scanner
- o WHILE roleFile has next line
- • PRINT line of file
- o ENDWHILE
- o PRINT logout prompt
- o WAIT for enter key to be pressed
- o CALL Authentication.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement