You are here

function _saml_sp__extract_inbound_id in SAML Service Provider 7.3

Same name and namespace in other branches
  1. 8.3 saml_sp.module \_saml_sp__extract_inbound_id()
  2. 8.2 saml_sp.module \_saml_sp__extract_inbound_id()
  3. 7.8 saml_sp.module \_saml_sp__extract_inbound_id()
  4. 7 saml_sp.module \_saml_sp__extract_inbound_id()
  5. 7.2 saml_sp.module \_saml_sp__extract_inbound_id()
  6. 4.x saml_sp.module \_saml_sp__extract_inbound_id()
  7. 3.x saml_sp.module \_saml_sp__extract_inbound_id()

Extract the unique ID in an inbound request.

Parameters

String $assertion: UUEncoded SAML assertion from the IdP (i.e. the POST request).

Return value

String|FALSE The unique ID of the inbound request, if it can be decoded. This will be OneLogin\Saml2\AuthRequest::ID_PREFIX, followed by a sha1 hash.

1 call to _saml_sp__extract_inbound_id()
saml_sp__endpoint in ./saml_sp.pages.inc
Page callback to complete the SAML authentication process. This is the consumer endpoint for all SAML authentication requests.

File

./saml_sp.module, line 809
SAML Service Provider

Code

function _saml_sp__extract_inbound_id($assertion) {

  // Decode the request.
  $xml = base64_decode($assertion);

  // Load the XML.
  $document = new DOMDocument();
  if ($document
    ->loadXML($xml)) {
    try {
      $id = @$document->firstChild->attributes
        ->getNamedItem('InResponseTo')->value;
      watchdog('saml_sp', 'SAML login attempt with inbound ID: %id<br/>XML => <br/><pre>@xml</pre>', array(
        '%id' => $id,
        '@xml' => $xml,
      ));
      return $id;
    } catch (Exception $e) {
      watchdog('saml_sp', 'Could not extract inbound ID. %exception', array(
        '%exception' => $e,
      ));
      return FALSE;
    }
  }
  return FALSE;
}