You are here

function _saml_sp__extract_outbound_id in SAML Service Provider 3.x

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

Extract the unique ID of an outbound request.

Parameters

string $encoded_url: The response of AuthRequest::getRedirectUrl(), which is multiple-encoded.

Return value

string|false The unique ID of the outbound request, if it can be decoded. This will be AuthRequest::ID_PREFIX, followed by a SHA1 hash.

File

./saml_sp.module, line 349
SAML Service Provider.

Code

function _saml_sp__extract_outbound_id($encoded_url) {
  $string = $encoded_url;
  $string = @urldecode($string);
  $string = @substr($string, 0, strpos($string, '&'));
  $string = @base64_decode($string);
  $string = @gzinflate($string);

  // This regex is based on the constructor code provided in
  // \OneLogin\Saml2\AuthnRequest.
  $regex = '/^<samlp:AuthnRequest
    xmlns:samlp="' . Constants::NS_SAMLP . '"
    xmlns:saml="' . Constants::NS_SAML . '"
    ID="(ONELOGIN_[0-9a-f]{40})"/m';
  $result = FALSE;
  if (preg_match($regex, $string, $matches)) {
    $result = $matches[1];
  }
  return $result;
}