Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[zen-27] Renamed interfaces in Zend\OpenId

  • Loading branch information...
commit f4f906dd2b49bad04597cadd8dd63b6e9c314424 1 parent 8da0112
prolic authored
18 library/Zend/OpenId/Consumer/Storage/File.php
View
@@ -46,7 +46,7 @@ class File extends AbstractStorage
* Constructs storage object and creates storage directory
*
* @param string $dir directory name to store data files in
- * @throws Zend\OpenId\Exception
+ * @throws OpenId\Exception\RuntimeException
*/
public function __construct($dir = null)
{
@@ -67,27 +67,27 @@ public function __construct($dir = null)
$this->_dir = $dir;
if (!is_dir($this->_dir)) {
if (!@mkdir($this->_dir, 0700, 1)) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot access storage directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
}
if (($f = fopen($this->_dir.'/assoc.lock', 'w+')) === null) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot create a lock file in the directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir.'/discovery.lock', 'w+')) === null) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot create a lock file in the directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir.'/nonce.lock', 'w+')) === null) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot create a lock file in the directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
fclose($f);
}
6 library/Zend/OpenId/Exception.php → library/Zend/OpenId/Exception/ExceptionInterface.php
View
@@ -19,17 +19,15 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\OpenId;
+namespace Zend\OpenId\Exception;
/**
- * Exception class for Zend\OpenId
- *
* @category Zend
* @package Zend_OpenId
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Exception extends \Exception
+interface ExceptionInterface
{
/**
8 library/Zend/OpenId/Exception/InvalidArgumentException.php
View
@@ -0,0 +1,8 @@
+<?php
+
+namespace Zend\OpenId\Exception;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements ExceptionInterface
+{}
8 library/Zend/OpenId/Exception/RuntimeException.php
View
@@ -0,0 +1,8 @@
+<?php
+
+namespace Zend\OpenId\Exception;
+
+class RuntimeException
+ extends \RuntimeException
+ implements ExceptionInterface
+{}
22 library/Zend/OpenId/OpenId.php
View
@@ -493,7 +493,7 @@ static public function randomBytes($len)
* @param string $func digest algorithm
* @param string $data data to sign
* @return string RAW digital signature
- * @throws Zend\OpenId\Exception
+ * @throws Exception\InvalidArgumentException
*/
static public function digest($func, $data)
{
@@ -508,9 +508,9 @@ static public function digest($func, $data)
return mhash(MHASH_SHA256 , $data);
}
}
- throw new Exception(
+ throw new Exception\InvalidArgumentException(
'Unsupported digest algorithm "' . $func . '".',
- Exception::UNSUPPORTED_DIGEST);
+ Exception\InvalidArgumentException::UNSUPPORTED_DIGEST);
}
/**
@@ -546,7 +546,7 @@ static public function hashHmac($macFunc, $data, $secret)
*
* @param string $bin binary representation of big number
* @return mixed
- * @throws Zend\OpenId\Exception
+ * @throws Exception\RuntimeException
*/
static protected function binToBigNum($bin)
{
@@ -561,7 +561,7 @@ static protected function binToBigNum($bin)
}
return $bn;
}
- throw new Exception(
+ throw new Exception\RuntimeException(
'The system doesn\'t have proper big integer extension',
Exception::UNSUPPORTED_LONG_MATH);
}
@@ -572,7 +572,7 @@ static protected function binToBigNum($bin)
*
* @param mixed $bn big number
* @return string
- * @throws Zend\OpenId\Exception
+ * @throws Exception\RuntimeException
*/
static protected function bigNumToBin($bn)
{
@@ -603,9 +603,9 @@ static protected function bigNumToBin($bn)
}
return $bin;
}
- throw new Exception(
+ throw new Exception\RuntimeException(
'The system doesn\'t have proper big integer extension',
- Exception::UNSUPPORTED_LONG_MATH);
+ Exception\RuntimeException::UNSUPPORTED_LONG_MATH);
}
/**
@@ -686,7 +686,7 @@ static public function getDhKeyDetails($dh)
* @param string $pub_key other party's public value
* @param mixed $dh Diffie-Hellman key
* @return string
- * @throws Zend\OpenId\Exception
+ * @throws Exception\RuntimeException
*/
static public function computeDhSecret($pub_key, $dh)
{
@@ -705,9 +705,9 @@ static public function computeDhSecret($pub_key, $dh)
$bn_secret = bcpowmod($bn_pub_key, $dh['priv_key'], $dh['p']);
return self::bigNumToBin($bn_secret);
}
- throw new Exception(
+ throw new Exception\RuntimeException(
'The system doesn\'t have proper big integer extension',
- Exception::UNSUPPORTED_LONG_MATH);
+ Exception\RuntimeException::UNSUPPORTED_LONG_MATH);
}
/**
14 library/Zend/OpenId/Provider/Storage/File.php
View
@@ -46,7 +46,7 @@ class File extends AbstractStorage
* Constructs storage object and creates storage directory
*
* @param string $dir directory name to store data files in
- * @throws Zend\OpenId\Exception
+ * @throws OpenId\Exception\RuntimeException
*/
public function __construct($dir = null)
{
@@ -67,21 +67,21 @@ public function __construct($dir = null)
$this->_dir = $dir;
if (!is_dir($this->_dir)) {
if (!@mkdir($this->_dir, 0700, 1)) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
"Cannot access storage directory $dir",
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
}
if (($f = fopen($this->_dir.'/assoc.lock', 'w+')) === null) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot create a lock file in the directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
fclose($f);
if (($f = fopen($this->_dir.'/user.lock', 'w+')) === null) {
- throw new OpenId\Exception(
+ throw new OpenId\Exception\RuntimeException(
'Cannot create a lock file in the directory ' . $dir,
- OpenId\Exception::ERROR_STORAGE);
+ OpenId\Exception\RuntimeException::ERROR_STORAGE);
}
fclose($f);
}
4 tests/Zend/OpenId/Consumer/Storage/FileTest.php
View
@@ -119,8 +119,8 @@ public function testConstruct()
} catch (\Exception $e) {
$ex = $e;
}
- $this->assertTrue( $ex instanceof \Zend\OpenId\Exception );
- $this->assertSame( \Zend\OpenId\Exception::ERROR_STORAGE, $ex->getCode() );
+ $this->assertTrue( $ex instanceof \Zend\OpenId\Exception\ExceptionInterface );
+ $this->assertSame( \Zend\OpenId\Exception\ExceptionInterface::ERROR_STORAGE, $ex->getCode() );
$this->assertContains( 'Cannot access storage directory', $ex->getMessage() );
chmod($dir, 0777);
$this->assertFalse( is_dir($dir2) );
2  tests/Zend/OpenId/ConsumerTest.php
View
@@ -537,7 +537,7 @@ public function testAssociate()
$this->assertSame( "sha256", $macFunc );
$this->assertSame( "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8", bin2hex($secret) );
$this->assertTrue( $storage->delAssociation(self::SERVER) );
- } catch (\Zend\OpenId\Exception $e) {
+ } catch (\Zend\OpenId\Exception\ExceptionInterface $e) {
$this->markTestSkipped($e->getMessage());
}
}
4 tests/Zend/OpenId/OpenIdTest.php
View
@@ -602,7 +602,7 @@ public function testCreateDhKey()
$this->assertTrue( strlen($dh_details['priv_key']) > 0 );
$this->assertTrue( is_string($dh_details['pub_key']) );
$this->assertTrue( strlen($dh_details['pub_key']) > 0 );
- } catch (\Zend\OpenId\Exception $e) {
+ } catch (\Zend\OpenId\Exception\ExceptionInterface $e) {
$this->markTestSkipped($e->getMessage());
}
}
@@ -632,7 +632,7 @@ public function testComputeDhSecret()
bin2hex(OpenId::computeDhSecret($alice_details['pub_key'], $bob)) );
$this->assertSame( '75',
bin2hex(OpenId::computeDhSecret($bob_details['pub_key'], $alice)) );
- } catch (\Zend\OpenId\Exception $e) {
+ } catch (\Zend\OpenId\Exception\ExceptionInterface $e) {
$this->markTestSkipped($e->getMessage());
}
}
4 tests/Zend/OpenId/Provider/Storage/FileTest.php
View
@@ -71,8 +71,8 @@ public function testConstruct()
} catch (\Exception $e) {
$ex = $e;
}
- $this->assertTrue( $ex instanceof \Zend\OpenId\Exception );
- $this->assertSame( \Zend\OpenId\Exception::ERROR_STORAGE, $ex->getCode() );
+ $this->assertTrue( $ex instanceof \Zend\OpenId\Exception\ExceptionInterface );
+ $this->assertSame( \Zend\OpenId\Exception\ExceptionInterface::ERROR_STORAGE, $ex->getCode() );
$this->assertContains( 'Cannot access storage directory', $ex->getMessage() );
chmod($dir, 0777);
$this->assertFalse( is_dir($dir2) );
2  tests/Zend/OpenId/ProviderTest.php
View
@@ -623,7 +623,7 @@ public function testAssociate()
$this->assertSame( '3600', $res['expires_in'] );
$this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) );
$this->assertSame( 'sha256', $macFunc );
- } catch (\Zend\OpenId\Exception $e) {
+ } catch (\Zend\OpenId\Exception\ExceptionInterface $e) {
$this->markTestSkipped($e->getMessage());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.