[geeklog-cvs] Auth_Enterprise/Enterprise/Client SOAP.php,1.2,1.3

tony at iowaoutdoors.org tony at iowaoutdoors.org
Tue Jul 27 16:43:07 EDT 2004


Update of /var/cvs/Auth_Enterprise/Enterprise/Client
In directory www:/tmp/cvs-serv25394

Modified Files:
	SOAP.php 
Log Message:
Back into a semi-working state.  Not all methods have been implemented nor tested.

Index: SOAP.php
===================================================================
RCS file: /var/cvs/Auth_Enterprise/Enterprise/Client/SOAP.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SOAP.php	26 Jul 2004 18:50:10 -0000	1.2
--- SOAP.php	27 Jul 2004 20:43:05 -0000	1.3
***************
*** 32,40 ****
  
  /**
- * PEAR's XML RPC Client
- */
- require_once 'XML/RPC.php';
- 
- /**
  * Auth_Enteprise XML RPC Implementation
  *
--- 32,35 ----
***************
*** 90,106 ****
      public function authenticate($userName, $password)
      {
!         try {
!             $result = $this->SOAPClient->authenticate($this->getAppId(), $userName, $password);
!         } catch (SoapFault $e) {
!             print_r($e);
!             exit;
!         }
          
-         if (is_soap_fault($result)) {
-             trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
-         }
          // If we got a fault, throw an exception back to the calling
          // application
!         if ($response->faultCode()) {
              try {
                  $e = $this->faultToException($result->faultcode, $result->faultstring);
--- 85,93 ----
      public function authenticate($userName, $password)
      {
!         $result = $this->SOAPClient->authenticate($userName, $password, $this->getAppId());
          
          // If we got a fault, throw an exception back to the calling
          // application
!         if (is_soap_fault($result)) {
              try {
                  $e = $this->faultToException($result->faultcode, $result->faultstring);
***************
*** 111,263 ****
          }
          
!         /*$user = new Auth_Enterprise_User;
!         $user->setUserName($retval['userName']);
!         $user->setPassword($retval['password']);
          $user->setClientProvider($this);
!         $user->setPrivileges($this->arrayToPrivileges($retval['privileges']));
!         $user->setGroups($this->arrayToGroups($retval['groups']));
          
          return $user;
-         */
-         
-         return $result;
-         
-     }
-     
-     protected function parseOptions($options = array())
-     {
-         if (!isset($options['appId'])) {
-             throw new AEInsufficientClientOptions('XML-RPC Client requires the appId option to be set.');
-         }
-         
-         if (!isset($options['wsdl'])) {
-             $options['wsdl'] = null;
-         }
-         
-         if (!isset($options['php_soap_options'])) {
-             $options['php_soap_options'] = array();
-         }
-             
-         // Enable debugging if requested.
-         /*if ($options['debug'] == 1) {
-             $this->XMLRPCClient->setDebug(true);
-         }*/
-         
-         parent::parseOptions($options);
      }
      
      /**
!     * Copies the group arrays returned from the XML_RPC call
!     * into Group objects
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access private
!     * @param array $groupArray Array of group arrays
!     * @return array Array of AEGroup objects
!     *
!     */
!     private function moveGroupsToObjects($groups)
!     {
!         $groupArray = array();
!         $tmpGroup = new Auth_Enterprise_Group();
!         foreach ($groups as $curGroup) {
!             $tmpGroup->setGroupId($curGroup[_groupId]);
!             $tmpGroup->setGroupLogicalName($curGroup['groupLogicalName']);
!             $tmpGroup->setGroupDisplayName($curGroup['groupDisplayName']);
!             $tmpGroup->setGroupDesc($curGroup[_groupDesc]);
!             $groupArray[] = $tmpGroup;
!         }
!         return $groupArray;
!     }
!     
!     /**
!     * Converts an array from an XMLRPC response to an array of privileges objects
      *
      * @author Tony Bibbs <tony at geeklog.net>
!     * @access private
!     * @param array $privArray Array representing privilege objects
!     * @return array Array of actual AEPrivileges objects
      *
      */
!     private function arrayToPrivileges($privArray)
      {
!         $retval = array();
!         if (is_array($privArray)) {
!             foreach ($privArray as $curPriv) {
!                 $newPriv = new Auth_Enterprise_Privilege();
!                 $newPriv->setPrivilegeCode($curPriv['privilegeCode']);
!                 $newPriv->setPrivilegeDesc($curPriv['privilegeDesc']);
!                 $retval[] = $newPriv;
              }
          }
-         return $retval;
      }
      
      /**
!     * Converts AEPrivilege objects to arrays.
      *
      * @author Tony Bibbs <tony at geeklog.net>
!     * @access private
!     * @param array $privArray Array of AEPrivilege objects
!     * @return array Array representing AEPrivielge objects
      *
      */
!     private function privilegesToArray($privArray)
      {
!         $retval = array();
!         foreach ($privArray as $curPriv) {
!             $tmpArray['privilegeCode'] = $curPriv->getPrivilegeCode();
!             $tmpArray['privilegeDesc'] = $curPriv->getPrivilegeDesc();
!             $retval[] = $tmpArray;
          }
!         return $retval;
      }
      
      /**
!     * Converts an array from an XMLRPC response to an array of group objects
      *
      * @author Tony Bibbs <tony at geeklog.net>
      * @access private
!     * @param array $groupArray Array representing group objects
!     * @return array Array of actual AEGroup objects
      *
      */
!     private function arrayToGroups($groupArray)
      {
!         $retval = array();
!         if (is_array($groupArray)) {
!             foreach ($groupArray as $curGroup) {
!                 $tmpGroup = new Auth_Enterprise_Group();
!                 $tmpGroup->setGroupId($curGroup['groupId']);
!                 $tmpGroup->setGroupLogicalName($curGroup['groupLogicalName']);
!                 $tmpGroup->setGroupDisplayName($curGroup['groupDisplayName']);
!                 $tmpGroup->setGroupDesc($curGroup['groupDesc']);
!                 $tmpGroup->setGroupPrivileges($curGroup['privileges']);
!                 $retval[] = $tmpGroup;
!             }
          }
!         return $retval;
      }
      
      /**
!     * Converts AEPrivilege objects to arrays.
      *
      * @author Tony Bibbs <tony at geeklog.net>
      * @access private
!     * @param array $privArray Array of AEPrivilege objects
!     * @return array Array representing AEPrivielge objects
      *
      */
!     private function groupsToArray($groupArray)
      {
!         $retval = array();
          foreach ($groupArray as $curGroup) {
!             $tmpArray['groupId'] = $curGroup->getGroupId();
!             $tmpArray['groupLogicalName'] = $curGroup->getGroupLogicalName();
!             $tmpArray['groupDisplayName'] = $curGroup->getGroupDisplayName();
!             $tmpArray['groupDesc'] = $curGroup->getGroupDesc();
!             $retval[] = $tmpArray;
          }
!         return $retval;
      }
      
--- 98,218 ----
          }
          
!         // Convert SOAP response to user object.  This is quite easy as the SOAP server returns an
!         // object close resembling our user object.
!         $user = new Auth_Enterprise_User();
!         $user->setUserName($result->userName);
!         $user->setPassword($result->password);
!         $user->setAccountLocked($result->accountLocked);
!         $user->setFailedAttempts($result->failedAttempts);
!         $user->setLastPWChange($result->lastPWChange);
          $user->setClientProvider($this);
!         $user->setPrivileges($this->stdObjArrayToPrivileges($result->privileges));
!         $user->setGroups($this->stdObjArrayToGroups($retval->groups));
          
          return $user;
      }
      
      /**
!     * Registers a new account with the service
      *
      * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
      *
      */
!     public function createAccountByAdmin($adminUserName, $adminPassword, $userName, $userPassword)
      {
!         $result->$this->SOAPClient->createAccountByAdmin($adminUsername, $adminPassword, $userName, $userPassword, $this->getAppId());
!         
!         // If we got a fault, throw an exception back to the calling
!         // application
!         if (is_soap_fault($result)) {
!             try {
!                 $e = $this->faultToException($result->faultcode, $result->faultstring);
!                 throw $e;
!             } catch (AEBaseException $e) {
!                 throw $e;
              }
          }
      }
      
      /**
!     * Gets options and makes sure we got everything we require
      *
      * @author Tony Bibbs <tony at geeklog.net>
!     * @access protected
!     * @param array $options Options to check
      *
      */
!     protected function parseOptions($options = array())
      {
!         if (!isset($options['appId'])) {
!             throw new AEInsufficientClientOptions('SOAP Client requires the appId option to be set.');
          }
!         
!         if (!isset($options['wsdl'])) {
!             throw new AEInsufficientClientOptions('SOAP Client requires the appId option to be set.');
!         }
!         
!         if (!isset($options['php_soap_options'])) {
!             $options['php_soap_options'] = array();
!         }
!             
!         parent::parseOptions($options);
      }
      
      /**
!     * Converts the privileges inside the stdObj returned by the SOAP Server and converts the
!     * privileges inside to an array of Auth_Enterpirse_Privilege objects
      *
      * @author Tony Bibbs <tony at geeklog.net>
      * @access private
!     * @param array $privilegeArray Array off stdObj objects
!     * @return array Array of Auth_Enterprise_Privilege objects
      *
      */
!     private function stdObjArrayToPrivileges($privilegeArray)
      {
!         $retArray = array();
!         
!         if (!is_array($privilegeArray)) {
!             return $retArray;
          }
!         
!         foreach ($privilegeArray as $curPriv) {
!             $tmpPriv = new Auth_Enterprise_Privilege($curPriv->privilegeCode, $curPriv->privilegeDesc);
!             $retArray[] = $tmpPriv;
!         }
!         
!         return $retArray;
      }
      
      /**
!     * Converts the grups inside the stdObj returned by the SOAP Server and converts the
!     * groups inside to an array of Auth_Enterpirse_Group objects
      *
      * @author Tony Bibbs <tony at geeklog.net>
      * @access private
!     * @param array $groupArray Array off stdObj objects
!     * @return array Array of Auth_Enterprise_Group objects
      *
      */
!     private function stdObjArrayToGroups($groupArray)
      {
!         $retArray = array();
!         
!         if (!is_array($groupArray)) {
!             return $retArray;
!         }
!         
          foreach ($groupArray as $curGroup) {
!             $tmpGroup = new Auth_Enterprise_Group();
!             $tmpGroup->setGroupId($curGroup->groupId);
!             $tmpGroup->setGroupLogicaName($curGroup->groupLogicalName);
!             $tmpGroup->setGroupDisplayName($curGroup->groupDisplayName);
!             $tmpGroup->setGroupDesc($curGroup->groupDesc);
!             $retArray[] = $tmpGroup;
          }
!         
!         return $retArray;
      }
      




More information about the geeklog-cvs mailing list