Refactored the CAS authentication logic to a separate class.