コード例 #1
0
 /**
  * @test
  */
 public function shouldReturnEmptyArrayWhenAllCalledAndNoneAdded()
 {
     $col = new ServiceInfoCollection();
     $all = $col->all();
     $this->assertInternalType('array', $all);
     $this->assertCount(0, $all);
 }
コード例 #2
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @throws \RuntimeException
  * @throws \InvalidArgumentException if cannot manage the Request
  * @return \Symfony\Component\HttpFoundation\Response|SamlSpInfo
  */
 public function manage(Request $request)
 {
     if (!$this->supports($request)) {
         throw new \InvalidArgumentException('Unsupported request');
     }
     $path = $this->getPath($request);
     $allProviders = $this->metaProviders->all();
     if (count($allProviders) == 1) {
         // there's only one idp... go straight to it
         $names = array_keys($allProviders);
         return new RedirectResponse($path . '?as=' . array_pop($names));
     } else {
         if (count($allProviders) == 0) {
             // configuration validation should ensure this... but anyway just to be sure
             throw new \RuntimeException('At least one authentication service required in configuration');
         } else {
             //$this->metaProviders->get('')->getIdpProvider()->getEntityDescriptor()->getEntityID()
             // present user to choose which idp he wants to authenticate with
             return new Response($this->twig->render('@AerialShipSamlSP/discovery.html.twig', array('providers' => $this->metaProviders->all(), 'path' => $path)));
         }
     }
 }