Authentication & Contingencies

Computer Science: OCR GCSE, topic 2.3.3

Authentication and Contingencies

Two very important elements of defensive design are authentication and contingency planning.

Authentication

Authentication

  • Authentication is the process of checking that a person or system is authorised to use a system.
  • The most common form of authentication is to require users to enter a username and password.
  • Once a user has authenticated themselves, they should be able to see data relevant to themselves and no one else.
Contingency planning

Contingency planning

  • It is impossible to predict all possible cases of misuse, but there are ways to help reduce errors. For example:
  • Providing helpful prompt messages.
  • Providing error-recovery routes (e.g. an undo feature).
  • Preventing access from certain parts of the system.
  • Using exception handling.

Exceptions

Rather than leaving the program to crash when an error happens, exceptions give us a chance to handle the error more gracefully.

Exceptions

Exceptions

  • When an error arises in a program, the program is said to 'throw' an exception.
  • An exception is a description of the error that arose.
  • Exceptions can be 'caught' or handled rather than allowing the program to crash.
Handling exceptions

Handling exceptions

  • If an exception can be dealt with internally, then we can catch the exception and continue with the program.
  • This is done using a structure as below:
  • try: ---
  • except: ---
  • The code within the try block will be executed.
  • If an exception is thrown inside the try block, then the except block will be run to 'clean up' after the exception.

Test yourself on Authentication & Contingencies

  • The most common form of authentication requires what data from the user?

  • Once a user is authenticated, what should they see?

  • Which of these is a common error-recovery route?

  • What is it called when an error arises in a program?

  • What is the purpose of the 'except' block of a try-except structure?

Practise this topic for free