cvs: pear /Auth package.xml /Auth/Container SOAP.php

From: Date: Fri, 07 Feb 2003 21:54:09 +0000
Subject: cvs: pear /Auth package.xml /Auth/Container SOAP.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8747@lists.php.net to get a copy of this message
mj Fri Feb 7 16:54:09 2003 EDT Added files: /pear/Auth/Container SOAP.php Modified files: /pear/Auth package.xml Log: * Add SOAP container by Bruno Pedro. Index: pear/Auth/package.xml diff -u pear/Auth/package.xml:1.24 pear/Auth/package.xml:1.25 --- pear/Auth/package.xml:1.24 Tue Feb 4 14:08:40 2003 +++ pear/Auth/package.xml Fri Feb 7 16:54:09 2003 @@ -14,7 +14,8 @@ * POP3 servers * IMAP servers * vpopmail accounts -* RADIUS</description> +* RADIUS +* SOAP</description> <maintainers> <maintainer> <user>MJ</user> @@ -44,6 +45,8 @@ <jeroen@terena.nl>. * Added new POP3 storage container written by Yavor Shahpasov <yavo@siava.org>. +* Added new SOAP storage container written by Bruno Pedro + <bpedro@co.sapo.pt>. * Fixed some smaller bugs. ]]> </notes> @@ -57,7 +60,8 @@ <file name="IMAP.php"/> <file name="POP3.php"/> <file name="LDAP.php"/> - <file name="RADIUS.php"/> + <file name="RADIUS.php"/> + <file name="SOAP.php"/> <file name="vpopmail.php"/> </dir> </filelist> Index: pear/Auth/Container/SOAP.php +++ pear/Auth/Container/SOAP.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Bruno Pedro <bpedro@co.sapo.pt> | // +----------------------------------------------------------------------+ // // $Id: SOAP.php,v 1.1 2003/02/07 21:54:09 mj Exp $ // require_once "Auth/Container.php"; require_once "PEAR.php"; require_once 'SOAP/Client.php'; /** * Storage driver for fetching login data from SOAP * * This class takes one parameter (options), where * you specify the following fields: endpoint, namespace, * method, encoding, usernamefield and passwordfield. * You can use specific features of your SOAP service * by providing its parameters in an associative manner by * using the '_features' array through the options parameter. * * Example usage: * * <?php * * ... * * $options = array ( * 'endpoint' => 'http://your.soap.service/endpoint', * 'namespace' => 'urn:/Your/Namespace', * 'method' => 'get', * 'encoding' => 'UTF-8', * 'usernamefield' => 'login', * 'passwordfield' => 'password', * '_features' => array ( * 'example_feature' => 'example_value', * 'another_example' => '' * ) * ); * $auth = new Auth('SOAP', $options, 'loginFunction'); * $auth->start(); * * ... * * ?> * * @author Bruno Pedro <bpedro@co.sapo.pt> * @package Auth * @version $Revision: 1.1 $ */ class Auth_Container_SOAP extends Auth_Container { /** * Required options for the class * @var array * @access private */ var $_requiredOptions = array('endpoint', 'namespace', 'method', 'encoding', 'usernamefield', 'passwordfield'); /** * Options for the class * @var array * @access private */ var $_options = array(); /** * Optional SOAP features * @var array * @access private */ var $_features = array(); /** * Constructor of the container class * * @param $options, associative array with endpoint, namespace, method, * usernamefield, passwordfield and optional features */ function Auth_Container_SOAP($options) { $this->_options = $options; if (!empty($this->_options['_features'])) { $this->_features = $this->_options['_features']; unset($this->_options['_features']); } } /** * Fetch data from SOAP service * * Requests the SOAP service for the given username/password * combination. * * @param string Username * @param string Password * @return mixed Returns the SOAP response or false if something went wrong */ function fetchData($username, $password) { // check if all required options are set if (array_intersect($this->_requiredOptions, array_keys($this->_options)) != $this->_requiredOptions) { return false; } else { // create a SOAP client and set encoding $soapClient = new SOAP_Client($this->_options['endpoint']); $soapClient->setEncoding($this->_options['encoding']); } // assign username and password fields $usernameField = new SOAP_Value($this->_options['usernamefield'],'string', $username); $passwordField = new SOAP_Value($this->_options['passwordfield'],'string', $password); $SOAPParams = array($usernameField, $passwordField); // assign optional features foreach ($this->_features as $fieldName => $fieldValue) { $SOAPParams[] = new SOAP_Value($fieldName, 'string', $fieldValue); } // make SOAP call $soapResponse = $soapClient->call($this->_options['method'], $SOAPParams, array('namespace' => $this->_options['namespace'])); if (!PEAR::isError($soapResponse)) { // check if passwords match if ($password == $soapResponse->{$this->_options['passwordfield']}) { return $soapResponse; } else { return false; } } else { return false; } } } ?>

« previous php.pear.cvs (#8747) next »