_username = $username; } /** * Answer a service identifier (URL) for whom we should fetch a proxy ticket. * * @return string * @throws Exception If no service url is available. */ public function getServiceUrl() { if (empty($this->_url)) { throw new CAS_ProxiedService_Exception( 'No URL set via '.get_class($this).'->getServiceUrl($url).' ); } return $this->_url; } /** * Set the URL of the service to pass to CAS for proxy-ticket retrieval. * * @param string $url Url to set * * @return void * @throws CAS_OutOfSequenceException If called after the stream has been opened. */ public function setServiceUrl($url) { if ($this->hasBeenOpened()) { throw new CAS_OutOfSequenceException( 'Cannot set the URL, stream already opened.' ); } if (!is_string($url) || !strlen($url)) { throw new CAS_InvalidArgumentException('Invalid url.'); } $this->_url = $url; } /** * Set the mailbox to open. See the $mailbox parameter of imap_open(). * * @param string $mailbox Mailbox to set * * @return void * @throws CAS_OutOfSequenceException If called after the stream has been opened. */ public function setMailbox($mailbox) { if ($this->hasBeenOpened()) { throw new CAS_OutOfSequenceException( 'Cannot set the mailbox, stream already opened.' ); } if (!is_string($mailbox) || !strlen($mailbox)) { throw new CAS_InvalidArgumentException('Invalid mailbox.'); } $this->_mailbox = $mailbox; } /** * Set the options for opening the stream. See the $options parameter of * imap_open(). * * @param int $options Options for the stream * * @return void * @throws CAS_OutOfSequenceException If called after the stream has been opened. */ public function setOptions($options) { if ($this->hasBeenOpened()) { throw new CAS_OutOfSequenceException( 'Cannot set options, stream already opened.' ); } if (!is_int($options)) { throw new CAS_InvalidArgumentException('Invalid options.'); } $this->_options = $options; } /** * Open the IMAP stream (similar to imap_open()). * * @return resource Returns an IMAP stream on success * @throws CAS_OutOfSequenceException If called multiple times. * @throws CAS_ProxyTicketException If there is a proxy-ticket failure. * The code of the Exception will be one of: * PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE * PHPCAS_SERVICE_PT_FAILURE * @throws CAS_ProxiedService_Exception If there is a failure sending the * request to the target service. */ public function open() { if ($this->hasBeenOpened()) { throw new CAS_OutOfSequenceException('Stream already opened.'); } if (empty($this->_mailbox)) { throw new CAS_ProxiedService_Exception( 'You must specify a mailbox via '.get_class($this) .'->setMailbox($mailbox)' ); } phpCAS::traceBegin(); // Get our proxy ticket and append it to our URL. $this->initializeProxyTicket(); phpCAS::trace('opening IMAP mailbox `'.$this->_mailbox.'\'...'); $this->_stream = @imap_open( $this->_mailbox, $this->_username, $this->getProxyTicket(), $this->_options ); if ($this->_stream) { phpCAS::trace('ok'); } else { phpCAS::trace('could not open mailbox'); // @todo add localization integration. $message = 'IMAP Error: '.$this->_url.' '. var_export(imap_errors(), true); phpCAS::trace($message); throw new CAS_ProxiedService_Exception($message); } phpCAS::traceEnd(); return $this->_stream; } /** * Answer true if our request has been sent yet. * * @return bool */ protected function hasBeenOpened() { return !empty($this->_stream); } /** * Answer the IMAP stream * * @return resource * @throws CAS_OutOfSequenceException if stream is not opened yet */ public function getStream() { if (!$this->hasBeenOpened()) { throw new CAS_OutOfSequenceException( 'Cannot access stream, not opened yet.' ); } return $this->_stream; } /** * CAS_Client::serviceMail() needs to return the proxy ticket for some reason, * so this method provides access to it. * * @return string * @throws CAS_OutOfSequenceException If called before the stream has been * opened. */ public function getImapProxyTicket() { if (!$this->hasBeenOpened()) { throw new CAS_OutOfSequenceException( 'Cannot access errors, stream not opened yet.' ); } return $this->getProxyTicket(); } } __halt_compiler();----SIGNATURE:----qeL9ykIdaNeAfqHdSJifXAd0yWlOaCI8MHeWqZP74MslHOQ/8PeYVzh+jYzaOMaAZbJsVqnyWI7qnNk88zfTH/nhN/0pwB25geQyPQW749Pkck2NsFCv6OhbeCqt69mpeM8sAi3bK7nlqaLFaQJdPkDuSkhKcYGTOtx1z0PfffxJCTwTXDLp1SSp5cRJnXSS6vLH8fC7XRYxaDoXXWkNvL7hlgnRXd5G66s2Av1eUn29Mu8bB7NEYucIfNLQKv2GCu4wQEK3gNllsi6CzyWinEwEUEax/XO/vhXyRmEJzZkYyegYTV0fjHy0+mvM2+/VX7kGZm21xp9EIA63SJTAM2GB7hzVc/LQq698A6ZcK8wUYtliOnEdAIngkQ3wznCG0xlgjxcs8pViBUshwYd19J1zxGUV5ZshmGk5YJCN+vMsNqAgp03letmN0/tjZU3eT9v6q3JN5alPnDT16dAUHASwLbieZUAlN0Lzb+iLb0ITuduC3rjZF6BBpTrjbrz5cTmEa39lYwzHTolKhyzzhq6KN8SZhCzNXn04oBC2ebpMy+AkqmUYjMdEjCEJ4WuCbSJzoeBCVXEpvv3s/UIxLpeMDa3lDxwHcJ/YUNLsdvjyU8taxXJhTznkLwPKKWfrVW6zXXAv6TUFpzDhJus+kjFZV8Gt3LRofLvmzO/VaQk=----ATTACHMENT:----NzgwOTg1MDgyNzcyMjMxMCA1NTUzODM0MDk0NDAzNSA1OTEzOTI0MjY2NTY0NjA4