Exemplo n.º 1
0
 public function setSamlSpInfo(SamlSpInfo $info)
 {
     $this->samlSpInfo = $info;
     if ($info->getNameID()) {
         $this->setAttribute(self::ATTRIBUTE_NAME_ID, $info->getNameID()->getValue());
         $this->setAttribute(self::ATTRIBUTE_NAME_ID_FORMAT, $info->getNameID()->getFormat());
     }
     if ($info->getAttributes()) {
         foreach ($info->getAttributes() as $attribute) {
             $value = $attribute->getValues();
             if (count($value) == 1) {
                 $value = array_shift($value);
             }
             $this->setAttribute($attribute->getName(), $value);
         }
     }
     if ($info->getAuthnStatement()) {
         $this->setAttribute(self::ATTRIBUTE_SESSION_INDEX, $info->getAuthnStatement()->getSessionIndex());
     }
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function shouldReturnEmptyArrayWhenNullAttributesSetInConstructor()
 {
     $samlSpInfo = new SamlSpInfo('idp');
     $this->assertEquals(array(), $samlSpInfo->getAttributes());
 }
 /**
  * @param LogoutRequestBuilder $builder
  * @param ServiceInfo $serviceInfo
  * @param SamlSpInfo $samlInfo
  * @return LogoutRequest
  */
 protected function createLogoutRequest(LogoutRequestBuilder $builder, ServiceInfo $serviceInfo, SamlSpInfo $samlInfo)
 {
     $logoutRequest = $builder->build($samlInfo->getNameID()->getValue(), $samlInfo->getNameID()->getFormat(), $samlInfo->getAuthnStatement()->getSessionIndex());
     $logoutRequest->sign($serviceInfo->getSpSigningProvider()->getCertificate(), $serviceInfo->getSpSigningProvider()->getPrivateKey());
     return $logoutRequest;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function createUserFromSamlInfo(SamlSpInfo $samlInfo)
 {
     $repository = $this->container->get('doctrine')->getManager()->getRepository('FITNetopeerBundle:SamlUser');
     $user = $repository->findOneBy(array('nameID' => $samlInfo->getNameID()->getValue()));
     if ($user) {
         $user->setUsername($samlInfo->getAttributes()['eduPersonPrincipalName']->getFirstValue());
         $user->setTargetedID($samlInfo->getAttributes()['eduPersonTargetedID']->getFirstValue());
     } else {
         $user = new SamlUser();
         $user->setUsername($samlInfo->getAttributes()['eduPersonPrincipalName']->getFirstValue());
         $user->setTargetedID($samlInfo->getAttributes()['eduPersonTargetedID']->getFirstValue());
         $user->setSessionIndex($samlInfo->getAuthnStatement()->getSessionIndex());
         $user->setProviderID($samlInfo->getNameID()->getSPProvidedID());
         $user->setAuthenticationServiceName($samlInfo->getAuthenticationServiceID());
         $user->setNameID($samlInfo->getNameID()->getValue());
         $user->setNameIDFormat($samlInfo->getNameID()->getFormat());
     }
     $em = $this->container->get('doctrine')->getManager();
     $em->persist($user);
     $em->flush();
     return $user;
 }