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

SAML2_AuthnRequest: Add support for retrieving the request id of the generated request.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@726 44740490-163a-0410-bde0-09ae8108e29a
parent 0124dbcd
No related branches found
No related tags found
No related merge requests found
...@@ -21,10 +21,18 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -21,10 +21,18 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
const PROTOCOL = 'saml2'; const PROTOCOL = 'saml2';
/**
* This variable holds the generated request id for this request.
*/
private $id = null;
function __construct(SimpleSAML_Configuration $configuration, SimpleSAML_Metadata_MetaDataStorageHandler $metadatastore) { function __construct(SimpleSAML_Configuration $configuration, SimpleSAML_Metadata_MetaDataStorageHandler $metadatastore) {
$this->configuration = $configuration; $this->configuration = $configuration;
$this->metadata = $metadatastore; $this->metadata = $metadatastore;
/* Generate request id. */
$this->id = SimpleSAML_Utilities::generateID();
} }
public function setXML($xml) { public function setXML($xml) {
...@@ -180,7 +188,6 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -180,7 +188,6 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
public function generate($spentityid, $destination) { public function generate($spentityid, $destination) {
$md = $this->metadata->getMetaData($spentityid); $md = $this->metadata->getMetaData($spentityid);
$id = SimpleSAML_Utilities::generateID();
$issueInstant = SimpleSAML_Utilities::generateTimestamp(); $issueInstant = SimpleSAML_Utilities::generateTimestamp();
$assertionConsumerServiceURL = $this->metadata->getGenerated('AssertionConsumerService', 'saml20-sp-hosted'); $assertionConsumerServiceURL = $this->metadata->getGenerated('AssertionConsumerService', 'saml20-sp-hosted');
...@@ -256,7 +263,7 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -256,7 +263,7 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
*/ */
$authnRequest = '<samlp:AuthnRequest $authnRequest = '<samlp:AuthnRequest
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="' . $id . '" Version="2.0" ID="' . $this->id . '" Version="2.0"
IssueInstant="' . $issueInstant . '" ForceAuthn="' . $forceauthn . '" IsPassive="' . $this->isPassive . '" IssueInstant="' . $issueInstant . '" ForceAuthn="' . $forceauthn . '" IsPassive="' . $this->isPassive . '"
Destination="' . htmlspecialchars($destination) . '" Destination="' . htmlspecialchars($destination) . '"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
...@@ -281,7 +288,16 @@ class SimpleSAML_XML_SAML20_AuthnRequest { ...@@ -281,7 +288,16 @@ class SimpleSAML_XML_SAML20_AuthnRequest {
AllowCreate="true" />'; AllowCreate="true" />';
} }
/**
* Retrieves the request id we used for the generated authentication request.
*
* @return The request id of the generated authentication request.
*/
public function getGeneratedID() {
return $this->id;
}
} }
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment