Skip to content
Snippets Groups Projects
Commit 3707ceab authored by Olav Morken's avatar Olav Morken
Browse files

saml:IdP: Extract extensions from authentication request.

Thanks to Andjelko Horvat for implementing this!

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2701 44740490-163a-0410-bde0-09ae8108e29a
parent 73cf5412
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,12 @@ class SAML2_AuthnRequest extends SAML2_Request { ...@@ -79,6 +79,12 @@ class SAML2_AuthnRequest extends SAML2_Request {
*/ */
private $requestedAuthnContext; private $requestedAuthnContext;
/**
* Request extensions.
*
* @var array
*/
private $extensions;
/** /**
* Constructor for SAML 2 authentication request messages. * Constructor for SAML 2 authentication request messages.
...@@ -165,6 +171,8 @@ class SAML2_AuthnRequest extends SAML2_Request { ...@@ -165,6 +171,8 @@ class SAML2_AuthnRequest extends SAML2_Request {
} }
} }
$this->extensions = SAML2_XML_samlp_Extensions::getList($xml);
} }
...@@ -346,6 +354,28 @@ class SAML2_AuthnRequest extends SAML2_Request { ...@@ -346,6 +354,28 @@ class SAML2_AuthnRequest extends SAML2_Request {
} }
/**
* Retrieve the Extensions.
*
* @return SAML2_XML_samlp_Extensions.
*/
public function getExtensions() {
return $this->extensions;
}
/**
* Set the Extensions.
*
* @param array|NULL $extensions The Extensions.
*/
public function setExtensions($extensions) {
assert('is_array($extensions) || is_null($extensions)');
$this->extensions = $extensions;
}
/** /**
* Convert this authentication request to an XML element. * Convert this authentication request to an XML element.
* *
......
<?php
/**
* Class for handling SAML2 extensions.
*
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_XML_samlp_Extensions {
/**
* Get a list of Extensions in the given element.
*
* @param DOMElement $parent The element that may contain the samlp:Extensions element.
* @return array Array of extensions.
*/
public static function getList(DOMElement $parent) {
$ret = array();
foreach (SAML2_Utils::xpQuery($parent, './saml_protocol:Extensions/*') as $node) {
$ret[] = new SAML2_XML_Chunk($node);
}
return $ret;
}
/**
* Add a list of Extensions to the given element.
*
* @param DOMElement $parent The element we should add the extensions to.
* @param array $extensions List of extension objects.
*/
public static function addList(DOMElement $parent, array $extensions) {
if (empty($extensions)) {
return;
}
$extElement = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAMLP, 'samlp:Extensions');
$parent->appendChild($extElement);
foreach ($extensions as $ext) {
$ext->toXML($extElement);
}
}
}
...@@ -173,6 +173,7 @@ class sspmod_saml_IdP_SAML2 { ...@@ -173,6 +173,7 @@ class sspmod_saml_IdP_SAML2 {
$forceAuthn = FALSE; $forceAuthn = FALSE;
$isPassive = FALSE; $isPassive = FALSE;
$consumerURL = NULL; $consumerURL = NULL;
$extensions = NULL;
SimpleSAML_Logger::info('SAML2.0 - IdP.SSOService: IdP initiated authentication: '. var_export($spEntityId, TRUE)); SimpleSAML_Logger::info('SAML2.0 - IdP.SSOService: IdP initiated authentication: '. var_export($spEntityId, TRUE));
...@@ -204,6 +205,7 @@ class sspmod_saml_IdP_SAML2 { ...@@ -204,6 +205,7 @@ class sspmod_saml_IdP_SAML2 {
$isPassive = $request->getIsPassive(); $isPassive = $request->getIsPassive();
$consumerURL = $request->getAssertionConsumerServiceURL(); $consumerURL = $request->getAssertionConsumerServiceURL();
$protocolBinding = $request->getProtocolBinding(); $protocolBinding = $request->getProtocolBinding();
$extensions = $request->getExtensions();
$nameIdPolicy = $request->getNameIdPolicy(); $nameIdPolicy = $request->getNameIdPolicy();
if (isset($nameIdPolicy['Format'])) { if (isset($nameIdPolicy['Format'])) {
...@@ -283,6 +285,7 @@ class sspmod_saml_IdP_SAML2 { ...@@ -283,6 +285,7 @@ class sspmod_saml_IdP_SAML2 {
'saml:ConsumerURL' => $consumerURL, 'saml:ConsumerURL' => $consumerURL,
'saml:Binding' => $protocolBinding, 'saml:Binding' => $protocolBinding,
'saml:NameIDFormat' => $nameIDFormat, 'saml:NameIDFormat' => $nameIDFormat,
'saml:Extensions' => $extensions,
); );
$idp->handleAuthenticationRequest($state); $idp->handleAuthenticationRequest($state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment