]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/CasAuthentication/extlib/CAS.php
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / CasAuthentication / extlib / CAS.php
index 59238eb8138bc2aa3d335337f099adec07ca0d50..e754374198d1d9aa3669ba7464b0aec432c84d5b 100644 (file)
@@ -14,7 +14,7 @@ if (!$_SERVER['REQUEST_URI']) {
 // another one by Vangelis Haniotakis also to make phpCAS work with PHP5\r
 //\r
 if (version_compare(PHP_VERSION,'5','>=')) {\r
-       require_once(dirname(__FILE__).'/CAS/domxml-php4-php5.php');\r
+       require_once(dirname(__FILE__).'/CAS/domxml-php4-to-php5.php');\r
 }\r
 \r
 /**\r
@@ -35,7 +35,7 @@ if (version_compare(PHP_VERSION,'5','>=')) {
 /**\r
  * phpCAS version. accessible for the user by phpCAS::getVersion().\r
  */\r
-define('PHPCAS_VERSION','1.0.1');\r
+define('PHPCAS_VERSION','1.1.0RC6');\r
 \r
 // ------------------------------------------------------------------------\r
 //  CAS VERSIONS\r
@@ -54,6 +54,63 @@ define("CAS_VERSION_1_0",'1.0');
  */\r
 define("CAS_VERSION_2_0",'2.0');\r
 \r
+// ------------------------------------------------------------------------\r
+//  SAML defines\r
+// ------------------------------------------------------------------------\r
+\r
+/**\r
+ * SAML protocol\r
+ */\r
+define("SAML_VERSION_1_1", 'S1');\r
+\r
+/**\r
+ * XML header for SAML POST\r
+ */\r
+define("SAML_XML_HEADER", '<?xml version="1.0" encoding="UTF-8"?>');\r
+\r
+/**\r
+ * SOAP envelope for SAML POST\r
+ */\r
+define ("SAML_SOAP_ENV", '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/>');\r
+\r
+/**\r
+ * SOAP body for SAML POST\r
+ */\r
+define ("SAML_SOAP_BODY", '<SOAP-ENV:Body>');\r
+\r
+/**\r
+ * SAMLP request\r
+ */\r
+define ("SAMLP_REQUEST", '<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"  MajorVersion="1" MinorVersion="1" RequestID="_192.168.16.51.1024506224022" IssueInstant="2002-06-19T17:03:44.022Z">');\r
+define ("SAMLP_REQUEST_CLOSE", '</samlp:Request>');\r
+\r
+/**\r
+ * SAMLP artifact tag (for the ticket)\r
+ */\r
+define ("SAML_ASSERTION_ARTIFACT", '<samlp:AssertionArtifact>');\r
+\r
+/**\r
+ * SAMLP close\r
+ */\r
+define ("SAML_ASSERTION_ARTIFACT_CLOSE", '</samlp:AssertionArtifact>');\r
+\r
+/**\r
+ * SOAP body close\r
+ */\r
+define ("SAML_SOAP_BODY_CLOSE", '</SOAP-ENV:Body>');\r
+\r
+/**\r
+ * SOAP envelope close\r
+ */\r
+define ("SAML_SOAP_ENV_CLOSE", '</SOAP-ENV:Envelope>');\r
+\r
+/**\r
+ * SAML Attributes\r
+ */\r
+define("SAML_ATTRIBUTES", 'SAMLATTRIBS');\r
+\r
+\r
+\r
 /** @} */\r
  /**\r
   * @addtogroup publicPGTStorage\r
@@ -304,7 +361,7 @@ class phpCAS
                        phpCAS::error('type mismatched for parameter $server_uri (should be `string\')');\r
                }\r
                \r
-               // store where the initialzer is called from\r
+               // store where the initializer is called from\r
                $dbg = phpCAS::backtrace();\r
                $PHPCAS_INIT_CALL = array('done' => TRUE,\r
                        'file' => $dbg[0]['file'],\r
@@ -739,7 +796,7 @@ class phpCAS
                if ( gettype($table) != 'string' ) {\r
                        phpCAS::error('type mismatched for parameter $table (should be `string\')');\r
                }\r
-               $PHPCAS_CLIENT->setPGTStorageDB($this,$user,$password,$hostname,$port,$database,$table);\r
+               $PHPCAS_CLIENT->setPGTStorageDB($user,$password,$database_type,$hostname,$port,$database,$table);\r
                phpCAS::traceEnd();\r
                }\r
        \r
@@ -797,6 +854,7 @@ class phpCAS
         * \r
         * @param $url a string giving the URL of the service, including the mailing box\r
         * for IMAP URLs, as accepted by imap_open().\r
+        * @param $service a string giving for CAS retrieve Proxy ticket\r
         * @param $flags options given to imap_open().\r
         * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on\r
         * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,\r
@@ -808,7 +866,7 @@ class phpCAS
         * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code\r
         * gives the reason why it failed and $err_msg contains an error message).\r
         */\r
-       function serviceMail($url,$flags,&$err_code,&$err_msg,&$pt)\r
+       function serviceMail($url,$service,$flags,&$err_code,&$err_msg,&$pt)\r
                {\r
                global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;\r
                \r
@@ -833,7 +891,7 @@ class phpCAS
                        phpCAS::error('type mismatched for parameter $flags (should be `integer\')');\r
                }\r
                \r
-               $res = $PHPCAS_CLIENT->serviceMail($url,$flags,$err_code,$err_msg,$pt);\r
+               $res = $PHPCAS_CLIENT->serviceMail($url,$service,$flags,$err_code,$err_msg,$pt);\r
                \r
                phpCAS::traceEnd($res);\r
                return $res;\r
@@ -893,7 +951,7 @@ class phpCAS
                phpCAS::traceEnd($auth);\r
                return $auth; \r
                }\r
-       \r
+\r
        /**\r
         * This method is called to force authentication if the user was not already \r
         * authenticated. If the user is not authenticated, halt by redirecting to \r
@@ -1022,6 +1080,27 @@ class phpCAS
                return $PHPCAS_CLIENT->getUser();\r
                }\r
        \r
+       /**\r
+        * This method returns the CAS user's login name.\r
+        * @warning should not be called only after phpCAS::forceAuthentication()\r
+        * or phpCAS::checkAuthentication().\r
+        *\r
+        * @return the login name of the authenticated user\r
+        */\r
+       function getAttributes()\r
+               {\r
+               global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;\r
+               if ( !is_object($PHPCAS_CLIENT) ) {\r
+                       phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');\r
+               }\r
+               if ( !$PHPCAS_AUTH_CHECK_CALL['done'] ) {\r
+                       phpCAS::error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()');\r
+               }\r
+               if ( !$PHPCAS_AUTH_CHECK_CALL['result'] ) {\r
+                       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');\r
+               }\r
+               return $PHPCAS_CLIENT->getAttributes();\r
+               }\r
     /**\r
      * Handle logout requests.\r
      */\r
@@ -1069,6 +1148,71 @@ class phpCAS
                $PHPCAS_CLIENT->setServerLoginURL($url);\r
                phpCAS::traceEnd();\r
                }\r
+               \r
+               \r
+       /**\r
+        * Set the serviceValidate URL of the CAS server.\r
+        * @param $url the serviceValidate URL\r
+        * @since 1.1.0 by Joachim Fritschi\r
+        */\r
+       function setServerServiceValidateURL($url='')\r
+               {\r
+               global $PHPCAS_CLIENT;\r
+               phpCAS::traceBegin();\r
+               if ( !is_object($PHPCAS_CLIENT) ) {\r
+                       phpCAS::error('this method should only be called after\r
+                               '.__CLASS__.'::client()');\r
+               }\r
+               if ( gettype($url) != 'string' ) {\r
+                       phpCAS::error('type mismatched for parameter $url (should be\r
+                       `string\')');\r
+               }\r
+               $PHPCAS_CLIENT->setServerServiceValidateURL($url);\r
+               phpCAS::traceEnd();\r
+               }\r
+               \r
+               \r
+        /**\r
+        * Set the proxyValidate URL of the CAS server.\r
+        * @param $url the proxyValidate URL\r
+        * @since 1.1.0 by Joachim Fritschi\r
+        */\r
+       function setServerProxyValidateURL($url='')\r
+               {\r
+               global $PHPCAS_CLIENT;\r
+               phpCAS::traceBegin();\r
+               if ( !is_object($PHPCAS_CLIENT) ) {\r
+                       phpCAS::error('this method should only be called after\r
+                               '.__CLASS__.'::client()');\r
+               }\r
+               if ( gettype($url) != 'string' ) {\r
+                       phpCAS::error('type mismatched for parameter $url (should be\r
+                       `string\')');\r
+               }\r
+               $PHPCAS_CLIENT->setServerProxyValidateURL($url);\r
+               phpCAS::traceEnd();\r
+               }\r
+               \r
+     /**\r
+        * Set the samlValidate URL of the CAS server.\r
+        * @param $url the samlValidate URL\r
+        * @since 1.1.0 by Joachim Fritschi\r
+        */\r
+       function setServerSamlValidateURL($url='')\r
+               {\r
+               global $PHPCAS_CLIENT;\r
+               phpCAS::traceBegin();\r
+               if ( !is_object($PHPCAS_CLIENT) ) {\r
+                       phpCAS::error('this method should only be called after\r
+                               '.__CLASS__.'::client()');\r
+               }\r
+               if ( gettype($url) != 'string' ) {\r
+                       phpCAS::error('type mismatched for parameter $url (should be\r
+                       `string\')');\r
+               }\r
+               $PHPCAS_CLIENT->setServerSamlValidateURL($url);\r
+               phpCAS::traceEnd();\r
+               }                       \r
        \r
        /**\r
         * This method returns the URL to be used to login.\r