Revision: 2283
Author: olavmrk
Date: Fri May 7 02:13:28 2010
Log: SAML1.1: Use configuration class for metadata.
http://code.google.com/p/simplesamlphp/source/detail?r=2283
Modified:
/trunk/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
/trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
/trunk/modules/saml/lib/IdP/SAML1.php
=======================================
--- /trunk/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php Mon Aug 24 23:49:47
2009
+++ /trunk/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php Fri May 7 02:13:28
2010
@@ -21,17 +21,17 @@
* Send an authenticationResponse using HTTP-POST.
*
* @param string $response The response which should be sent.
- * @param array $idpmd The metadata of the IdP which is sending the
response.
- * @param array $spmd The metadata of the SP which is receiving the
response.
+ * @param SimpleSAML_Configuration $idpmd The metadata of the IdP which
is sending the response.
+ * @param SimpleSAML_Configuration $spmd The metadata of the SP which is
receiving the response.
* @param string|NULL $relayState The relaystate for the SP.
* @param string $shire The shire which should receive the response.
*/
- public function sendResponse($response, $idpmd, $spmd, $relayState,
$shire) {
+ public function sendResponse($response, SimpleSAML_Configuration $idpmd,
SimpleSAML_Configuration $spmd, $relayState, $shire) {
SimpleSAML_Utilities::validateXMLDocument($response, 'saml11');
- $privatekey = SimpleSAML_Utilities::loadPrivateKey($idpmd,
TRUE);
- $publickey = SimpleSAML_Utilities::loadPublicKey($idpmd, TRUE);
+ $privatekey = SimpleSAML_Utilities::loadPrivateKey($idpmd->toArray(),
TRUE);
+ $publickey = SimpleSAML_Utilities::loadPublicKey($idpmd->toArray(),
TRUE);
$responsedom = new DOMDocument();
$responsedom->loadXML(str_replace ("\r", "", $response));
@@ -44,12 +44,8 @@
* SP metadata or 'saml20.signresponse' in the global
configuration.
*/
$signResponse = FALSE;
- if (array_key_exists('signresponse', $spmd) && $spmd['signresponse'] !==
NULL) {
- $signResponse = $spmd['signresponse'];
- if(!is_bool($signResponse)) {
- throw new Exception('Expected the \'signresponse\' option in the
metadata of the' .
- ' SP \'' . $spmd['entityid'] . '\' to
be a boolean value.');
- }
+ if ($spmd->hasValue('signresponse')) {
+ $signResponse = $spmd->getBoolean['signresponse'];
} else {
$signResponse = $this->configuration->getBoolean('shib13.signresponse',
TRUE);
}
@@ -65,8 +61,8 @@
'id' => ($signResponse ? 'ResponseID' : 'AssertionID') ,
));
- if (array_key_exists('certificatechain', $idpmd)) {
- $signer->addCertificate($idpmd['certificatechain']);
+ if ($idpmd->hasValue('certificatechain')) {
+
$signer->addCertificate($idpmd->getString('certificatechain'));
}
if ($signResponse) {
=======================================
--- /trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php Fri Mar 26 03:14:37
2010
+++ /trunk/lib/SimpleSAML/XML/Shib13/AuthnResponse.php Fri May 7 02:13:28
2010
@@ -284,31 +284,17 @@
* @param array|NULL $attributes The attributes which should be included
in the response.
* @return string The response.
*/
- public function generate($idp, $sp, $shire, $attributes) {
- assert('is_array($idp)');
- assert('is_array($sp)');
+ public function generate(SimpleSAML_Configuration $idp,
SimpleSAML_Configuration $sp, $shire, $attributes) {
assert('is_string($shire)');
assert('$attributes === NULL || is_array($attributes)');
- if (array_key_exists('scopedattributes', $sp)) {
- $scopedAttributes = $sp['scopedattributes'];
- $scopedAttributesSource = 'the shib13-sp-remote sp \'' .
$sp['entityid'] . '\'';
- } elseif (array_key_exists('scopedattributes', $idp)) {
- $scopedAttributes = $idp['scopedattributes'];
- $scopedAttributesSource = 'the shib13-idp-hosted idp \'' .
$idp['entityid'] . '\'';
+ if ($sp->hasValue('scopedattributes')) {
+ $scopedAttributes = $sp->getArray('scopedattributes');
+ } elseif ($idp->hasValue('scopedattributes')) {
+ $scopedAttributes = $idp->getArray('scopedattributes');
} else {
$scopedAttributes = array();
}
- if (!is_array($scopedAttributes)) {
- throw new Exception('The \'scopedattributes\' option in ' .
$scopedAttributesSource .
- ' should be an array of attribute names.');
- }
- foreach ($scopedAttributes as $an) {
- if (!is_string($an)) {
- throw new Exception('Invalid attribute name in the
\'scopedattributes\' option in ' .
- $scopedAttributesSource . ': ' .
var_export($an, TRUE));
- }
- }
$id = SimpleSAML_Utilities::generateID();
@@ -321,10 +307,12 @@
$assertionExpire = SimpleSAML_Utilities::generateTimestamp(time() + 60 *
5);# 5 minutes
$assertionid = SimpleSAML_Utilities::generateID();
- $audience = isset($sp['audience']) ? $sp['audience'] :
$sp['entityid'];
- $base64 = isset($sp['base64attributes']) ? $sp['base64attributes'] :
false;
-
- $namequalifier = isset($sp['NameQualifier']) ? $sp['NameQualifier'] :
$sp['entityid'];
+ $spEntityId = $sp->getString('entityid');
+
+ $audience = $sp->getString('audience', $spEntityId);
+ $base64 = $sp->getBoolean('base64attributes', FALSE);
+
+ $namequalifier = $sp->getString('NameQualifier', $spEntityId);
$nameid = SimpleSAML_Utilities::generateID();
$subjectNode =
'<Subject>' .
@@ -369,7 +357,7 @@
</Status>
<Assertion xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
AssertionID="' . $assertionid . '" IssueInstant="' .
$issueInstant. '"
- Issuer="' . htmlspecialchars($idp['entityid']) . '"
MajorVersion="1" MinorVersion="1">
+ Issuer="' . htmlspecialchars($idp->getString('entityid')) . '"
MajorVersion="1" MinorVersion="1">
<Conditions NotBefore="' . $notBefore. '" NotOnOrAfter="'.
$assertionExpire . '">
<AudienceRestrictionCondition>
<Audience>' . htmlspecialchars($audience) . '</Audience>
=======================================
--- /trunk/modules/saml/lib/IdP/SAML1.php Tue Jan 5 02:19:19 2010
+++ /trunk/modules/saml/lib/IdP/SAML1.php Fri May 7 02:13:28 2010
@@ -21,6 +21,8 @@
$spMetadata = $state["SPMetadata"];
$spEntityId = $spMetadata['entityid'];
+ $spMetadata =
SimpleSAML_Configuration::loadFromArray($spMetadata,
+ '$metadata[' . var_export($spEntityId, TRUE) . ']');
SimpleSAML_Logger::info('Sending SAML 1.1 Response to ' .
var_export($spEntityId, TRUE));
@@ -30,7 +32,7 @@
$idp = SimpleSAML_IdP::getByState($state);
- $idpMetadata = $idp->getConfig()->toArray();
+ $idpMetadata = $idp->getConfig();
$config = SimpleSAML_Configuration::getInstance();
$metadata =
SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
--
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en.