CAS-1219: TGT validity check at the beginning of the login flow

Incorporated the implementation attached to the JIRA issue.