Ejemplo n.º 1
0
 /**
  * @param AssertionConsumerService $assertionConsumerService
  *
  * @return SpSsoDescriptor
  */
 public function addAssertionConsumerService(AssertionConsumerService $assertionConsumerService)
 {
     if (false == is_array($this->assertionConsumerServices)) {
         $this->assertionConsumerServices = array();
     }
     if (null === $assertionConsumerService->getIndex()) {
         $assertionConsumerService->setIndex(count($this->assertionConsumerServices));
     }
     $this->assertionConsumerServices[] = $assertionConsumerService;
     return $this;
 }
Ejemplo n.º 2
0
 public function test_finds_acs_endpoint_and_sets_outbounding_authn_request_acs_url()
 {
     $action = new ACSUrlAction($loggerMock = TestHelper::getLoggerMock($this), $endpointResolverMock = $this->getEndpointResolverMock());
     $context = new ProfileContext(Profiles::SSO_SP_SEND_AUTHN_REQUEST, ProfileContext::ROLE_SP);
     $context->getOwnEntityContext()->setEntityDescriptor($entityDescriptorMock = $this->getEntityDescriptorMock());
     $entityDescriptorMock->expects($this->once())->method('getAllEndpoints')->willReturn([TestHelper::getEndpointReferenceMock($this, $endpoint = new AssertionConsumerService('http://localhost/acs'))]);
     $endpointResolverMock->expects($this->once())->method('resolve')->with($this->isInstanceOf(CriteriaSet::class), $this->isType('array'))->willReturnCallback(function (CriteriaSet $criteriaSet, array $candidates) {
         $this->assertTrue($criteriaSet->has(DescriptorTypeCriteria::class));
         $this->assertEquals(SpSsoDescriptor::class, $criteriaSet->getSingle(DescriptorTypeCriteria::class)->getDescriptorType());
         $this->assertTrue($criteriaSet->has(ServiceTypeCriteria::class));
         $this->assertEquals(AssertionConsumerService::class, $criteriaSet->getSingle(ServiceTypeCriteria::class)->getServiceType());
         $this->assertTrue($criteriaSet->has(BindingCriteria::class));
         $this->assertEquals([SamlConstants::BINDING_SAML2_HTTP_POST], $criteriaSet->getSingle(BindingCriteria::class)->getAllBindings());
         return $candidates;
     });
     $context->getOutboundContext()->setMessage($authnRequest = new AuthnRequest());
     $action->execute($context);
     $this->assertEquals($endpoint->getLocation(), $authnRequest->getAssertionConsumerServiceURL());
 }
 /**
  * @return SpSsoDescriptor|null
  */
 protected function getSpSsoDescriptor()
 {
     if (null === $this->acsUrl) {
         return null;
     }
     $spSso = new SpSsoDescriptor();
     foreach ($this->acsBindings as $index => $biding) {
         $acs = new AssertionConsumerService();
         $acs->setIndex($index)->setLocation($this->acsUrl)->setBinding($biding);
         $spSso->addAssertionConsumerService($acs);
     }
     $this->addKeyDescriptors($spSso);
     return $spSso;
 }