public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result) { $intendedAudiences = $assertion->getValidAudiences(); if ($intendedAudiences === NULL) { return; } $entityId = $this->serviceProvider->getEntityId(); if (!in_array($entityId, $intendedAudiences)) { $result->addError(sprintf('The configured Service Provider [%s] is not a valid audience for the assertion. Audiences: [%s]', $entityId, implode('], [', $intendedAudiences))); } }