ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ArtifactResolutionService.php
Go to the documentation of this file.
1<?php
2
11require_once('../../_include.php');
12
14if (!$config->getBoolean('enable.saml20-idp', false)) {
15 throw new SimpleSAML_Error_Error('NOACCESS');
16}
17
19$idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
20$idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-hosted');
21
22if (!$idpMetadata->getBoolean('saml20.sendartifact', false)) {
23 throw new SimpleSAML_Error_Error('NOACCESS');
24}
25
27if ($store === false) {
28 throw new Exception('Unable to send artifact without a datastore configured.');
29}
30
31$binding = new \SAML2\SOAP();
32try {
33 $request = $binding->receive();
34} catch (Exception $e) { // TODO: look for a specific exception
35 // This is dirty. Instead of checking the message of the exception, \SAML2\Binding::getCurrentBinding() should throw
36 // an specific exception when the binding is unknown, and we should capture that here. Also note that the exception
37 // message here is bogus!
38 if ($e->getMessage() === 'Invalid message received to AssertionConsumerService endpoint.') {
39 throw new SimpleSAML_Error_Error('ARSPARAMS', $e, 400);
40 } else {
41 throw $e; // do not ignore other exceptions!
42 }
43}
44if (!($request instanceof \SAML2\ArtifactResolve)) {
45 throw new Exception('Message received on ArtifactResolutionService wasn\'t a ArtifactResolve request.');
46}
47
48$issuer = $request->getIssuer();
49$spMetadata = $metadata->getMetadataConfig($issuer, 'saml20-sp-remote');
50
51$artifact = $request->getArtifact();
52
53$responseData = $store->get('artifact', $artifact);
54$store->delete('artifact', $artifact);
55
56if ($responseData !== null) {
58 $responseXML = $document->firstChild;
59} else {
60 $responseXML = null;
61}
62
63$artifactResponse = new \SAML2\ArtifactResponse();
65$artifactResponse->setInResponseTo($request->getId());
66$artifactResponse->setAny($responseXML);
if(! $config->getBoolean('enable.saml20-idp', false)) $metadata
if(! $idpMetadata->getBoolean('saml20.sendartifact', false)) $store
if($store===false) $binding
catch(Exception $e) if(!($request instanceof \SAML2\ArtifactResolve)) $issuer
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
static getInstance()
Retrieve our singleton instance.
Definition: Store.php:31
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static getMetadataHandler()
This function retrieves the current instance of the metadata handler.
static addSign(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata, \SAML2\SignedElement $element)
Add signature key and sender certificate to an element (Message or Assertion).
Definition: Message.php:20