예제 #1
0
 /**
  * @expectedException \LightSaml\Error\LightSamlValidationException
  * @expectedExceptionMessage DNSName attribute of SubjectLocality must contain at least one non-whitespace character
  */
 public function test_authn_statement_fails_with_subject_locality_dns_name_empty_string()
 {
     $subjectLocality = new SubjectLocality();
     $subjectLocality->setDNSName('');
     $authnStatement = new AuthnStatement();
     $authnStatement->setAuthnInstant(123456789)->setSubjectLocality($subjectLocality);
     $validator = new StatementValidator();
     $validator->validateStatement($authnStatement);
 }
 /**
  * @param AssertionContext $context
  *
  * @return void
  */
 protected function doExecute(AssertionContext $context)
 {
     $authnContext = new AuthnContext();
     $authnContextClassRef = $this->sessionInfoProvider->getAuthnContextClassRef() ?: SamlConstants::AUTHN_CONTEXT_UNSPECIFIED;
     $authnContext->setAuthnContextClassRef($authnContextClassRef);
     $authnStatement = new AuthnStatement();
     $authnStatement->setAuthnContext($authnContext);
     $sessionIndex = $this->sessionInfoProvider->getSessionIndex();
     if ($sessionIndex) {
         $authnStatement->setSessionIndex($sessionIndex);
     }
     $authnInstant = $this->sessionInfoProvider->getAuthnInstant() ?: new \DateTime();
     $authnStatement->setAuthnInstant($authnInstant);
     $subjectLocality = new SubjectLocality();
     $subjectLocality->setAddress($context->getProfileContext()->getHttpRequest()->getClientIp());
     $authnStatement->setSubjectLocality($subjectLocality);
     $context->getAssertion()->addItem($authnStatement);
 }