Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change scoping from private to protected #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions xmlseclibs.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class XMLSecurityKey {
const RSA_SHA512 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512';
const HMAC_SHA1 = 'http://www.w3.org/2000/09/xmldsig#hmac-sha1';

private $cryptParams = array();
protected $cryptParams = array();
public $type = 0;
public $key = NULL;
public $passphrase = "";
Expand All @@ -199,10 +199,10 @@ class XMLSecurityKey {
* This variable contains the certificate as a string if this key represents an X509-certificate.
* If this key doesn't represent a certificate, this will be NULL.
*/
private $x509Certificate = NULL;
protected $x509Certificate = NULL;

/* This variable contains the certificate thunbprint if we have loaded an X509-certificate. */
private $X509Thumbprint = NULL;
protected $X509Thumbprint = NULL;

public function __construct($type, $params=NULL) {
srand();
Expand Down Expand Up @@ -434,7 +434,7 @@ public function loadKey($key, $isFile=FALSE, $isCert = FALSE) {
}
}

private function encryptMcrypt($data) {
protected function encryptMcrypt($data) {
$td = mcrypt_module_open($this->cryptParams['cipher'], '', $this->cryptParams['mode'], '');
$this->iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $this->key, $this->iv);
Expand All @@ -450,7 +450,7 @@ private function encryptMcrypt($data) {
return $encrypted_data;
}

private function decryptMcrypt($data) {
protected function decryptMcrypt($data) {
$td = mcrypt_module_open($this->cryptParams['cipher'], '', $this->cryptParams['mode'], '');
$iv_length = mcrypt_enc_get_iv_size($td);

Expand All @@ -469,7 +469,7 @@ private function decryptMcrypt($data) {
return $decrypted_data;
}

private function encryptOpenSSL($data) {
protected function encryptOpenSSL($data) {
if ($this->cryptParams['type'] == 'public') {
if (! openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) {
throw new Exception('Failure encrypting Data');
Expand All @@ -484,7 +484,7 @@ private function encryptOpenSSL($data) {
return $encrypted_data;
}

private function decryptOpenSSL($data) {
protected function decryptOpenSSL($data) {
if ($this->cryptParams['type'] == 'public') {
if (! openssl_public_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) {
throw new Exception('Failure decrypting Data');
Expand All @@ -499,7 +499,7 @@ private function decryptOpenSSL($data) {
return $decrypted;
}

private function signOpenSSL($data) {
protected function signOpenSSL($data) {
$algo = OPENSSL_ALGO_SHA1;
if (! empty($this->cryptParams['digest'])) {
$algo = $this->cryptParams['digest'];
Expand All @@ -511,7 +511,7 @@ private function signOpenSSL($data) {
return $signature;
}

private function verifyOpenSSL($data, $signature) {
protected function verifyOpenSSL($data, $signature) {
$algo = OPENSSL_ALGO_SHA1;
if (! empty($this->cryptParams['digest'])) {
$algo = $this->cryptParams['digest'];
Expand Down Expand Up @@ -686,26 +686,26 @@ class XMLSecurityDSig {
public $sigNode = NULL;
public $idKeys = array();
public $idNS = array();
private $signedInfo = NULL;
private $xPathCtx = NULL;
private $canonicalMethod = NULL;
private $prefix = 'ds';
private $searchpfx = 'secdsig';
protected $signedInfo = NULL;
protected $xPathCtx = NULL;
protected $canonicalMethod = NULL;
protected $prefix = 'ds';
protected $searchpfx = 'secdsig';

/* This variable contains an associative array of validated nodes. */
private $validatedNodes = NULL;
protected $validatedNodes = NULL;

public function __construct() {
$sigdoc = new DOMDocument();
$sigdoc->loadXML(XMLSecurityDSig::template);
$this->sigNode = $sigdoc->documentElement;
}

private function resetXPathObj() {
protected function resetXPathObj() {
$this->xPathCtx = NULL;
}
private function getXPathObj() {

protected function getXPathObj() {
if (empty($this->xPathCtx) && ! empty($this->sigNode)) {
$xpath = new DOMXPath($this->sigNode->ownerDocument);
$xpath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS);
Expand Down Expand Up @@ -777,7 +777,7 @@ public function setCanonicalMethod($method) {
}
}

private function canonicalizeData($node, $canonicalmethod, $arXPath=NULL, $prefixList=NULL) {
protected function canonicalizeData($node, $canonicalmethod, $arXPath=NULL, $prefixList=NULL) {
$exclusive = FALSE;
$withComments = FALSE;
switch ($canonicalmethod) {
Expand Down Expand Up @@ -1086,7 +1086,7 @@ public function validateReference() {
return TRUE;
}

private function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms=NULL, $options=NULL) {
protected function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms=NULL, $options=NULL) {
$prefix = NULL;
$prefix_ns = NULL;
$id_name = 'Id';
Expand Down Expand Up @@ -1512,17 +1512,17 @@ class XMLSecEnc {
const URI = 3;
const XMLENCNS = 'http://www.w3.org/2001/04/xmlenc#';

private $encdoc = NULL;
private $rawNode = NULL;
protected $encdoc = NULL;
protected $rawNode = NULL;
public $type = NULL;
public $encKey = NULL;
private $references = array();
protected $references = array();

public function __construct() {
$this->_resetTemplate();
}

private function _resetTemplate(){
protected function _resetTemplate(){
$this->encdoc = new DOMDocument();
$this->encdoc->loadXML(XMLSecEnc::template);
}
Expand Down