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

IdP/Artifact: Use the new datastore to store artifacts.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2491 44740490-163a-0410-bde0-09ae8108e29a
parent a7e38a70
Branches
Tags
No related merge requests found
...@@ -20,11 +20,18 @@ class SAML2_HTTPArtifact extends SAML2_Binding { ...@@ -20,11 +20,18 @@ class SAML2_HTTPArtifact extends SAML2_Binding {
*/ */
public function getRedirectURL(SAML2_Message $message) { public function getRedirectURL(SAML2_Message $message) {
$store = SimpleSAML_Store::getInstance();
if ($store === FALSE) {
throw new Exception('Unable to send artifact without a datastore configured.');
}
$generatedId = pack('H*', ((string) SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(20)))); $generatedId = pack('H*', ((string) SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(20))));
$artifact = base64_encode("\x00\x04\x00\x00" . sha1($message->getIssuer(), TRUE) . $generatedId) ; $artifact = base64_encode("\x00\x04\x00\x00" . sha1($message->getIssuer(), TRUE) . $generatedId) ;
$artifactData = $message->toUnsignedXML(); $artifactData = $message->toUnsignedXML();
$artifactDataString = $artifactData->ownerDocument->saveXML($artifactData); $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);
SimpleSAML_Memcache::set('artifact:' . $artifact, $artifactDataString);
$store->set('artifact', $artifact, $artifactDataString, time() + 15*60);
$params = array( $params = array(
'SAMLart' => $artifact, 'SAMLart' => $artifact,
); );
......
...@@ -24,13 +24,18 @@ if (!$idpMetadata->getBoolean('saml20.sendartifact', FALSE)) { ...@@ -24,13 +24,18 @@ if (!$idpMetadata->getBoolean('saml20.sendartifact', FALSE)) {
throw new SimpleSAML_Error_Error('NOACCESS'); throw new SimpleSAML_Error_Error('NOACCESS');
} }
$store = SimpleSAML_Store::getInstance();
if ($store === FALSE) {
throw new Exception('Unable to send artifact without a datastore configured.');
}
$binding = new SAML2_SOAP(); $binding = new SAML2_SOAP();
$request = $binding->receive(); $request = $binding->receive();
if (!($request instanceof SAML2_ArtifactResolve)) { if (!($request instanceof SAML2_ArtifactResolve)) {
throw new Exception('Message received on ArtifactResolutionService wasn\'t a ArtifactResolve request.'); throw new Exception('Message received on ArtifactResolutionService wasn\'t a ArtifactResolve request.');
} }
$artifact = $request->getArtifact(); $artifact = $request->getArtifact();
$responseData = SimpleSAML_Memcache::get('artifact:' . $artifact); $responseData = $store->get('artifact', $artifact);
$document = new DOMDocument(); $document = new DOMDocument();
$document->loadXML($responseData); $document->loadXML($responseData);
$responseXML = $document->firstChild; $responseXML = $document->firstChild;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment