/**
* Main execution method. Initializes CAS client and force authentication if required before passing user to parent startup method.
*
* @param object $controller A reference to the instantiating controller object
* @return boolean
* @access public
*/
function startup(&$controller)
{
// CAS authentication required if user is not logged in
//debug($controller);exit;
//if (!$this->user()) {
if (!isset($this->request->query['ticket'])) {
// Set debug mode
phpCAS::setDebug(false);
//if(!empty(phpCAS::getUser()))
// debug($this);
//Initialize phpCAS
//debug(isset($this->request->query['ticket']));
phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'));
// No SSL validation for the CAS server
phpCAS::setNoCasServerValidation();
// Force CAS authentication if required
phpCAS::forceAuthentication();
//debug();exit;
$model =& $this->getModel();
$controller->data[$model->alias][$this->fields['username']] = phpCAS::getUser();
$controller->data[$model->alias][$this->fields['password']] = 'a';
//$this->User->['username']=phpCAS::getUser();
//$this->User->['password']='******';
}
return parent::startup($controller);
//$this->redirect(array('controller'=>'User','action'=>'login'));
}