Ejemplo n.º 1
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @throws \RuntimeException
  * @throws \Symfony\Component\Security\Core\Exception\AuthenticationException
  * @throws \InvalidArgumentException if cannot manage the Request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|SamlSpInfo
  */
 public function manage(Request $request)
 {
     if (!$this->supports($request)) {
         throw new \InvalidArgumentException();
     }
     $response = $this->getSamlResponse($request);
     $serviceInfo = $this->serviceInfoCollection->findByIDPEntityID($response->getIssuer());
     $serviceInfo->getSpProvider()->setRequest($request);
     $this->validateResponse($serviceInfo, $response);
     $assertion = $this->getSingleAssertion($response);
     $this->createSSOState($serviceInfo, $assertion);
     return new SamlSpInfo($serviceInfo->getAuthenticationService(), $assertion->getSubject()->getNameID(), $assertion->getAllAttributes(), $assertion->getAuthnStatement());
 }
 /**
  * @param LogoutRequest $logoutRequest
  * @return ServiceInfo|null
  * @throws \RuntimeException
  */
 protected function getServiceInfo(LogoutRequest $logoutRequest)
 {
     $serviceInfo = $this->serviceInfoCollection->findByIDPEntityID($logoutRequest->getIssuer());
     if (!$serviceInfo) {
         throw new \RuntimeException('Got logout request from unknown IDP: ' . $logoutRequest->getIssuer());
     }
     return $serviceInfo;
 }
 protected function deleteSSOSession(LogoutResponse $logoutResponse)
 {
     $serviceInfo = $this->serviceInfoCollection->findByIDPEntityID($logoutResponse->getIssuer());
     /** @var $token SamlSpToken */
     $token = $this->securityContext->getToken();
     if ($token && $token instanceof SamlSpToken) {
         $samlInfo = $token->getSamlSpInfo();
         if ($samlInfo) {
             $arrStates = $this->getSSOState($serviceInfo, $samlInfo->getNameID()->getValue(), $samlInfo->getAuthnStatement()->getSessionIndex());
             $this->deleteSSOState($arrStates);
         }
     }
 }
 /**
  * @test
  */
 public function shouldReturnNullWhenFindByIDPEntityIDIsCalledWithUnknownEntityID()
 {
     $col = new ServiceInfoCollection();
     $this->assertNull($col->findByIDPEntityID('foo'));
 }