1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	public function casAction() {
		$config = array(
			'hostname'  => 'fed.princeton.edu', 
			'port'      => 443, 
			'path'      => 'cas', 
		);
		
		$auth = Zend_Auth::getInstance();
		$adapter = new Zend_Auth_Adapter_Cas($config);
		
		$adapter->setQueryParams($this->_request->getQuery());
		$adapter->setTicket();
		//echo "<pre>";print_r($adapter);echo "</pre>";
		// If no identity is set and a ticket exists, attempt to authenticate
		if(!$auth->hasIdentity() && $adapter->hasTicket()) {

        	$result = $auth->authenticate($adapter);echo $adapter->getValidationURL();
        	echo "<pre>";print_r($result);echo "</pre>";
        	if(!$result->isValid()) {
        		$this->view->messages = $result->getMessages();
        		return;
        	}
		}
		
		// Send to CAS for authentication
		if(!$auth->hasIdentity()) {
			$this->_redirect($adapter->getLoginUrl());
		} else {
			$this->_redirect ( '/' );
		}
		
	}