Exemple #1
0
 /**
  * Start a SAML 2 logout operation.
  *
  * @param array $state  The logout state.
  */
 public function startSLO2(&$state)
 {
     assert('is_array($state)');
     assert('array_key_exists("saml:logout:IdP", $state)');
     assert('array_key_exists("saml:logout:NameID", $state)');
     assert('array_key_exists("saml:logout:SessionIndex", $state)');
     $id = SimpleSAML_Auth_State::saveState($state, 'saml:slosent');
     $idp = $state['saml:logout:IdP'];
     $nameId = $state['saml:logout:NameID'];
     $sessionIndex = $state['saml:logout:SessionIndex'];
     $idpMetadata = $this->getIdPMetadata($idp);
     $endpoint = $idpMetadata->getEndpointPrioritizedByBinding('SingleLogoutService', array(\SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HTTP_POST), FALSE);
     if ($endpoint === FALSE) {
         SimpleSAML\Logger::info('No logout endpoint for IdP ' . var_export($idp, TRUE) . '.');
         return;
     }
     $lr = sspmod_saml_Message::buildLogoutRequest($this->metadata, $idpMetadata);
     $lr->setNameId($nameId);
     $lr->setSessionIndex($sessionIndex);
     $lr->setRelayState($id);
     $lr->setDestination($endpoint['Location']);
     $encryptNameId = $idpMetadata->getBoolean('nameid.encryption', NULL);
     if ($encryptNameId === NULL) {
         $encryptNameId = $this->metadata->getBoolean('nameid.encryption', FALSE);
     }
     if ($encryptNameId) {
         $lr->encryptNameId(sspmod_saml_Message::getEncryptionKey($idpMetadata));
     }
     $b = \SAML2\Binding::getBinding($endpoint['Binding']);
     $b->send($lr);
     assert('FALSE');
 }
Exemple #2
0
 /**
  * Send a SAML1 SSO request to an IdP.
  *
  * @param SimpleSAML_Configuration $idpMetadata  The metadata of the IdP.
  * @param array $state  The state array for the current authentication.
  */
 private function startSSO1(SimpleSAML_Configuration $idpMetadata, array $state)
 {
     $idpEntityId = $idpMetadata->getString('entityid');
     $state['saml:idp'] = $idpEntityId;
     $ar = new SimpleSAML_XML_Shib13_AuthnRequest();
     $ar->setIssuer($this->entityId);
     $id = SimpleSAML_Auth_State::saveState($state, 'saml:sp:sso');
     $ar->setRelayState($id);
     $useArtifact = $idpMetadata->getBoolean('saml1.useartifact', NULL);
     if ($useArtifact === NULL) {
         $useArtifact = $this->metadata->getBoolean('saml1.useartifact', FALSE);
     }
     if ($useArtifact) {
         $shire = SimpleSAML_Module::getModuleURL('saml/sp/saml1-acs.php/' . $this->authId . '/artifact');
     } else {
         $shire = SimpleSAML_Module::getModuleURL('saml/sp/saml1-acs.php/' . $this->authId);
     }
     $url = $ar->createRedirect($idpEntityId, $shire);
     SimpleSAML_Logger::debug('Starting SAML 1 SSO to ' . var_export($idpEntityId, TRUE) . ' from ' . var_export($this->entityId, TRUE) . '.');
     SimpleSAML_Utilities::redirect($url);
 }