--- /dev/null
+/package.xml/1.3/Tue Jul 29 05:00:09 2008//
+D/lib////
--- /dev/null
+framework/Oauth
--- /dev/null
+chuck@cvs.horde.org:/repository
--- /dev/null
+
+Bug:
+Submitted by:
+Merge after:
+CVS: ----------------------------------------------------------------------
+CVS: Bug: Fill this in if a listed bug is affected by the change.
+CVS: Submitted by: Fill this in if someone else sent in the change.
+CVS: Merge after: N [day[s]|week[s]|month[s]] (days assumed by default)
--- /dev/null
+D/Horde////
--- /dev/null
+framework/Oauth/lib
--- /dev/null
+chuck@cvs.horde.org:/repository
--- /dev/null
+
+Bug:
+Submitted by:
+Merge after:
+CVS: ----------------------------------------------------------------------
+CVS: Bug: Fill this in if a listed bug is affected by the change.
+CVS: Submitted by: Fill this in if someone else sent in the change.
+CVS: Merge after: N [day[s]|week[s]|month[s]] (days assumed by default)
--- /dev/null
+D/Oauth////
--- /dev/null
+framework/Oauth/lib/Horde
--- /dev/null
+chuck@cvs.horde.org:/repository
--- /dev/null
+
+Bug:
+Submitted by:
+Merge after:
+CVS: ----------------------------------------------------------------------
+CVS: Bug: Fill this in if a listed bug is affected by the change.
+CVS: Submitted by: Fill this in if someone else sent in the change.
+CVS: Merge after: N [day[s]|week[s]|month[s]] (days assumed by default)
--- /dev/null
+/Consumer.php/1.1/Tue Jul 29 03:25:15 2008//
+/Exception.php/1.1/Tue Jul 29 03:25:15 2008//
+/Request.php/1.1/Tue Jul 29 03:25:15 2008//
+/Token.php/1.1/Tue Jul 29 03:25:15 2008//
+/Utils.php/1.1/Tue Jul 29 03:25:15 2008//
+D/SignatureMethod////
--- /dev/null
+framework/Oauth/lib/Horde/Oauth
--- /dev/null
+chuck@cvs.horde.org:/repository
--- /dev/null
+
+Bug:
+Submitted by:
+Merge after:
+CVS: ----------------------------------------------------------------------
+CVS: Bug: Fill this in if a listed bug is affected by the change.
+CVS: Submitted by: Fill this in if someone else sent in the change.
+CVS: Merge after: N [day[s]|week[s]|month[s]] (days assumed by default)
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth consumer class
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_Consumer
+{
+ protected $_config;
+
+ public function __construct($config)
+ {
+ $this->_config = $config;
+ }
+
+ public function __get($name)
+ {
+ return isset($this->_config[$name]) ? $this->_config[$name] : null;
+ }
+
+ public function getRequestToken($params = array())
+ {
+ $params['oauth_consumer_key'] = $this->key;
+
+ $request = new Horde_Oauth_Request($this->requestTokenUrl, $params);
+ $request->sign($this->signatureMethod, $this);
+
+ $client = new Horde_Http_Client;
+ $response = $client->post(
+ $this->requestTokenUrl,
+ $request->buildHttpQuery()
+ );
+ return Horde_Oauth_Token::fromString($response->getBody());
+ }
+
+ public function getUserAuthorizationUrl($token)
+ {
+ return $this->authorizeTokenUrl . '?oauth_token=' . urlencode($token->key) . '&oauth_callback=' . urlencode($this->callbackUrl);
+ }
+
+ public function getAccessToken($token, $params = array())
+ {
+ $params['oauth_consumer_key'] = $this->key;
+ $params['oauth_token'] = $token->key;
+
+ $request = new Horde_Oauth_Request($this->accessTokenUrl, $params);
+ $request->sign($this->signatureMethod, $this, $token);
+
+ $client = new Horde_Http_Client;
+ $response = $client->post(
+ $this->accessTokenUrl,
+ $request->buildHttpQuery()
+ );
+ return Horde_Oauth_Token::fromString($response->getBody());
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth exception class
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_Exception extends Exception
+{
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth request class
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_Request
+{
+ const VERSION = '1.0';
+
+ protected $_params = array();
+ protected $_url;
+
+ function __construct($url, $params = array())
+ {
+ if (!isset($params['oauth_version'])) {
+ $params['oauth_version'] = self::VERSION;
+ }
+ if (!isset($params['oauth_nonce'])) {
+ $params['oauth_nonce'] = self::_generateNonce();
+ }
+ if (!isset($params['oauth_timestamp'])) {
+ $params['oauth_timestamp'] = time();
+ }
+
+ $this->_params = $params;
+ $this->_url = $url;
+ }
+
+ public function sign($signatureMethod, $consumer, $token = null)
+ {
+ $this->_params['oauth_signature_method'] = $signatureMethod->getName();
+ $this->_params['oauth_signature'] = $signatureMethod->sign($this, $consumer, $token);
+
+ return $this->_url . '?' . $this->buildHttpQuery();
+ }
+
+ /**
+ * Returns the signable string of this request
+ *
+ * The base string is defined as the method, the url and the parameters
+ * (normalized), each urlencoded and concatenated with &.
+ */
+ public function getSignatureBaseString()
+ {
+ $parts = array(
+ 'POST',
+ $this->_url,
+ $this->_getSignableParameters()
+ );
+
+ return implode('&', array_map(array('Horde_Oauth_Utils', 'urlencodeRfc3986'), $parts));
+ }
+
+ /**
+ * Get a query string suitable for use in a URL or as POST data.
+ */
+ public function buildHttpQuery()
+ {
+ $parts = array();
+ foreach ($this->_params as $k => $v) {
+ $parts[] = Horde_Oauth_Utils::urlencodeRfc3986($k) . '=' . Horde_Oauth_Utils::urlencodeRfc3986($v);
+ }
+ return implode('&', $parts);
+ }
+
+ /**
+ * Generate a nonce.
+ */
+ protected static function _generateNonce()
+ {
+ $mt = microtime();
+ $rand = mt_rand();
+
+ return md5(microtime() . mt_rand());
+ }
+
+ /**
+ * Returns the normalized parameters of the request
+ *
+ * This will be all parameters except oauth_signature, sorted first by key,
+ * and if there are duplicate keys, then by value.
+ *
+ * The returned string will be all the key=value pairs concatenated by &.
+ *
+ * @return string
+ */
+ protected function _getSignableParameters()
+ {
+ // Grab all parameters
+ $params = $this->_params;
+
+ // Remove oauth_signature if present
+ if (isset($params['oauth_signature'])) {
+ unset($params['oauth_signature']);
+ }
+
+ // Urlencode both keys and values
+ $keys = array_map(array('Horde_Oauth_Utils', 'urlencodeRfc3986'), array_keys($params));
+ $values = array_map(array('Horde_Oauth_Utils', 'urlencodeRfc3986'), array_values($params));
+ $params = array_combine($keys, $values);
+
+ // Sort by keys (natsort)
+ uksort($params, 'strnatcmp');
+
+ // Generate key=value pairs
+ $pairs = array();
+ foreach ($params as $key => $value) {
+ if (is_array($value)) {
+ // If the value is an array, it's because there are multiple values
+ // with the same key. Sort them, then add all the pairs.
+ natsort($value);
+ foreach ($value as $v2) {
+ $pairs[] = $key . '=' . $v2;
+ }
+ } else {
+ $pairs[] = $key . '=' . $value;
+ }
+ }
+
+ // Return the pairs, concatenated with &
+ return implode('&', $pairs);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth abstract signature method base class
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+abstract class Horde_Oauth_SignatureMethod_Base
+{
+ abstract public function getName();
+
+ abstract public function sign($request, $consumer, $token);
+
+ public function verify($signature, $request, $consumer, $token)
+ {
+ return $signature == $this->sign($request, $consumer, $token);
+ }
+
+}
--- /dev/null
+/Base.php/1.1/Tue Jul 29 03:25:16 2008//
+/HmacSha1.php/1.1/Tue Jul 29 03:25:16 2008//
+/Plaintext.php/1.1/Tue Jul 29 03:25:16 2008//
+/RsaSha1.php/1.1/Tue Jul 29 03:25:16 2008//
+D
--- /dev/null
+framework/Oauth/lib/Horde/Oauth/SignatureMethod
--- /dev/null
+chuck@cvs.horde.org:/repository
--- /dev/null
+
+Bug:
+Submitted by:
+Merge after:
+CVS: ----------------------------------------------------------------------
+CVS: Bug: Fill this in if a listed bug is affected by the change.
+CVS: Submitted by: Fill this in if someone else sent in the change.
+CVS: Merge after: N [day[s]|week[s]|month[s]] (days assumed by default)
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth HMAC-SHA1 signature method
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_SignatureMethod_HmacSha1 extends Horde_Oauth_SignatureMethod_Base
+{
+ public function getName()
+ {
+ return 'HMAC-SHA1';
+ }
+
+ public function sign($request, $consumer, $token)
+ {
+ $baseString = $request->getSignatureBaseString();
+
+ $key_parts = array(
+ $consumer->secret,
+ ($token) ? $token->secret : ''
+ );
+
+ $key_parts = array_map(array('Horde_Oauth_Utils','urlencodeRfc3986'), $key_parts);
+ $key = implode('&', $key_parts);
+
+ return base64_encode(hash_hmac('sha1', $baseString, $key, true));
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth plaintext signature method
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_SignatureMethod_Plaintext extends Horde_Oauth_SignatureMethod_Base
+{
+ public function getName()
+ {
+ return 'PLAINTEXT';
+ }
+
+ public function sign($request, $consumer, $token)
+ {
+ $signature = array(
+ Horde_Oauth_Utils::urlencodeRfc3986($consumer->secret),
+ );
+
+ if ($token) {
+ array_push($signature, Horde_Oauth_Utils::urlencodeRfc3986($token->secret));
+ } else {
+ array_push($signature, '');
+ }
+
+ return Horde_Oauth_Utils::urlencodeRfc3986(implode('&', $signature));
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth RSA-SHA1 signature method
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_SignatureMethod_RsaSha1 extends Horde_Oauth_SignatureMethod_Base
+{
+ public function __construct($publicKey = null, $privateKey = null)
+ {
+ $this->_publicKey = $publicKey;
+ $this->_privateKey = $privateKey;
+ }
+
+ public function getName()
+ {
+ return 'RSA-SHA1';
+ }
+
+ public function sign($request, $consumer, $token)
+ {
+ $baseString = $request->getSignatureBaseString();
+
+ $pkeyid = openssl_pkey_get_private($this->_privateKey);
+ $ok = openssl_sign($baseString, $signature, $pkeyid);
+ openssl_free_key($pkeyid);
+
+ return base64_encode($signature);
+ }
+
+ public function verify($signature, $request, $consumer, $token)
+ {
+ $decodedSignature = base64_decode($signature);
+ $baseString = $request->getSignatureBaseString();
+
+ $pubkeyid = openssl_pkey_get_public($this->_publicKey);
+ $result = openssl_verify($baseString, $decodedSignature, $pubkeyid);
+ openssl_free_key($pubkeyid);
+
+ return $result == 1;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth access tokens and request tokens
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_Token
+{
+ public $key;
+ public $secret;
+
+ /**
+ * key = the token
+ * secret = the token secret
+ */
+ function __construct($key, $secret)
+ {
+ $this->key = $key;
+ $this->secret = $secret;
+ }
+
+ /**
+ * Generate the basic string serialization of a token that a server would
+ * respond to request_token and access_token calls with.
+ */
+ public function __toString()
+ {
+ return
+ 'oauth_token='.Horde_Oauth_Utils::urlencodeRfc3986($this->key).
+ '&oauth_token_secret='.Horde_Oauth_Utils::urlencodeRfc3986($this->secret);
+ }
+
+ public static function fromString($string)
+ {
+ parse_str($string, $parts);
+ return new self($parts['oauth_token'], $parts['oauth_token_secret']);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Copyright 2008 The Horde Project (http://www.horde.org/)
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+
+/**
+ * OAuth utilities
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Oauth
+ */
+class Horde_Oauth_Utils
+{
+ public static function urlencodeRfc3986($string)
+ {
+ return str_replace(array('%7E', '+'),
+ array('~', '%20'),
+ rawurlencode($string));
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+http://pear.php.net/dtd/tasks-1.0.xsd
+http://pear.php.net/dtd/package-2.0
+http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Oauth</name>
+ <channel>pear.horde.org</channel>
+ <summary>Horde OAuth client/server</summary>
+ <description>This package provides an OAuth consumer (http://oauth.net) and OAuth infrastruture, and in the future will provide an OAuth server.
+ </description>
+ <lead>
+ <name>Chuck Hagenbuch</name>
+ <user>chuck</user>
+ <email>chuck@horde.org</email>
+ <active>yes</active>
+ </lead>
+ <date>2008-07-28</date>
+ <version>
+ <release>0.1.0</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <license uri="http://opensource.org/licenses/bsd-license.php">BSD</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+ <dir name="/">
+ <dir name="lib">
+ <dir name="Horde">
+ <dir name="Oauth">
+ <dir name="SignatureMethod">
+ <file name="Base.php" role="php" />
+ <file name="HmacSha1.php" role="php" />
+ <file name="Plaintext.php" role="php" />
+ <file name="RsaSha1.php" role="php" />
+ </dir> <!-- /lib/Horde/Oauth/SignatureMethod -->
+ <file name="Consumer.php" role="php" />
+ <file name="Exception.php" role="php" />
+ <file name="Request.php" role="php" />
+ <file name="Token.php" role="php" />
+ <file name="Utils.php" role="php" />
+ </dir> <!-- /lib/Horde/Oauth -->
+ </dir> <!-- /lib/Horde -->
+ </dir> <!-- /lib -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.5.0</min>
+ </pearinstaller>
+ <package>
+ <name>Http_Client</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install name="lib/Horde/Oauth/Consumer.php" as="Horde/Oauth/Consumer.php" />
+ <install name="lib/Horde/Oauth/Exception.php" as="Horde/Oauth/Exception.php" />
+ <install name="lib/Horde/Oauth/Request.php" as="Horde/Oauth/Request.php" />
+ <install name="lib/Horde/Oauth/SignatureMethod/Base.php" as="Horde/Oauth/SignatureMethod/Base.php" />
+ <install name="lib/Horde/Oauth/SignatureMethod/HmacSha1.php" as="Horde/Oauth/SignatureMethod/HmacSha1.php" />
+ <install name="lib/Horde/Oauth/SignatureMethod/Plaintext.php" as="Horde/Oauth/SignatureMethod/Plaintext.php" />
+ <install name="lib/Horde/Oauth/SignatureMethod/RsaSha1.php" as="Horde/Oauth/SignatureMethod/RsaSha1.php" />
+ <install name="lib/Horde/Oauth/Token.php" as="Horde/Oauth/Token.php" />
+ <install name="lib/Horde/Oauth/Utils.php" as="Horde/Oauth/Utils.php" />
+ </filelist>
+ </phprelease>
+</package>