import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -16,7 +16,7 @@
* @package Zend_InfoCard
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: InfoCard.php 11010 2008-08-24 19:22:58Z thomas $
* @version $Id: InfoCard.php 13522 2009-01-06 16:35:55Z thomas $
*/
/**
@ -29,11 +29,6 @@ require_once 'Zend/InfoCard/Xml/EncryptedData.php';
*/
require_once 'Zend/InfoCard/Xml/Assertion.php';
/**
* Zend_InfoCard_Exception
*/
require_once 'Zend/InfoCard/Exception.php';
/**
* Zend_InfoCard_Cipher
*/
@ -54,7 +49,6 @@ require_once 'Zend/InfoCard/Adapter/Interface.php';
*/
require_once 'Zend/InfoCard/Claims.php';
/**
* @category Zend
* @package Zend_InfoCard
@ -109,10 +103,12 @@ class Zend_InfoCard
$this->_keyPairs = array();
if(!extension_loaded('mcrypt')) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Use of the Zend_InfoCard component requires the mcrypt extension to be enabled in PHP");
}
if(!extension_loaded('openssl')) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Use of the Zend_InfoCard component requires the openssl extension to be enabled in PHP");
}
}
@ -138,7 +134,7 @@ class Zend_InfoCard
*/
public function getAdapter()
{
if(is_null($this->_adapter)) {
if($this->_adapter === null) {
require_once 'Zend/InfoCard/Adapter/Default.php';
$this->setAdapter(new Zend_InfoCard_Adapter_Default());
}
@ -201,6 +197,7 @@ class Zend_InfoCard
{
if(!key_exists($key_id, $this->_keyPairs)) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Attempted to remove unknown key id: $key_id");
}
@ -222,38 +219,42 @@ class Zend_InfoCard
{
if(!file_exists($private_key_file) ||
!file_exists($public_key_file)) {
throw new Zend_InfoCard_Exception("Could not locate the public and private certificate pair files: $private_key_file, $public_key_file");
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Could not locate the public and private certificate pair files: $private_key_file, $public_key_file");
}
if(!is_readable($private_key_file) ||
!is_readable($public_key_file)) {
throw new Zend_InfoCard_Exception("Could not read the public and private certificate pair files (check permissions): $private_key_file, $public_key_file");
}
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Could not read the public and private certificate pair files (check permissions): $private_key_file, $public_key_file");
}
$key_id = md5($private_key_file.$public_key_file);
$key_id = md5($private_key_file.$public_key_file);
if(key_exists($key_id, $this->_keyPairs)) {
throw new Zend_InfoCard_Exception("Attempted to add previously existing certificate pair: $private_key_file, $public_key_file");
}
if(key_exists($key_id, $this->_keyPairs)) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Attempted to add previously existing certificate pair: $private_key_file, $public_key_file");
}
switch($type) {
case Zend_InfoCard_Cipher::ENC_RSA:
case Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P:
$this->_keyPairs[$key_id] = array('private' => $private_key_file,
'public' => $public_key_file,
'type_uri' => $type);
switch($type) {
case Zend_InfoCard_Cipher::ENC_RSA:
case Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P:
$this->_keyPairs[$key_id] = array('private' => $private_key_file,
'public' => $public_key_file,
'type_uri' => $type);
if(!is_null($password)) {
if($password !== null) {
$this->_keyPairs[$key_id]['password'] = $password;
} else {
$this->_keyPairs[$key_id]['password'] = null;
}
return $key_id;
break;
default:
throw new Zend_InfoCard_Exception("Invalid Certificate Pair Type specified: $type");
}
break;
default:
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Invalid Certificate Pair Type specified: $type");
}
}
/**
@ -270,6 +271,7 @@ class Zend_InfoCard
return $this->_keyPairs[$key_id];
}
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Invalid Certificate Pair ID provided: $key_id");
}
@ -296,6 +298,7 @@ class Zend_InfoCard
$digest_retval = sha1($certificateData, true);
break;
default:
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Invalid Digest Type Provided: $digestMethod");
}
@ -342,6 +345,7 @@ class Zend_InfoCard
case Zend_InfoCard_Cipher::ENC_AES256CBC:
break;
default:
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Unknown Encryption Method used in the secure token");
}
@ -350,6 +354,7 @@ class Zend_InfoCard
$keyinfo = $encryptedData->getKeyInfo();
if(!($keyinfo instanceof Zend_InfoCard_Xml_KeyInfo_XmlDSig)) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Expected a XML digital signature KeyInfo, but was not found");
}
@ -361,6 +366,7 @@ class Zend_InfoCard
case Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P:
break;
default:
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Unknown Key Encryption Method used in secure token");
}
@ -369,6 +375,7 @@ class Zend_InfoCard
$key_id = $this->_findCertifiatePairByDigest($securityTokenRef->getKeyReference());
if(!$key_id) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Unable to find key pair used to encrypt symmetric InfoCard Key");
}
@ -377,6 +384,7 @@ class Zend_InfoCard
// Santity Check
if($certificate_pair['type_uri'] != $encryptedKey->getEncryptionMethod()) {
require_once 'Zend/InfoCard/Exception.php';
throw new Zend_InfoCard_Exception("Certificate Pair which matches digest is not of same algorithm type as document, check addCertificate()");
}
@ -421,6 +429,7 @@ class Zend_InfoCard
$retval = new Zend_InfoCard_Claims();
require_once 'Zend/InfoCard/Exception.php';
try {
$signedAssertionsXml = $this->_extractSignedToken($strXmlToken);
} catch(Zend_InfoCard_Exception $e) {