You are here

public function SamlSPResponse::validateSignedElements in SAML Service Provider 4.x

Same name and namespace in other branches
  1. 8.3 src/SAML/SamlSPResponse.php \Drupal\saml_sp\SAML\SamlSPResponse::validateSignedElements()
  2. 8.2 src/SAML/SamlSPResponse.php \Drupal\saml_sp\SAML\SamlSPResponse::validateSignedElements()
  3. 3.x src/SAML/SamlSPResponse.php \Drupal\saml_sp\SAML\SamlSPResponse::validateSignedElements()

Verifies that the document has the expected signed nodes.

File

src/SAML/SamlSPResponse.php, line 15

Class

SamlSPResponse
Provides the response.

Namespace

Drupal\saml_sp\SAML

Code

public function validateSignedElements($signedElements) {
  if (count($signedElements) > 2) {
    return FALSE;
  }
  $ocurrence = array_count_values($signedElements);
  if (in_array('samlp:Response', $signedElements) && $ocurrence['samlp:Response'] > 1 || in_array('saml:Assertion', $signedElements) && $ocurrence['saml:Assertion'] > 1 || in_array('Assertion', $signedElements) && $ocurrence['Assertion'] > 1 || !in_array('samlp:Response', $signedElements) && !in_array('saml:Assertion', $signedElements) && !in_array('Assertion', $signedElements)) {
    return FALSE;
  }
  return TRUE;
}