Updated authentication code and created exception classes for
authentication errors.