X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FCasAuthentication%2Fextlib%2FCAS.php;h=e754374198d1d9aa3669ba7464b0aec432c84d5b;hb=2a02c5470e92050fe167cf418d0226cfeae732fe;hp=59238eb8138bc2aa3d335337f099adec07ca0d50;hpb=90a2563a90e1bf2239d177a564bbe3e838d93dc4;p=quix0rs-gnu-social.git diff --git a/plugins/CasAuthentication/extlib/CAS.php b/plugins/CasAuthentication/extlib/CAS.php index 59238eb813..e754374198 100644 --- a/plugins/CasAuthentication/extlib/CAS.php +++ b/plugins/CasAuthentication/extlib/CAS.php @@ -14,7 +14,7 @@ if (!$_SERVER['REQUEST_URI']) { // another one by Vangelis Haniotakis also to make phpCAS work with PHP5 // if (version_compare(PHP_VERSION,'5','>=')) { - require_once(dirname(__FILE__).'/CAS/domxml-php4-php5.php'); + require_once(dirname(__FILE__).'/CAS/domxml-php4-to-php5.php'); } /** @@ -35,7 +35,7 @@ if (version_compare(PHP_VERSION,'5','>=')) { /** * phpCAS version. accessible for the user by phpCAS::getVersion(). */ -define('PHPCAS_VERSION','1.0.1'); +define('PHPCAS_VERSION','1.1.0RC6'); // ------------------------------------------------------------------------ // CAS VERSIONS @@ -54,6 +54,63 @@ define("CAS_VERSION_1_0",'1.0'); */ define("CAS_VERSION_2_0",'2.0'); +// ------------------------------------------------------------------------ +// SAML defines +// ------------------------------------------------------------------------ + +/** + * SAML protocol + */ +define("SAML_VERSION_1_1", 'S1'); + +/** + * XML header for SAML POST + */ +define("SAML_XML_HEADER", ''); + +/** + * SOAP envelope for SAML POST + */ +define ("SAML_SOAP_ENV", ''); + +/** + * SOAP body for SAML POST + */ +define ("SAML_SOAP_BODY", ''); + +/** + * SAMLP request + */ +define ("SAMLP_REQUEST", ''); +define ("SAMLP_REQUEST_CLOSE", ''); + +/** + * SAMLP artifact tag (for the ticket) + */ +define ("SAML_ASSERTION_ARTIFACT", ''); + +/** + * SAMLP close + */ +define ("SAML_ASSERTION_ARTIFACT_CLOSE", ''); + +/** + * SOAP body close + */ +define ("SAML_SOAP_BODY_CLOSE", ''); + +/** + * SOAP envelope close + */ +define ("SAML_SOAP_ENV_CLOSE", ''); + +/** + * SAML Attributes + */ +define("SAML_ATTRIBUTES", 'SAMLATTRIBS'); + + + /** @} */ /** * @addtogroup publicPGTStorage @@ -304,7 +361,7 @@ class phpCAS phpCAS::error('type mismatched for parameter $server_uri (should be `string\')'); } - // store where the initialzer is called from + // store where the initializer is called from $dbg = phpCAS::backtrace(); $PHPCAS_INIT_CALL = array('done' => TRUE, 'file' => $dbg[0]['file'], @@ -739,7 +796,7 @@ class phpCAS if ( gettype($table) != 'string' ) { phpCAS::error('type mismatched for parameter $table (should be `string\')'); } - $PHPCAS_CLIENT->setPGTStorageDB($this,$user,$password,$hostname,$port,$database,$table); + $PHPCAS_CLIENT->setPGTStorageDB($user,$password,$database_type,$hostname,$port,$database,$table); phpCAS::traceEnd(); } @@ -797,6 +854,7 @@ class phpCAS * * @param $url a string giving the URL of the service, including the mailing box * for IMAP URLs, as accepted by imap_open(). + * @param $service a string giving for CAS retrieve Proxy ticket * @param $flags options given to imap_open(). * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, @@ -808,7 +866,7 @@ class phpCAS * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code * gives the reason why it failed and $err_msg contains an error message). */ - function serviceMail($url,$flags,&$err_code,&$err_msg,&$pt) + function serviceMail($url,$service,$flags,&$err_code,&$err_msg,&$pt) { global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; @@ -833,7 +891,7 @@ class phpCAS phpCAS::error('type mismatched for parameter $flags (should be `integer\')'); } - $res = $PHPCAS_CLIENT->serviceMail($url,$flags,$err_code,$err_msg,$pt); + $res = $PHPCAS_CLIENT->serviceMail($url,$service,$flags,$err_code,$err_msg,$pt); phpCAS::traceEnd($res); return $res; @@ -893,7 +951,7 @@ class phpCAS phpCAS::traceEnd($auth); return $auth; } - + /** * This method is called to force authentication if the user was not already * authenticated. If the user is not authenticated, halt by redirecting to @@ -1022,6 +1080,27 @@ class phpCAS return $PHPCAS_CLIENT->getUser(); } + /** + * This method returns the CAS user's login name. + * @warning should not be called only after phpCAS::forceAuthentication() + * or phpCAS::checkAuthentication(). + * + * @return the login name of the authenticated user + */ + function getAttributes() + { + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; + if ( !is_object($PHPCAS_CLIENT) ) { + phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); + } + if ( !$PHPCAS_AUTH_CHECK_CALL['done'] ) { + phpCAS::error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'); + } + if ( !$PHPCAS_AUTH_CHECK_CALL['result'] ) { + phpCAS::error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); + } + return $PHPCAS_CLIENT->getAttributes(); + } /** * Handle logout requests. */ @@ -1069,6 +1148,71 @@ class phpCAS $PHPCAS_CLIENT->setServerLoginURL($url); phpCAS::traceEnd(); } + + + /** + * Set the serviceValidate URL of the CAS server. + * @param $url the serviceValidate URL + * @since 1.1.0 by Joachim Fritschi + */ + function setServerServiceValidateURL($url='') + { + global $PHPCAS_CLIENT; + phpCAS::traceBegin(); + if ( !is_object($PHPCAS_CLIENT) ) { + phpCAS::error('this method should only be called after + '.__CLASS__.'::client()'); + } + if ( gettype($url) != 'string' ) { + phpCAS::error('type mismatched for parameter $url (should be + `string\')'); + } + $PHPCAS_CLIENT->setServerServiceValidateURL($url); + phpCAS::traceEnd(); + } + + + /** + * Set the proxyValidate URL of the CAS server. + * @param $url the proxyValidate URL + * @since 1.1.0 by Joachim Fritschi + */ + function setServerProxyValidateURL($url='') + { + global $PHPCAS_CLIENT; + phpCAS::traceBegin(); + if ( !is_object($PHPCAS_CLIENT) ) { + phpCAS::error('this method should only be called after + '.__CLASS__.'::client()'); + } + if ( gettype($url) != 'string' ) { + phpCAS::error('type mismatched for parameter $url (should be + `string\')'); + } + $PHPCAS_CLIENT->setServerProxyValidateURL($url); + phpCAS::traceEnd(); + } + + /** + * Set the samlValidate URL of the CAS server. + * @param $url the samlValidate URL + * @since 1.1.0 by Joachim Fritschi + */ + function setServerSamlValidateURL($url='') + { + global $PHPCAS_CLIENT; + phpCAS::traceBegin(); + if ( !is_object($PHPCAS_CLIENT) ) { + phpCAS::error('this method should only be called after + '.__CLASS__.'::client()'); + } + if ( gettype($url) != 'string' ) { + phpCAS::error('type mismatched for parameter $url (should be + `string\')'); + } + $PHPCAS_CLIENT->setServerSamlValidateURL($url); + phpCAS::traceEnd(); + } /** * This method returns the URL to be used to login.