59        if (!is_string($username) || !strlen($username)) {
 
   63        $this->_username = $username;
 
   80        if (empty($this->_url)) {
 
   82                'No URL set via ' . get_class($this) . 
'->getServiceUrl($url).' 
  105                'Cannot set the URL, stream already opened.' 
  108        if (!is_string(
$url) || !strlen(
$url)) {
 
  134                'Cannot set the mailbox, stream already opened.' 
  137        if (!is_string($mailbox) || !strlen($mailbox)) {
 
  141        $this->_mailbox = $mailbox;
 
  164                'Cannot set options, stream already opened.' 
  196        if (empty($this->_mailbox)) {
 
  198                'You must specify a mailbox via ' . get_class($this)
 
  199                . 
'->setMailbox($mailbox)' 
  207        phpCAS::trace(
'opening IMAP mailbox `' . $this->_mailbox . 
'\'...
'); 
  208        $this->_stream = @imap_open( 
  211            $this->getProxyTicket(), 
  214        if ($this->_stream) { 
  217            phpCAS::trace('could not 
open mailbox
'); 
  218            // @todo add localization integration. 
  219            $message = 'IMAP Error: 
' . $this->_url . ' ' . var_export(imap_errors(), true); 
  220            phpCAS::trace($message); 
  221            throw new CAS_ProxiedService_Exception($message); 
  225        return $this->_stream; 
  233    protected function hasBeenOpened() 
  235        return !empty($this->_stream); 
  253    public function getStream()
 
  255        if (!$this->hasBeenOpened()) {
 
  256            throw new CAS_OutOfSequenceException(
 
  257                'Cannot access stream, not opened yet.
' 
  260        return $this->_stream; 
  271    public function getImapProxyTicket() 
  273        if (!$this->hasBeenOpened()) { 
  274            throw new CAS_OutOfSequenceException( 
  275                'Cannot access errors, stream not opened yet.
' 
  278        return $this->getProxyTicket(); 
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.