diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-11-06 16:34:34 +0100 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-11-06 16:34:34 +0100 |
commit | af24da40fd3e4b9067a661952c28b3b5e4413940 (patch) | |
tree | e693b8622212fcac67e904528d72e116657b829e /lib/SimpleSAML/XML | |
parent | f25c7815af52a751cb815709ff33abee14e130a4 (diff) | |
download | simplesamlphp-af24da40fd3e4b9067a661952c28b3b5e4413940.zip simplesamlphp-af24da40fd3e4b9067a661952c28b3b5e4413940.tar.gz simplesamlphp-af24da40fd3e4b9067a661952c28b3b5e4413940.tar.bz2 |
Clean one-liner comments.
Diffstat (limited to 'lib/SimpleSAML/XML')
-rw-r--r-- | lib/SimpleSAML/XML/Errors.php | 14 | ||||
-rw-r--r-- | lib/SimpleSAML/XML/Parser.php | 2 | ||||
-rw-r--r-- | lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 18 | ||||
-rw-r--r-- | lib/SimpleSAML/XML/Signer.php | 8 | ||||
-rw-r--r-- | lib/SimpleSAML/XML/Validator.php | 52 |
5 files changed, 47 insertions, 47 deletions
diff --git a/lib/SimpleSAML/XML/Errors.php b/lib/SimpleSAML/XML/Errors.php index 0ef5529..c56d95b 100644 --- a/lib/SimpleSAML/XML/Errors.php +++ b/lib/SimpleSAML/XML/Errors.php @@ -44,13 +44,13 @@ class SimpleSAML_XML_Errors { */ public static function begin() { - /* Check whether the error access functions are present. */ + // Check whether the error access functions are present if(!function_exists('libxml_use_internal_errors')) { return; } if(count(self::$errorStack) === 0) { - /* No error logging is currently in progress. Initialize it. */ + // No error logging is currently in progress. Initialize it. self::$xmlErrorState = libxml_use_internal_errors(TRUE); libxml_clear_errors(); } else { @@ -60,7 +60,7 @@ class SimpleSAML_XML_Errors { self::addErrors(); } - /* Add a new level to the error stack. */ + // Add a new level to the error stack self::$errorStack[] = array(); } @@ -72,20 +72,20 @@ class SimpleSAML_XML_Errors { */ public static function end() { - /* Check whether the error access functions are present. */ + // Check whether the error access functions are present if(!function_exists('libxml_use_internal_errors')) { - /* Pretend that no errors occurred. */ + // Pretend that no errors occurred return array(); } - /* Add any errors which may have occurred. */ + // Add any errors which may have occurred self::addErrors(); $ret = array_pop(self::$errorStack); if(count(self::$errorStack) === 0) { - /* Disable our error logging and restore the previous state. */ + // Disable our error logging and restore the previous state libxml_use_internal_errors(self::$xmlErrorState); } diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index db1eb40..42b4731 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -20,7 +20,7 @@ class SimpleSAML_XML_Parser { public static function fromSimpleXMLElement(SimpleXMLElement $element) { - // Traverse all existing namespaces in element. + // Traverse all existing namespaces in element $namespaces = $element->getNamespaces(); foreach ($namespaces AS $prefix => $ns) { $element[(($prefix === '') ? 'xmlns' : 'xmlns:' . $prefix)] = $ns; diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index 4a4346e..6f6dd8a 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -75,17 +75,17 @@ class SimpleSAML_XML_Shib13_AuthnResponse { assert('$this->dom instanceof DOMDocument'); if ($this->messageValidated) { - /* This message was validated externally. */ + // This message was validated externally return TRUE; } - /* Validate the signature. */ + // Validate the signature $this->validator = new SimpleSAML_XML_Validator($this->dom, array('ResponseID', 'AssertionID')); - // Get the issuer of the response. + // Get the issuer of the response $issuer = $this->getIssuer(); - /* Get the metadata of the issuer. */ + // Get the metadata of the issuer $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $md = $metadata->getMetaDataConfig($issuer, 'shib13-idp-remote'); @@ -102,10 +102,10 @@ class SimpleSAML_XML_Shib13_AuthnResponse { } elseif ($md->hasValue('certFingerprint')) { $certFingerprints = $md->getArrayizeString('certFingerprint'); - /* Validate the fingerprint. */ + // Validate the fingerprint $this->validator->validateFingerprint($certFingerprints); } elseif ($md->hasValue('caFile')) { - /* Validate against CA. */ + // Validate against CA $this->validator->validateCA(\SimpleSAML\Utils\Config::getCertPath($md->getString('caFile'))); } else { throw new SimpleSAML_Error_Exception('Missing certificate in Shibboleth 1.3 IdP Remote metadata for identity provider [' . $issuer . '].'); @@ -123,7 +123,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse { private function isNodeValidated($node) { if ($this->messageValidated) { - /* This message was validated externally. */ + // This message was validated externally return TRUE; } @@ -131,7 +131,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse { return FALSE; } - /* Convert the node to a DOM node if it is an element from SimpleXML. */ + // Convert the node to a DOM node if it is an element from SimpleXML if($node instanceof SimpleXMLElement) { $node = dom_import_simplexml($node); } @@ -308,7 +308,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse { $issueInstant = SimpleSAML\Utils\Time::generateTimestamp(); - // 30 seconds timeskew back in time to allow differing clocks. + // 30 seconds timeskew back in time to allow differing clocks $notBefore = SimpleSAML\Utils\Time::generateTimestamp(time() - 30); diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php index 39cc09b..04f176c 100644 --- a/lib/SimpleSAML/XML/Signer.php +++ b/lib/SimpleSAML/XML/Signer.php @@ -146,11 +146,11 @@ class SimpleSAML_XML_Signer { assert('is_array($publickey)'); if (!array_key_exists('PEM', $publickey)) { - /* We have a public key with only a fingerprint. */ + // We have a public key with only a fingerprint throw new Exception('Tried to add a certificate fingerprint in a signature.'); } - /* For now, we only assume that the public key is an X509 certificate. */ + // For now, we only assume that the public key is an X509 certificate $this->certificate = $publickey['PEM']; } @@ -254,11 +254,11 @@ class SimpleSAML_XML_Signer { if($this->certificate !== FALSE) { - /* Add the certificate to the signature. */ + // Add the certificate to the signature $objXMLSecDSig->add509Cert($this->certificate, TRUE); } - /* Add extra certificates. */ + // Add extra certificates foreach($this->extraCertificates as $certificate) { $objXMLSecDSig->add509Cert($certificate, TRUE); } diff --git a/lib/SimpleSAML/XML/Validator.php b/lib/SimpleSAML/XML/Validator.php index 05261c2..5555786 100644 --- a/lib/SimpleSAML/XML/Validator.php +++ b/lib/SimpleSAML/XML/Validator.php @@ -50,10 +50,10 @@ class SimpleSAML_XML_Validator { assert('$publickey === FALSE || is_array($publickey)'); } - /* Create an XML security object. */ + // Create an XML security object $objXMLSecDSig = new XMLSecurityDSig(); - /* Add the id attribute if the user passed in an id attribute. */ + // Add the id attribute if the user passed in an id attribute if($idAttribute !== NULL) { if (is_string($idAttribute)) { $objXMLSecDSig->idKeys[] = $idAttribute; @@ -63,33 +63,33 @@ class SimpleSAML_XML_Validator { } } - /* Locate the XMLDSig Signature element to be used. */ + // Locate the XMLDSig Signature element to be used $signatureElement = $objXMLSecDSig->locateSignature($xmlNode); if (!$signatureElement) { throw new Exception('Could not locate XML Signature element.'); } - /* Canonicalize the XMLDSig SignedInfo element in the message. */ + // Canonicalize the XMLDSig SignedInfo element in the message $objXMLSecDSig->canonicalizeSignedInfo(); - /* Validate referenced xml nodes. */ + // Validate referenced xml nodes if (!$objXMLSecDSig->validateReference()) { throw new Exception('XMLsec: digest validation failed'); } - /* Find the key used to sign the document. */ + // Find the key used to sign the document $objKey = $objXMLSecDSig->locateKey(); if (empty($objKey)) { throw new Exception('Error loading key to handle XML signature'); } - /* Load the key data. */ + // Load the key data if ($publickey !== FALSE && array_key_exists('PEM', $publickey)) { - /* We have PEM data for the public key / certificate. */ + // We have PEM data for the public key / certificate $objKey->loadKey($publickey['PEM']); } else { - /* No PEM data. Search for key in signature. */ + // No PEM data. Search for key in signature if (!XMLSecEnc::staticLocateKeyInfo($objKey, $signatureElement)) { throw new Exception('Error finding key data for XML signature validation.'); @@ -104,25 +104,25 @@ class SimpleSAML_XML_Validator { $certificate = $objKey->getX509Certificate(); if ($certificate === NULL) { - /* Wasn't signed with an X509 certificate. */ + // Wasn't signed with an X509 certificate throw new Exception('Message wasn\'t signed with an X509 certificate,' . ' and no public key was provided in the metadata.'); } self::validateCertificateFingerprint($certificate, $publickey['certFingerprint']); - /* Key OK. */ + // Key OK } } - /* Check the signature. */ + // Check the signature if (! $objXMLSecDSig->verify($objKey)) { throw new Exception("Unable to validate Signature"); } - /* Extract the certificate. */ + // Extract the certificate $this->x509Certificate = $objKey->getX509Certificate(); - /* Find the list of validated nodes. */ + // Find the list of validated nodes $this->validNodes = $objXMLSecDSig->getValidatedNodes(); } @@ -156,19 +156,19 @@ class SimpleSAML_XML_Validator { $data = ''; foreach($lines as $line) { - /* Remove '\r' from end of line if present. */ + // Remove '\r' from end of line if present $line = rtrim($line); if($line === '-----BEGIN CERTIFICATE-----') { - /* Delete junk from before the certificate. */ + // Delete junk from before the certificate $data = ''; } elseif($line === '-----END CERTIFICATE-----') { - /* Ignore data after the certificate. */ + // Ignore data after the certificate break; } elseif($line === '-----BEGIN PUBLIC KEY-----') { - /* This isn't an X509 certificate. */ + // This isn't an X509 certificate return NULL; } else { - /* Append the current line to the certificate data. */ + // Append the current line to the certificate data $data .= $line; } } @@ -195,7 +195,7 @@ class SimpleSAML_XML_Validator { $certFingerprint = self::calculateX509Fingerprint($certificate); if ($certFingerprint === NULL) { - /* Couldn't calculate fingerprint from X509 certificate. Should not happen. */ + // Couldn't calculate fingerprint from X509 certificate. Should not happen. throw new Exception('Unable to calculate fingerprint from X509' . ' certificate. Maybe it isn\'t an X509 certificate?'); } @@ -204,13 +204,13 @@ class SimpleSAML_XML_Validator { assert('is_string($fp)'); if ($fp === $certFingerprint) { - /* The fingerprints matched. */ + // The fingerprints matched return; } } - /* None of the fingerprints matched. Throw an exception describing the error. */ + // None of the fingerprints matched. Throw an exception describing the error. throw new Exception('Invalid fingerprint of certificate. Expected one of [' . implode('], [', $fingerprints) . '], but got [' . $certFingerprint . ']'); } @@ -237,11 +237,11 @@ class SimpleSAML_XML_Validator { $fingerprints = array($fingerprints); } - /* Normalize the fingerprints. */ + // Normalize the fingerprints foreach($fingerprints as &$fp) { assert('is_string($fp)'); - /* Make sure that the fingerprint is in the correct format. */ + // Make sure that the fingerprint is in the correct format $fp = strtolower(str_replace(":", "", $fp)); } @@ -305,13 +305,13 @@ class SimpleSAML_XML_Validator { assert('is_string($certificate)'); assert('is_string($caFile)'); - /* Clear openssl errors. */ + // Clear openssl errors while(openssl_error_string() !== FALSE); $res = openssl_x509_checkpurpose($certificate, X509_PURPOSE_ANY, array($caFile)); $errors = ''; - /* Log errors. */ + // Log errors while( ($error = openssl_error_string()) !== FALSE) { $errors .= ' [' . $error . ']'; } |