This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
forked from SAML-Toolkits/wordpress-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update php-saml to 3.1.0. Make the code compatible
- Loading branch information
Showing
29 changed files
with
3,853 additions
and
2,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2007-2013, Robert Richards <[email protected]>. | ||
Copyright (c) 2007-2018, Robert Richards <[email protected]>. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
|
@@ -28,4 +28,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#xmlseclibs | ||
|
||
xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. | ||
|
||
The author of xmlseclibs is Rob Richards. | ||
|
||
# Branches | ||
Both the master and the 2.0 branches are actively maintained. | ||
* master: Removes mcrypt usage requiring 5.4+ (5.6.24+ recommended for security reasons) | ||
* 2.0: Contains namespace support requiring 5.3+ | ||
* 1.4: Contains auto-loader support while also maintaining backwards compatiblity with the older 1.3 version using the xmlseclibs.php file. Supports PHP 5.2+ | ||
|
||
# Requirements | ||
|
||
xmlseclibs requires PHP version 5.4 or greater. **5.6.24+ recommended for security reasons** | ||
|
||
|
||
## How to Install | ||
|
||
Install with [`composer.phar`](http://getcomposer.org). | ||
|
||
```sh | ||
php composer.phar require "robrichards/xmlseclibs" | ||
``` | ||
|
||
|
||
## Use cases | ||
|
||
xmlseclibs is being used in many different software. | ||
|
||
* [SimpleSAMLPHP](https://github.com/simplesamlphp/simplesamlphp) | ||
* [LightSAML](https://github.com/lightsaml/lightsaml) | ||
* [OneLogin](https://github.com/onelogin/php-saml) | ||
|
||
## Basic usage | ||
|
||
The example below shows basic usage of xmlseclibs, with a SHA-256 signature. | ||
|
||
```php | ||
use RobRichards\XMLSecLibs\XMLSecurityDSig; | ||
use RobRichards\XMLSecLibs\XMLSecurityKey; | ||
|
||
// Load the XML to be signed | ||
$doc = new DOMDocument(); | ||
$doc->load('./path/to/file/tobesigned.xml'); | ||
|
||
// Create a new Security object | ||
$objDSig = new XMLSecurityDSig(); | ||
// Use the c14n exclusive canonicalization | ||
$objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); | ||
// Sign using SHA-256 | ||
$objDSig->addReference( | ||
$doc, | ||
XMLSecurityDSig::SHA256, | ||
array('http://www.w3.org/2000/09/xmldsig#enveloped-signature') | ||
); | ||
|
||
// Create a new (private) Security key | ||
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type'=>'private')); | ||
/* | ||
If key has a passphrase, set it using | ||
$objKey->passphrase = '<passphrase>'; | ||
*/ | ||
// Load the private key | ||
$objKey->loadKey('./path/to/privatekey.pem', TRUE); | ||
|
||
// Sign the XML file | ||
$objDSig->sign($objKey); | ||
|
||
// Add the associated public key to the signature | ||
$objDSig->add509Cert(file_get_contents('./path/to/file/mycert.pem')); | ||
|
||
// Append the signature to the XML | ||
$objDSig->appendSignature($doc->documentElement); | ||
// Save the signed XML | ||
$doc->save('./path/to/signed.xml'); | ||
``` | ||
|
||
## How to Contribute | ||
|
||
* [Open Issues](https://github.com/robrichards/xmlseclibs/issues) | ||
* [Open Pull Requests](https://github.com/robrichards/xmlseclibs/pulls) | ||
|
||
Mailing List: https://groups.google.com/forum/#!forum/xmlseclibs |
44 changes: 44 additions & 0 deletions
44
onelogin-saml-sso/php/extlib/xmlseclibs/src/Utils/XPath.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace RobRichards\XMLSecLibs\Utils; | ||
|
||
class XPath | ||
{ | ||
const ALPHANUMERIC = '\w\d'; | ||
const NUMERIC = '\d'; | ||
const LETTERS = '\w'; | ||
const EXTENDED_ALPHANUMERIC = '\w\d\s\-_:\.'; | ||
|
||
const SINGLE_QUOTE = '\''; | ||
const DOUBLE_QUOTE = '"'; | ||
const ALL_QUOTES = '[\'"]'; | ||
|
||
|
||
/** | ||
* Filter an attribute value for save inclusion in an XPath query. | ||
* | ||
* @param string $value The value to filter. | ||
* @param string $quotes The quotes used to delimit the value in the XPath query. | ||
* | ||
* @return string The filtered attribute value. | ||
*/ | ||
public static function filterAttrValue($value, $quotes = self::ALL_QUOTES) | ||
{ | ||
return preg_replace('#'.$quotes.'#', '', $value); | ||
} | ||
|
||
|
||
/** | ||
* Filter an attribute name for save inclusion in an XPath query. | ||
* | ||
* @param string $name The attribute name to filter. | ||
* @param mixed $allow The set of characters to allow. Can be one of the constants provided by this class, or a | ||
* custom regex excluding the '#' character (used as delimiter). | ||
* | ||
* @return string The filtered attribute name. | ||
*/ | ||
public static function filterAttrName($name, $allow = self::EXTENDED_ALPHANUMERIC) | ||
{ | ||
return preg_replace('#[^'.$allow.']#', '', $name); | ||
} | ||
} |
Oops, something went wrong.