/** * @param Assertion $assertion * * @throws LightSamlValidationException */ protected function validateAssertionAttributes(Assertion $assertion) { if (false == Helper::validateRequiredString($assertion->getVersion())) { throw new LightSamlValidationException('Assertion element must have the Version attribute set.'); } if ($assertion->getVersion() != SamlConstants::VERSION_20) { throw new LightSamlValidationException('Assertion element must have the Version attribute value equal to 2.0.'); } if (false == Helper::validateRequiredString($assertion->getId())) { throw new LightSamlValidationException('Assertion element must have the ID attribute set.'); } if (false == Helper::validateIdString($assertion->getId())) { throw new LightSamlValidationException('Assertion element must have an ID attribute with at least 16 characters (the equivalent of 128 bits).'); } if (false == $assertion->getIssueInstantTimestamp()) { throw new LightSamlValidationException('Assertion element must have the IssueInstant attribute set.'); } if (false == $assertion->getIssuer()) { throw new LightSamlValidationException('Assertion element must have an issuer element.'); } $this->nameIdValidator->validateNameId($assertion->getIssuer()); }
public function test__validate_id_string_returns_false_for_short_string() { $this->assertFalse(Helper::validateIdString('')); $this->assertFalse(Helper::validateIdString('abc')); $this->assertFalse(Helper::validateIdString('123456789012345')); }
/** * @param AbstractNameID $nameId */ protected function validateTransientFormat(AbstractNameID $nameId) { if (false == Helper::validateRequiredString($nameId->getValue())) { throw new LightSamlValidationException('NameID with Transient Format attribute MUST contain a Value that contains more than whitespace characters'); } if (strlen($nameId->getValue()) > 256) { throw new LightSamlValidationException('NameID with Transient Format attribute MUST have a Value that contains no more than 256 characters'); } if (false == Helper::validateIdString($nameId->getValue())) { throw new LightSamlValidationException(sprintf("NameID '%s' with Transient Format attribute MUST have a Value with at least 16 characters (the equivalent of 128 bits)", $nameId->getValue())); } }