60        if (!is_string($username) || !strlen($username)) {
 
   64        $this->_username = $username;
 
   81        if (empty($this->_url)) {
 
   83                'No URL set via '.get_class($this).
'->getServiceUrl($url).' 
  106                'Cannot set the URL, stream already opened.' 
  109        if (!is_string(
$url) || !strlen(
$url)) {
 
  135                'Cannot set the mailbox, stream already opened.' 
  138        if (!is_string($mailbox) || !strlen($mailbox)) {
 
  142        $this->_mailbox = $mailbox;
 
  165                'Cannot set options, stream already opened.' 
  197        if (empty($this->_mailbox)) {
 
  199                'You must specify a mailbox via '.get_class($this)
 
  200                .
'->setMailbox($mailbox)' 
  208        phpCAS::trace(
'opening IMAP mailbox `'.$this->_mailbox.
'\'...
'); 
  209        $this->_stream = @imap_open( 
  210            $this->_mailbox, $this->_username, $this->getProxyTicket(), 
  213        if ($this->_stream) { 
  216            phpCAS::trace('could not 
open mailbox
'); 
  217            // @todo add localization integration. 
  218            $message = 'IMAP Error: 
'.$this->_url.' '. var_export(imap_errors(), true); 
  219            phpCAS::trace($message); 
  220            throw new CAS_ProxiedService_Exception($message); 
  224        return $this->_stream; 
  232    protected function hasBeenOpened () 
  234        return !empty($this->_stream); 
  252    public function getStream ()
 
  254        if (!$this->hasBeenOpened()) {
 
  255            throw new CAS_OutOfSequenceException(
 
  256                'Cannot access stream, not opened yet.
' 
  259        return $this->_stream; 
  270    public function getImapProxyTicket () 
  272        if (!$this->hasBeenOpened()) { 
  273            throw new CAS_OutOfSequenceException( 
  274                'Cannot access errors, stream not opened yet.
' 
  277        return $this->getProxyTicket(); 
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
Exception that denotes invalid arguments were passed.
This class defines Exceptions that should be thrown when the sequence of operations is invalid.
This class implements common methods for ProxiedService implementations included with phpCAS.
initializeProxyTicket()
Fetch our proxy ticket.
An Exception for problems communicating with a proxied service.
Provides access to a proxy-authenticated IMAP stream.
getServiceUrl()
Answer a service identifier (URL) for whom we should fetch a proxy ticket.
$_url
The target service url.
$_options
A bit mask of options to pass to imap_open() as the $options parameter.
setMailbox($mailbox)
Set the mailbox to open.
setServiceUrl($url)
Set the URL of the service to pass to CAS for proxy-ticket retrieval.
setOptions($options)
Set the options for opening the stream.
__construct($username)
Constructor.
$_username
The username to send via imap_open.
$_mailbox
The mailbox to open.
hasBeenOpened()
Answer true if our request has been sent yet.
open()
Open the IMAP stream (similar to imap_open()).
static trace($str)
This method is used to log something in debug mode.
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode.