[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/auth/cas/CAS/ -> client.php (summary)

(no description)

File Size: 2078 lines (65 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CASClient:: (62 methods):
  HTMLFilterOutput()
  printHTMLHeader()
  printHTMLFooter()
  setHTMLHeader()
  setHTMLFooter()
  getLang()
  getString()
  setLang()
  getServerVersion()
  getServerHostname()
  getServerPort()
  getServerURI()
  getServerBaseURL()
  getServerLoginURL()
  setServerLoginURL()
  getServerServiceValidateURL()
  getServerProxyValidateURL()
  getServerProxyURL()
  getServerLogoutURL()
  setServerLogoutURL()
  isHttps()
  CASClient()
  setUser()
  getUser()
  forceAuthentication()
  setCacheTimesForAuthRequest()
  checkAuthentication()
  isAuthenticated()
  isSessionAuthenticated()
  wasPreviouslyAuthenticated()
  redirectToCas()
  logout()
  getST()
  setST()
  hasST()
  validateST()
  isProxy()
  getPGT()
  setPGT()
  hasPGT()
  setCallbackMode()
  isCallbackMode()
  getCallbackURL()
  setCallbackURL()
  callback()
  initPGTStorage()
  storePGT()
  loadPGT()
  setPGTStorageFile()
  setPGTStorageDB()
  validatePGT()
  retrievePT()
  readURL()
  serviceWeb()
  serviceMail()
  getPT()
  setPT()
  hasPT()
  validatePT()
  getURL()
  setURL()
  authError()


Class: CASClient  - X-Ref


HTMLFilterOutput($str)   X-Ref
This method filters a string by replacing special tokens by appropriate values
and prints it. The corresponding tokens are taken into account:
- __CAS_VERSION__
- __PHPCAS_VERSION__
- __SERVER_BASE_URL__

Used by CASClient::PrintHTMLHeader() and CASClient::printHTMLFooter().

param: $str the string to filter and output

printHTMLHeader($title)   X-Ref
This method prints the header of the HTML output (after filtering). If
CASClient::setHTMLHeader() was not used, a default header is output.

param: $title the title of the page

printHTMLFooter()   X-Ref
This method prints the footer of the HTML output (after filtering). If
CASClient::setHTMLFooter() was not used, a default footer is output.


setHTMLHeader($header)   X-Ref
This method set the HTML header used for all outputs.

param: $header the HTML header.

setHTMLFooter($footer)   X-Ref
This method set the HTML footer used for all outputs.

param: $footer the HTML footer.

getLang()   X-Ref
This method returns the language used by phpCAS.

return: a string representing the language

getString($str)   X-Ref
This method returns a string depending on the language.

param: $str the index of the string in $_string.
return: the string corresponding to $index in $string.

setLang($lang)   X-Ref
This method is used to set the language used by phpCAS.

param: $lang a string representing the language.

getServerVersion()   X-Ref
This method is used to retrieve the version of the CAS server.

return: the version of the CAS server.

getServerHostname()   X-Ref
This method is used to retrieve the hostname of the CAS server.

return: the hostname of the CAS server.

getServerPort()   X-Ref
This method is used to retrieve the port of the CAS server.

return: the port of the CAS server.

getServerURI()   X-Ref
This method is used to retrieve the URI of the CAS server.

return: a URI.

getServerBaseURL()   X-Ref
This method is used to retrieve the base URL of the CAS server.

return: a URL.

getServerLoginURL($gateway=false)   X-Ref
This method is used to retrieve the login URL of the CAS server.

param: $gateway true to check authentication, false to force it
return: a URL.

setServerLoginURL($url)   X-Ref
This method sets the login URL of the CAS server.

param: $url the login URL

getServerServiceValidateURL()   X-Ref
This method is used to retrieve the service validating URL of the CAS server.

return: a URL.

getServerProxyValidateURL()   X-Ref
This method is used to retrieve the proxy validating URL of the CAS server.

return: a URL.

getServerProxyURL()   X-Ref
This method is used to retrieve the proxy URL of the CAS server.

return: a URL.

getServerLogoutURL()   X-Ref
This method is used to retrieve the logout URL of the CAS server.

return: a URL.

setServerLogoutURL($url)   X-Ref
This method sets the logout URL of the CAS server.

param: $url the logout URL

isHttps()   X-Ref
This method checks to see if the request is secured via HTTPS

return: true if https, false otherwise

CASClient($server_version,$proxy,$server_hostname,$server_port,$server_uri,$start_session = true)   X-Ref
CASClient constructor.

param: $server_version the version of the CAS server
param: $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise
param: $server_hostname the hostname of the CAS server
param: $server_port the port the CAS server is running on
param: $server_uri the URI the CAS server is responding on
param: $start_session Have phpCAS start PHP sessions (default true)
return: a newly created CASClient object

setUser($user)   X-Ref
This method sets the CAS user's login name.

param: $user the login name of the authenticated user.

getUser()   X-Ref
This method returns the CAS user's login name.

return: the login name of the authenticated user

forceAuthentication()   X-Ref
This method is called to be sure that the user is authenticated. When not
authenticated, halt by redirecting to the CAS server; otherwise return TRUE.

return: TRUE when the user is authenticated; otherwise halt.

setCacheTimesForAuthRequest($n)   X-Ref
Set the number of times authentication will be cached before rechecked.

param: $n an integer.

checkAuthentication()   X-Ref
This method is called to check whether the user is authenticated or not.

return: TRUE when the user is authenticated, FALSE otherwise.

isAuthenticated()   X-Ref
This method is called to check if the user is authenticated (previously or by
tickets given in the URL).

return: TRUE when the user is authenticated.

isSessionAuthenticated()   X-Ref
This method tells if the current session is authenticated.

return: true if authenticated based soley on $_SESSION variable

wasPreviouslyAuthenticated()   X-Ref
This method tells if the user has already been (previously) authenticated
by looking into the session variables.

return: TRUE when the user has already been authenticated; FALSE otherwise.

redirectToCas($gateway=false)   X-Ref
This method is used to redirect the client to the CAS server.
It is used by CASClient::forceAuthentication() and CASClient::checkAuthentication().

param: $gateway true to check authentication, false to force it

logout($url = "")   X-Ref
This method is used to logout from CAS.

param: $url a URL that will be transmitted to the CAS server (to come back to when logged out)

getST()   X-Ref
This method returns the Service Ticket provided in the URL of the request.

return: The service ticket.

setST($st)   X-Ref
This method stores the Service Ticket.

param: $st The Service Ticket.

hasST()   X-Ref
This method tells if a Service Ticket was stored.

return: TRUE if a Service Ticket has been stored.

validateST($validate_url,&$text_response,&$tree_response)   X-Ref
This method is used to validate a ST; halt on failure, and sets $validate_url,
$text_reponse and $tree_response on success. These parameters are used later
by CASClient::validatePGT() for CAS proxies.

param: $validate_url the URL of the request to the CAS server.
param: $text_response the response of the CAS server, as is (XML text).
param: $tree_response the response of the CAS server, as a DOM XML tree.
return: bool TRUE when successfull, halt otherwise by calling CASClient::authError().

isProxy()   X-Ref
Tells if a CAS client is a CAS proxy or not

return: TRUE when the CAS client is a CAs proxy, FALSE otherwise

getPGT()   X-Ref
This method returns the Proxy Granting Ticket given by the CAS server.

return: The Proxy Granting Ticket.

setPGT($pgt)   X-Ref
This method stores the Proxy Granting Ticket.

param: $pgt The Proxy Granting Ticket.

hasPGT()   X-Ref
This method tells if a Proxy Granting Ticket was stored.

return: TRUE if a Proxy Granting Ticket has been stored.

setCallbackMode($callback_mode)   X-Ref
This method sets/unsets callback mode.

param: $callback_mode TRUE to set callback mode, FALSE otherwise.

isCallbackMode()   X-Ref
This method returns TRUE when the CAs client is running i callback mode,
FALSE otherwise.

return: A boolean.

getCallbackURL()   X-Ref
This method returns the URL that should be used for the PGT callback (in
fact the URL of the current request without any CGI parameter, except if
phpCAS::setFixedCallbackURL() was used).

return: The callback URL

setCallbackURL($url)   X-Ref
This method sets the callback url.

param: $callback_url url to set callback

callback()   X-Ref
This method is called by CASClient::CASClient() when running in callback
mode. It stores the PGT and its PGT Iou, prints its output and halts.


initPGTStorage()   X-Ref
This method is used to initialize the storage of PGT's.
Halts on error.


storePGT($pgt,$pgt_iou)   X-Ref
This method stores a PGT. Halts on error.

param: $pgt the PGT to store
param: $pgt_iou its corresponding Iou

loadPGT($pgt_iou)   X-Ref
This method reads a PGT from its Iou and deletes the corresponding storage entry.

param: $pgt_iou the PGT Iou
return: The PGT corresponding to the Iou, FALSE when not found.

setPGTStorageFile($format='',$path='')   X-Ref
This method is used to tell phpCAS to store the response of the
CAS server to PGT requests onto the filesystem.

param: $format the format used to store the PGT's (`plain' and `xml' allowed)
param: $path the path where the PGT's should be stored

setPGTStorageDB($user,$password,$database_type,$hostname,$port,$database,$table)   X-Ref
This method is used to tell phpCAS to store the response of the
CAS server to PGT requests into a database.

param: $user the user to access the data with
param: $password the user's password
param: $database_type the type of the database hosting the data
param: $hostname the server hosting the database
param: $port the port the server is listening on
param: $database the name of the database
param: $table the name of the table storing the data

validatePGT(&$validate_url,$text_response,$tree_response)   X-Ref
This method is used to validate a PGT; halt on failure.

param: $validate_url the URL of the request to the CAS server.
param: $text_response the response of the CAS server, as is (XML text); result
param: $tree_response the response of the CAS server, as a DOM XML tree; result
return: bool TRUE when successfull, halt otherwise by calling CASClient::authError().

retrievePT($target_service,&$err_code,&$err_msg)   X-Ref
This method is used to retrieve PT's from the CAS server thanks to a PGT.

param: $target_service the service to ask for with the PT.
param: $err_code an error code (PHPCAS_SERVICE_OK on success).
param: $err_msg an error message (empty on success).
return: a Proxy Ticket, or FALSE on error.

readURL($url,$cookies,&$headers,&$body,&$err_msg)   X-Ref
This method is used to acces a remote URL.

param: $url the URL to access.
param: $cookies an array containing cookies strings such as 'name=val'
param: $headers an array containing the HTTP header lines of the response
param: $body the body of the response, as a string (empty on failure).
param: $err_msg an error message, filled on failure.
return: TRUE on success, FALSE otherwise (in this later case, $err_msg

serviceWeb($url,&$err_code,&$output)   X-Ref
This method is used to access an HTTP[S] service.

param: $url the service to access.
param: $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
param: $output the output of the service (also used to give an error
return: TRUE on success, FALSE otherwise (in this later case, $err_code

serviceMail($url,$flags,&$err_code,&$err_msg,&$pt)   X-Ref
This method is used to access an IMAP/POP3/NNTP service.

param: $url a string giving the URL of the service, including the mailing box
param: $flags options given to imap_open().
param: $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
param: $err_msg an error message on failure
param: $pt the Proxy Ticket (PT) retrieved from the CAS server to access the URL
return: an IMAP stream on success, FALSE otherwise (in this later case, $err_code

getPT()   X-Ref
This method returns the Proxy Ticket provided in the URL of the request.

return: The proxy ticket.

setPT($pt)   X-Ref
This method stores the Proxy Ticket.

param: $pt The Proxy Ticket.

hasPT()   X-Ref
This method tells if a Proxy Ticket was stored.

return: TRUE if a Proxy Ticket has been stored.

validatePT(&$validate_url,&$text_response,&$tree_response)   X-Ref
This method is used to validate a PT; halt on failure

return: bool TRUE when successfull, halt otherwise by calling CASClient::authError().

getURL()   X-Ref
This method returns the URL of the current request (without any ticket
CGI parameter).

return: The URL

setURL($url)   X-Ref
This method sets the URL of the current request

param: $url url to set for service

authError($failure,$cas_url,$no_response,$bad_response='',$cas_response='',$err_code='',$err_msg='')   X-Ref
This method is used to print the HTML output when the user was not authenticated.

param: $failure the failure that occured
param: $cas_url the URL the CAS server was asked for
param: $no_response the response from the CAS server (other
param: $bad_response bad response from the CAS server ($err_code
param: $cas_response the response of the CAS server
param: $err_code the error code given by the CAS server
param: $err_msg the error message given by the CAS server



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7